@Test public void testDuplicateDecisionRule() { final DecisionRule rule = DecisionRuleFactory.makeDecisionRule(dtable); final List<UnaryTests> inputEntries = rule.getInputEntry(); assertThat(inputEntries.size()).isEqualTo(2); inputEntries.get(0).getText().setValue(INPUT_CLAUSE_TEXT_1); inputEntries.get(1).getText().setValue(INPUT_CLAUSE_TEXT_2); inputEntries.get(0).setConstraintType(ConstraintType.ENUMERATION); inputEntries.get(1).setConstraintType(ConstraintType.RANGE); final List<LiteralExpression> outputEntries = rule.getOutputEntry(); assertThat(outputEntries.size()).isEqualTo(2); outputEntries.get(0).getText().setValue(OUTPUT_CLAUSE_TEXT_1); outputEntries.get(1).getText().setValue(OUTPUT_CLAUSE_TEXT_2); final List<RuleAnnotationClauseText> annotationEntries = rule.getAnnotationEntry(); assertThat(annotationEntries.size()).isEqualTo(2); annotationEntries.get(0).getText().setValue(RULE_ANNOTATION_CLAUSE_TEXT_1); annotationEntries.get(1).getText().setValue(RULE_ANNOTATION_CLAUSE_TEXT_2); dtable.getRule().add(rule); final DecisionRule duplicate = DecisionRuleFactory.duplicateDecisionRule(0, dtable); final List<UnaryTests> duplicateInputEntries = duplicate.getInputEntry(); assertThat(duplicateInputEntries.size()).isEqualTo(2); assertUnaryTestsText(duplicateInputEntries.get(0), INPUT_CLAUSE_TEXT_1); assertUnaryTestsText(duplicateInputEntries.get(1), INPUT_CLAUSE_TEXT_2); assertThat(duplicateInputEntries.get(0).getConstraintType()).isEqualTo(ConstraintType.ENUMERATION); assertThat(duplicateInputEntries.get(1).getConstraintType()).isEqualTo(ConstraintType.RANGE); assertUnaryTestsInstancesAreNotTheSame(inputEntries.get(0), duplicateInputEntries.get(0)); assertUnaryTestsInstancesAreNotTheSame(inputEntries.get(1), duplicateInputEntries.get(1)); assertThat(duplicateInputEntries).allSatisfy(unaryTests -> assertThat(unaryTests.getParent()).isEqualTo(duplicate)); final List<LiteralExpression> duplicateOutputEntries = duplicate.getOutputEntry(); assertThat(duplicateOutputEntries.size()).isEqualTo(2); assertLiteralExpressionText(duplicateOutputEntries.get(0), OUTPUT_CLAUSE_TEXT_1); assertLiteralExpressionText(duplicateOutputEntries.get(1), OUTPUT_CLAUSE_TEXT_2); assertLiteralExpressionInstancesAreNotTheSame(outputEntries.get(0), duplicateOutputEntries.get(0)); assertLiteralExpressionInstancesAreNotTheSame(outputEntries.get(1), duplicateOutputEntries.get(1)); assertThat(duplicateOutputEntries).allSatisfy(literalExpression -> assertThat(literalExpression.getParent()).isEqualTo(duplicate)); final List<RuleAnnotationClauseText> duplicateRuleAnnotationClauses = duplicate.getAnnotationEntry(); assertThat(duplicateRuleAnnotationClauses.size()).isEqualTo(2); assertAnnotationClauseText(duplicateRuleAnnotationClauses.get(0), RULE_ANNOTATION_CLAUSE_TEXT_1); assertAnnotationClauseText(duplicateRuleAnnotationClauses.get(1), RULE_ANNOTATION_CLAUSE_TEXT_2); assertRuleAnnotationClauseInstancesAreNotTheSame(annotationEntries.get(0), duplicateRuleAnnotationClauses.get(0)); assertRuleAnnotationClauseInstancesAreNotTheSame(annotationEntries.get(1), duplicateRuleAnnotationClauses.get(1)); assertThat(duplicateRuleAnnotationClauses).allSatisfy(ruleAnnotationClauseText -> assertThat(ruleAnnotationClauseText.getParent()).isEqualTo(duplicate)); assertThat(duplicate.getParent()).isEqualTo(dtable); }
public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) { final DecisionRule rule = new DecisionRule(); final DecisionRule source = dtable.getRule().get(index); for (UnaryTests ie : source.getInputEntry()) { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(ie.getText().getValue()); ut.setConstraintType(ie.getConstraintType()); rule.getInputEntry().add(ut); ut.setParent(rule); } for (LiteralExpression oe : source.getOutputEntry()) { final LiteralExpression le = new LiteralExpression(); le.getText().setValue(oe.getText().getValue()); rule.getOutputEntry().add(le); le.setParent(rule); } for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) { final RuleAnnotationClauseText copy = new RuleAnnotationClauseText(); copy.getText().setValue(text.getText().getValue()); copy.setParent(rule); rule.getAnnotationEntry().add(copy); } rule.setParent(dtable); return rule; }
DecisionRuleFactory { public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) { final DecisionRule rule = new DecisionRule(); final DecisionRule source = dtable.getRule().get(index); for (UnaryTests ie : source.getInputEntry()) { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(ie.getText().getValue()); ut.setConstraintType(ie.getConstraintType()); rule.getInputEntry().add(ut); ut.setParent(rule); } for (LiteralExpression oe : source.getOutputEntry()) { final LiteralExpression le = new LiteralExpression(); le.getText().setValue(oe.getText().getValue()); rule.getOutputEntry().add(le); le.setParent(rule); } for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) { final RuleAnnotationClauseText copy = new RuleAnnotationClauseText(); copy.getText().setValue(text.getText().getValue()); copy.setParent(rule); rule.getAnnotationEntry().add(copy); } rule.setParent(dtable); return rule; } }
DecisionRuleFactory { public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) { final DecisionRule rule = new DecisionRule(); final DecisionRule source = dtable.getRule().get(index); for (UnaryTests ie : source.getInputEntry()) { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(ie.getText().getValue()); ut.setConstraintType(ie.getConstraintType()); rule.getInputEntry().add(ut); ut.setParent(rule); } for (LiteralExpression oe : source.getOutputEntry()) { final LiteralExpression le = new LiteralExpression(); le.getText().setValue(oe.getText().getValue()); rule.getOutputEntry().add(le); le.setParent(rule); } for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) { final RuleAnnotationClauseText copy = new RuleAnnotationClauseText(); copy.getText().setValue(text.getText().getValue()); copy.setParent(rule); rule.getAnnotationEntry().add(copy); } rule.setParent(dtable); return rule; }  }
DecisionRuleFactory { public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) { final DecisionRule rule = new DecisionRule(); final DecisionRule source = dtable.getRule().get(index); for (UnaryTests ie : source.getInputEntry()) { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(ie.getText().getValue()); ut.setConstraintType(ie.getConstraintType()); rule.getInputEntry().add(ut); ut.setParent(rule); } for (LiteralExpression oe : source.getOutputEntry()) { final LiteralExpression le = new LiteralExpression(); le.getText().setValue(oe.getText().getValue()); rule.getOutputEntry().add(le); le.setParent(rule); } for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) { final RuleAnnotationClauseText copy = new RuleAnnotationClauseText(); copy.getText().setValue(text.getText().getValue()); copy.setParent(rule); rule.getAnnotationEntry().add(copy); } rule.setParent(dtable); return rule; }  static DecisionRule makeDecisionRule(final DecisionTable dtable); static DecisionRule duplicateDecisionRule(final int index,
                                                     final DecisionTable dtable); }
DecisionRuleFactory { public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) { final DecisionRule rule = new DecisionRule(); final DecisionRule source = dtable.getRule().get(index); for (UnaryTests ie : source.getInputEntry()) { final UnaryTests ut = new UnaryTests(); ut.getText().setValue(ie.getText().getValue()); ut.setConstraintType(ie.getConstraintType()); rule.getInputEntry().add(ut); ut.setParent(rule); } for (LiteralExpression oe : source.getOutputEntry()) { final LiteralExpression le = new LiteralExpression(); le.getText().setValue(oe.getText().getValue()); rule.getOutputEntry().add(le); le.setParent(rule); } for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) { final RuleAnnotationClauseText copy = new RuleAnnotationClauseText(); copy.getText().setValue(text.getText().getValue()); copy.setParent(rule); rule.getAnnotationEntry().add(copy); } rule.setParent(dtable); return rule; }  static DecisionRule makeDecisionRule(final DecisionTable dtable); static DecisionRule duplicateDecisionRule(final int index,
                                                     final DecisionTable dtable);  }