@Test @SuppressWarnings("unchecked") public void testWBFromDMN() { final Node<View<Decision>, ?> factoryNode = new NodeImpl<>(UUID.uuid()); final View<Decision> view = new ViewImpl<>(new Decision(), Bounds.create()); factoryNode.setContent(view); when(factoryManager.newElement(anyString(), eq(getDefinitionId(Decision.class)))).thenReturn(element); when(element.asNode()).thenReturn(factoryNode); final org.kie.dmn.model.api.Decision dmn = new TDecision(); final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression(); final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem(); literalExpression.setId(EXPRESSION_UUID); dmn.setId(DECISION_UUID); dmn.setName(DECISION_NAME); dmn.setDescription(DECISION_DESCRIPTION); dmn.setVariable(informationItem); dmn.setExpression(literalExpression); final Node<View<Decision>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer); final Decision wb = (Decision) DefinitionUtils.getElementDefinition(node); assertThat(wb).isNotNull(); assertThat(wb.getId()).isNotNull(); assertThat(wb.getId().getValue()).isEqualTo(DECISION_UUID); assertThat(wb.getName()).isNotNull(); assertThat(wb.getName().getValue()).isEqualTo(DECISION_NAME); assertThat(wb.getDescription()).isNotNull(); assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_DESCRIPTION); assertThat(wb.getVariable()).isNotNull(); assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_NAME); 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()); }
@Override public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode(); final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final Name name = new Name(dmn.getName()); final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion())); decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers())); node.getContent().setDefinition(decision); if (informationItem != null) { informationItem.setParent(decision); } if (expression != null) { expression.setParent(decision); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision); return node; }
DecisionConverter implements NodeConverter<org.kie.dmn.model.api.Decision, org.kie.workbench.common.dmn.api.definition.model.Decision> { @Override public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode(); final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final Name name = new Name(dmn.getName()); final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion())); decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers())); node.getContent().setDefinition(decision); if (informationItem != null) { informationItem.setParent(decision); } if (expression != null) { expression.setParent(decision); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision); return node; } }
DecisionConverter implements NodeConverter<org.kie.dmn.model.api.Decision, org.kie.workbench.common.dmn.api.definition.model.Decision> { @Override public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode(); final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final Name name = new Name(dmn.getName()); final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion())); decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers())); node.getContent().setDefinition(decision); if (informationItem != null) { informationItem.setParent(decision); } if (expression != null) { expression.setParent(decision); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision); return node; } DecisionConverter(final FactoryManager factoryManager); }
DecisionConverter implements NodeConverter<org.kie.dmn.model.api.Decision, org.kie.workbench.common.dmn.api.definition.model.Decision> { @Override public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode(); final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final Name name = new Name(dmn.getName()); final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion())); decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers())); node.getContent().setDefinition(decision); if (informationItem != null) { informationItem.setParent(decision); } if (expression != null) { expression.setParent(decision); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision); return node; } DecisionConverter(final FactoryManager factoryManager); @Override Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn,
                                               final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); @Override org.kie.dmn.model.api.Decision dmnFromNode(final Node<View<Decision>, ?> node,
                                                      final Consumer<ComponentWidths> componentWidthsConsumer); }
DecisionConverter implements NodeConverter<org.kie.dmn.model.api.Decision, org.kie.workbench.common.dmn.api.definition.model.Decision> { @Override public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(Decision.class)).asNode(); final Id id = new Id(dmn.getId()); final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription()); final Name name = new Name(dmn.getName()); final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn); final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer); final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion())); decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers())); node.getContent().setDefinition(decision); if (informationItem != null) { informationItem.setParent(decision); } if (expression != null) { expression.setParent(decision); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision); return node; } DecisionConverter(final FactoryManager factoryManager); @Override Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.api.Decision dmn,
                                               final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); @Override org.kie.dmn.model.api.Decision dmnFromNode(final Node<View<Decision>, ?> node,
                                                      final Consumer<ComponentWidths> componentWidthsConsumer);  }