@Test public void testConverterWhenJSITOutputTypeRefIsNullThenDecisionTableOutputTypeRefIsUndefined() { when(jsitDecisionTable.getOutput()).thenReturn(jsitOutput); when(jsitOutput.size()).thenReturn(1); when(jsitOutput.get(0)).thenReturn(jsitOutputItem); final DecisionTable decisionTable = DecisionTablePropertyConverter.wbFromDMN(jsitDecisionTable); assertNotNull(decisionTable); assertNotNull(decisionTable.getOutput()); assertEquals(1, decisionTable.getOutput().size()); assertEquals(BuiltInType.UNDEFINED.asQName(), decisionTable.getOutput().get(0).getTypeRef()); }
public static DecisionTable wbFromDMN(final JSITDecisionTable dmn) { final Id id = IdPropertyConverter.wbFromDMN(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef()); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); final List<JSITRuleAnnotationClause> jsiRuleAnnotationClauses = dmn.getAnnotation(); if (jsiRuleAnnotationClauses.isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (int i = 0; i < jsiRuleAnnotationClauses.size(); i++) { final JSITRuleAnnotationClause ruleAnnotationClause = Js.uncheckedCast(jsiRuleAnnotationClauses.get(i)); final RuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.wbFromDMN(ruleAnnotationClause); if (Objects.nonNull(converted)) { converted.setParent(result); result.getAnnotations().add(converted); } } } final List<JSITInputClause> jsiInputClauses = dmn.getInput(); for (int i = 0; i < jsiInputClauses.size(); i++) { final JSITInputClause input = Js.uncheckedCast(jsiInputClauses.get(i)); final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (Objects.nonNull(inputClauseConverted)) { inputClauseConverted.setParent(result); result.getInput().add(inputClauseConverted); } } final List<JSITOutputClause> jsiOutputClauses = dmn.getOutput(); for (int i = 0; i < jsiOutputClauses.size(); i++) { final JSITOutputClause output = Js.uncheckedCast(jsiOutputClauses.get(i)); final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (Objects.nonNull(outputClauseConverted)) { outputClauseConverted.setParent(result); result.getOutput().add(outputClauseConverted); } } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(BuiltInType.UNDEFINED.asQName()); } final List<JSITDecisionRule> jsiDecisionRules = dmn.getRule(); for (int i = 0; i < jsiDecisionRules.size(); i++) { final JSITDecisionRule dr = Js.uncheckedCast(jsiDecisionRules.get(i)); final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (Objects.nonNull(decisionRuleConverted)) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } final String hitPolicy = Js.uncheckedCast(dmn.getHitPolicy()); if (Objects.nonNull(hitPolicy)) { result.setHitPolicy(HitPolicy.fromValue(hitPolicy)); } final String aggregation = Js.uncheckedCast(dmn.getAggregation()); if (Objects.nonNull(aggregation)) { result.setAggregation(BuiltinAggregator.fromValue(aggregation)); } final String orientation = Js.uncheckedCast(dmn.getPreferredOrientation()); if (Objects.nonNull(orientation)) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(orientation)); } result.setOutputLabel(dmn.getOutputLabel()); return result; }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final JSITDecisionTable dmn) { final Id id = IdPropertyConverter.wbFromDMN(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef()); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); final List<JSITRuleAnnotationClause> jsiRuleAnnotationClauses = dmn.getAnnotation(); if (jsiRuleAnnotationClauses.isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (int i = 0; i < jsiRuleAnnotationClauses.size(); i++) { final JSITRuleAnnotationClause ruleAnnotationClause = Js.uncheckedCast(jsiRuleAnnotationClauses.get(i)); final RuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.wbFromDMN(ruleAnnotationClause); if (Objects.nonNull(converted)) { converted.setParent(result); result.getAnnotations().add(converted); } } } final List<JSITInputClause> jsiInputClauses = dmn.getInput(); for (int i = 0; i < jsiInputClauses.size(); i++) { final JSITInputClause input = Js.uncheckedCast(jsiInputClauses.get(i)); final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (Objects.nonNull(inputClauseConverted)) { inputClauseConverted.setParent(result); result.getInput().add(inputClauseConverted); } } final List<JSITOutputClause> jsiOutputClauses = dmn.getOutput(); for (int i = 0; i < jsiOutputClauses.size(); i++) { final JSITOutputClause output = Js.uncheckedCast(jsiOutputClauses.get(i)); final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (Objects.nonNull(outputClauseConverted)) { outputClauseConverted.setParent(result); result.getOutput().add(outputClauseConverted); } } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(BuiltInType.UNDEFINED.asQName()); } final List<JSITDecisionRule> jsiDecisionRules = dmn.getRule(); for (int i = 0; i < jsiDecisionRules.size(); i++) { final JSITDecisionRule dr = Js.uncheckedCast(jsiDecisionRules.get(i)); final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (Objects.nonNull(decisionRuleConverted)) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } final String hitPolicy = Js.uncheckedCast(dmn.getHitPolicy()); if (Objects.nonNull(hitPolicy)) { result.setHitPolicy(HitPolicy.fromValue(hitPolicy)); } final String aggregation = Js.uncheckedCast(dmn.getAggregation()); if (Objects.nonNull(aggregation)) { result.setAggregation(BuiltinAggregator.fromValue(aggregation)); } final String orientation = Js.uncheckedCast(dmn.getPreferredOrientation()); if (Objects.nonNull(orientation)) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(orientation)); } result.setOutputLabel(dmn.getOutputLabel()); return result; } }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final JSITDecisionTable dmn) { final Id id = IdPropertyConverter.wbFromDMN(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef()); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); final List<JSITRuleAnnotationClause> jsiRuleAnnotationClauses = dmn.getAnnotation(); if (jsiRuleAnnotationClauses.isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (int i = 0; i < jsiRuleAnnotationClauses.size(); i++) { final JSITRuleAnnotationClause ruleAnnotationClause = Js.uncheckedCast(jsiRuleAnnotationClauses.get(i)); final RuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.wbFromDMN(ruleAnnotationClause); if (Objects.nonNull(converted)) { converted.setParent(result); result.getAnnotations().add(converted); } } } final List<JSITInputClause> jsiInputClauses = dmn.getInput(); for (int i = 0; i < jsiInputClauses.size(); i++) { final JSITInputClause input = Js.uncheckedCast(jsiInputClauses.get(i)); final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (Objects.nonNull(inputClauseConverted)) { inputClauseConverted.setParent(result); result.getInput().add(inputClauseConverted); } } final List<JSITOutputClause> jsiOutputClauses = dmn.getOutput(); for (int i = 0; i < jsiOutputClauses.size(); i++) { final JSITOutputClause output = Js.uncheckedCast(jsiOutputClauses.get(i)); final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (Objects.nonNull(outputClauseConverted)) { outputClauseConverted.setParent(result); result.getOutput().add(outputClauseConverted); } } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(BuiltInType.UNDEFINED.asQName()); } final List<JSITDecisionRule> jsiDecisionRules = dmn.getRule(); for (int i = 0; i < jsiDecisionRules.size(); i++) { final JSITDecisionRule dr = Js.uncheckedCast(jsiDecisionRules.get(i)); final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (Objects.nonNull(decisionRuleConverted)) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } final String hitPolicy = Js.uncheckedCast(dmn.getHitPolicy()); if (Objects.nonNull(hitPolicy)) { result.setHitPolicy(HitPolicy.fromValue(hitPolicy)); } final String aggregation = Js.uncheckedCast(dmn.getAggregation()); if (Objects.nonNull(aggregation)) { result.setAggregation(BuiltinAggregator.fromValue(aggregation)); } final String orientation = Js.uncheckedCast(dmn.getPreferredOrientation()); if (Objects.nonNull(orientation)) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(orientation)); } result.setOutputLabel(dmn.getOutputLabel()); return result; }  }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final JSITDecisionTable dmn) { final Id id = IdPropertyConverter.wbFromDMN(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef()); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); final List<JSITRuleAnnotationClause> jsiRuleAnnotationClauses = dmn.getAnnotation(); if (jsiRuleAnnotationClauses.isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (int i = 0; i < jsiRuleAnnotationClauses.size(); i++) { final JSITRuleAnnotationClause ruleAnnotationClause = Js.uncheckedCast(jsiRuleAnnotationClauses.get(i)); final RuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.wbFromDMN(ruleAnnotationClause); if (Objects.nonNull(converted)) { converted.setParent(result); result.getAnnotations().add(converted); } } } final List<JSITInputClause> jsiInputClauses = dmn.getInput(); for (int i = 0; i < jsiInputClauses.size(); i++) { final JSITInputClause input = Js.uncheckedCast(jsiInputClauses.get(i)); final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (Objects.nonNull(inputClauseConverted)) { inputClauseConverted.setParent(result); result.getInput().add(inputClauseConverted); } } final List<JSITOutputClause> jsiOutputClauses = dmn.getOutput(); for (int i = 0; i < jsiOutputClauses.size(); i++) { final JSITOutputClause output = Js.uncheckedCast(jsiOutputClauses.get(i)); final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (Objects.nonNull(outputClauseConverted)) { outputClauseConverted.setParent(result); result.getOutput().add(outputClauseConverted); } } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(BuiltInType.UNDEFINED.asQName()); } final List<JSITDecisionRule> jsiDecisionRules = dmn.getRule(); for (int i = 0; i < jsiDecisionRules.size(); i++) { final JSITDecisionRule dr = Js.uncheckedCast(jsiDecisionRules.get(i)); final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (Objects.nonNull(decisionRuleConverted)) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } final String hitPolicy = Js.uncheckedCast(dmn.getHitPolicy()); if (Objects.nonNull(hitPolicy)) { result.setHitPolicy(HitPolicy.fromValue(hitPolicy)); } final String aggregation = Js.uncheckedCast(dmn.getAggregation()); if (Objects.nonNull(aggregation)) { result.setAggregation(BuiltinAggregator.fromValue(aggregation)); } final String orientation = Js.uncheckedCast(dmn.getPreferredOrientation()); if (Objects.nonNull(orientation)) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(orientation)); } result.setOutputLabel(dmn.getOutputLabel()); return result; }  static DecisionTable wbFromDMN(final JSITDecisionTable dmn); static JSITDecisionTable dmnFromWB(final DecisionTable wb); }
DecisionTablePropertyConverter { public static DecisionTable wbFromDMN(final JSITDecisionTable dmn) { final Id id = IdPropertyConverter.wbFromDMN(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef()); final DecisionTable result = new DecisionTable(); result.setId(id); result.setDescription(description); result.setTypeRef(typeRef); final List<JSITRuleAnnotationClause> jsiRuleAnnotationClauses = dmn.getAnnotation(); if (jsiRuleAnnotationClauses.isEmpty()) { final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.setParent(result); result.getAnnotations().add(ruleAnnotationClause); } else { for (int i = 0; i < jsiRuleAnnotationClauses.size(); i++) { final JSITRuleAnnotationClause ruleAnnotationClause = Js.uncheckedCast(jsiRuleAnnotationClauses.get(i)); final RuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.wbFromDMN(ruleAnnotationClause); if (Objects.nonNull(converted)) { converted.setParent(result); result.getAnnotations().add(converted); } } } final List<JSITInputClause> jsiInputClauses = dmn.getInput(); for (int i = 0; i < jsiInputClauses.size(); i++) { final JSITInputClause input = Js.uncheckedCast(jsiInputClauses.get(i)); final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input); if (Objects.nonNull(inputClauseConverted)) { inputClauseConverted.setParent(result); result.getInput().add(inputClauseConverted); } } final List<JSITOutputClause> jsiOutputClauses = dmn.getOutput(); for (int i = 0; i < jsiOutputClauses.size(); i++) { final JSITOutputClause output = Js.uncheckedCast(jsiOutputClauses.get(i)); final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output); if (Objects.nonNull(outputClauseConverted)) { outputClauseConverted.setParent(result); result.getOutput().add(outputClauseConverted); } } if (result.getOutput().size() == 1) { final OutputClause outputClause = result.getOutput().get(0); outputClause.setName(null); outputClause.setTypeRef(BuiltInType.UNDEFINED.asQName()); } final List<JSITDecisionRule> jsiDecisionRules = dmn.getRule(); for (int i = 0; i < jsiDecisionRules.size(); i++) { final JSITDecisionRule dr = Js.uncheckedCast(jsiDecisionRules.get(i)); final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr); if (Objects.nonNull(decisionRuleConverted)) { decisionRuleConverted.setParent(result); } result.getRule().add(decisionRuleConverted); } final String hitPolicy = Js.uncheckedCast(dmn.getHitPolicy()); if (Objects.nonNull(hitPolicy)) { result.setHitPolicy(HitPolicy.fromValue(hitPolicy)); } final String aggregation = Js.uncheckedCast(dmn.getAggregation()); if (Objects.nonNull(aggregation)) { result.setAggregation(BuiltinAggregator.fromValue(aggregation)); } final String orientation = Js.uncheckedCast(dmn.getPreferredOrientation()); if (Objects.nonNull(orientation)) { result.setPreferredOrientation(DecisionTableOrientation.fromValue(orientation)); } result.setOutputLabel(dmn.getOutputLabel()); return result; }  static DecisionTable wbFromDMN(final JSITDecisionTable dmn); static JSITDecisionTable dmnFromWB(final DecisionTable wb);  }