@Test public void testWBFromDMN() { final org.kie.dmn.model.api.FunctionDefinition dmn = new TFunctionDefinition(); final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression(); literalExpression.setId(EXPRESSION_UUID); dmn.setId(FUNCTION_DEFINITION_UUID); dmn.setDescription(FUNCTION_DEFINITION_DESCRIPTION); dmn.setTypeRef(new QName(FUNCTION_DEFINITION_QNAME_LOCALPART)); dmn.setKind(FunctionKind.JAVA); dmn.setExpression(literalExpression); final FunctionDefinition wb = FunctionDefinitionPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer); assertThat(wb).isNotNull(); assertThat(wb.getId()).isNotNull(); assertThat(wb.getId().getValue()).isEqualTo(FUNCTION_DEFINITION_UUID); assertThat(wb.getDescription()).isNotNull(); assertThat(wb.getDescription().getValue()).isEqualTo(FUNCTION_DEFINITION_DESCRIPTION); assertThat(wb.getTypeRef()).isNotNull(); assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(FUNCTION_DEFINITION_QNAME_LOCALPART); assertThat(wb.getKind()).isNotNull(); assertThat(wb.getKind()).isEqualTo(FunctionDefinition.Kind.JAVA); assertThat(wb.getExpression()).isNotNull(); assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID); verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture()); final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue(); assertThat(hasComponentWidths).isNotNull(); assertThat(hasComponentWidths).isEqualTo(wb.getExpression()); }
public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { if (dmn == null) { return null; } final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression); if (expression != null) { expression.setParent(result); } final FunctionKind kind = dmn.getKind(); switch (kind) { case FEEL: result.setKind(Kind.FEEL); break; case JAVA: result.setKind(Kind.JAVA); break; case PMML: result.setKind(Kind.PMML); convertPMMLFunctionExpression(result); break; default: result.setKind(Kind.FEEL); break; } for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) { final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii); if (iiConverted != null) { iiConverted.setParent(result); } result.getFormalParameter().add(iiConverted); } return result; }
FunctionDefinitionPropertyConverter { public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { if (dmn == null) { return null; } final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression); if (expression != null) { expression.setParent(result); } final FunctionKind kind = dmn.getKind(); switch (kind) { case FEEL: result.setKind(Kind.FEEL); break; case JAVA: result.setKind(Kind.JAVA); break; case PMML: result.setKind(Kind.PMML); convertPMMLFunctionExpression(result); break; default: result.setKind(Kind.FEEL); break; } for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) { final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii); if (iiConverted != null) { iiConverted.setParent(result); } result.getFormalParameter().add(iiConverted); } return result; } }
FunctionDefinitionPropertyConverter { public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { if (dmn == null) { return null; } final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression); if (expression != null) { expression.setParent(result); } final FunctionKind kind = dmn.getKind(); switch (kind) { case FEEL: result.setKind(Kind.FEEL); break; case JAVA: result.setKind(Kind.JAVA); break; case PMML: result.setKind(Kind.PMML); convertPMMLFunctionExpression(result); break; default: result.setKind(Kind.FEEL); break; } for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) { final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii); if (iiConverted != null) { iiConverted.setParent(result); } result.getFormalParameter().add(iiConverted); } return result; }  }
FunctionDefinitionPropertyConverter { public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { if (dmn == null) { return null; } final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression); if (expression != null) { expression.setParent(result); } final FunctionKind kind = dmn.getKind(); switch (kind) { case FEEL: result.setKind(Kind.FEEL); break; case JAVA: result.setKind(Kind.JAVA); break; case PMML: result.setKind(Kind.PMML); convertPMMLFunctionExpression(result); break; default: result.setKind(Kind.FEEL); break; } for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) { final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii); if (iiConverted != null) { iiConverted.setParent(result); } result.getFormalParameter().add(iiConverted); } return result; }  static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn,
                                               final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); static org.kie.dmn.model.api.FunctionDefinition dmnFromWB(final FunctionDefinition wb,
                                                                     final Consumer<ComponentWidths> componentWidthsConsumer); }
FunctionDefinitionPropertyConverter { public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { if (dmn == null) { return null; } final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression); if (expression != null) { expression.setParent(result); } final FunctionKind kind = dmn.getKind(); switch (kind) { case FEEL: result.setKind(Kind.FEEL); break; case JAVA: result.setKind(Kind.JAVA); break; case PMML: result.setKind(Kind.PMML); convertPMMLFunctionExpression(result); break; default: result.setKind(Kind.FEEL); break; } for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) { final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii); if (iiConverted != null) { iiConverted.setParent(result); } result.getFormalParameter().add(iiConverted); } return result; }  static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn,
                                               final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); static org.kie.dmn.model.api.FunctionDefinition dmnFromWB(final FunctionDefinition wb,
                                                                     final Consumer<ComponentWidths> componentWidthsConsumer);  }