public EditAction generate(final Random random, FeatureModel model, OperationType operationType) { EditAction action = new EditAction(); action.setEditObjectType(EditObjectType.FeatureGroup); if (operationType == OperationType.Random) { operationType = random.nextBoolean() ? OperationType.AllAdd : OperationType.AllRemove; } if (operationType == OperationType.AllAdd) { action.setEditType(EditType.Add); FeatureGroup group = new FeatureGroup(); List<Feature> children = new ArrayList<Feature>(); for (int i = 0; i < random.nextInt(3); i++) { children.add(new Feature(Utility.getNewFeatureName(false))); } group.setChildren(children); action.addParameter("group", group); action.addParameter("targetCompound", Utility.getRandomCompound(model, random, false)); } else { action.setEditType(EditType.Remove); } return action; }
public EditAction generate(final Random random, FeatureModel model, OperationType operationType) { EditAction action = new EditAction(); action.setEditType(EditType.Set); action.setEditObjectType(EditObjectType.GroupType); action.addParameter("feature", Utility.getRandomCompound(model, random, false)); FeatureGroupType type; if (random.nextBoolean()) { type = FeatureGroupType.Alternative; } else { if (random.nextBoolean()) { type = FeatureGroupType.Or; } else { type = FeatureGroupType.And; } } action.addParameter("newGroupType", type); return action; }
public EditAction generate(final Random random, FeatureModel model, OperationType operationType) { EditAction action = new EditAction(); action.setEditObjectType(EditObjectType.Compound); if (operationType == OperationType.Random) { operationType = random.nextBoolean() ? OperationType.AllAdd : OperationType.AllRemove; } if (operationType == OperationType.AllAdd) { action.setEditType(EditType.Add); action.addParameter("targetFeature", Utility.getRandomFeature(model, random, false)); Feature newCompound = new Feature(Utility.getNewFeatureName(true)); action.addParameter("newCompound", newCompound); } else { action.setEditType(EditType.Remove); action.addParameter("compound", Utility.getRandomCompound(model, random, false)); } return action; }