@Test @SuppressWarnings("unchecked") public void testWBFromDMN() { final Node<View<BusinessKnowledgeModel>, ?> factoryNode = new NodeImpl<>(UUID.uuid()); final View<BusinessKnowledgeModel> view = new ViewImpl<>(new BusinessKnowledgeModel(), Bounds.create()); factoryNode.setContent(view); when(factoryManager.newElement(anyString(), eq(getDefinitionId(BusinessKnowledgeModel.class)))).thenReturn(element); when(element.asNode()).thenReturn(factoryNode); final org.kie.dmn.model.api.BusinessKnowledgeModel dmn = new TBusinessKnowledgeModel(); final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression(); final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem(); final org.kie.dmn.model.api.FunctionDefinition functionDefinition = new TFunctionDefinition(); literalExpression.setId(EXPRESSION_UUID); functionDefinition.setExpression(literalExpression); functionDefinition.setId(FUNCTION_DEFINITION_UUID); dmn.setId(DECISION_UUID); dmn.setName(DECISION_NAME); dmn.setDescription(DECISION_DESCRIPTION); dmn.setVariable(informationItem); dmn.setEncapsulatedLogic(functionDefinition); final Node<View<BusinessKnowledgeModel>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer); final BusinessKnowledgeModel wb = (BusinessKnowledgeModel) 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.getEncapsulatedLogic()).isNotNull(); assertThat(wb.getEncapsulatedLogic().getExpression()).isNotNull(); assertThat(wb.getEncapsulatedLogic().getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID); verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture()); final HasComponentWidths hasComponentWidths0 = hasComponentWidthsCaptor.getValue(); assertThat(hasComponentWidths0).isNotNull(); assertThat(hasComponentWidths0).isEqualTo(wb.getEncapsulatedLogic().getExpression()); verify(hasComponentWidthsConsumer).accept(eq(FUNCTION_DEFINITION_UUID), hasComponentWidthsCaptor.capture()); final HasComponentWidths hasComponentWidths1 = hasComponentWidthsCaptor.getValue(); assertThat(hasComponentWidths1).isNotNull(); assertThat(hasComponentWidths1).isEqualTo(wb.getEncapsulatedLogic()); }
@Override public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(BusinessKnowledgeModel.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 org.kie.dmn.model.api.FunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic(); final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, hasComponentWidthsConsumer); final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); node.getContent().setDefinition(bkm); if (informationItem != null) { informationItem.setParent(bkm); } if (functionDefinition != null) { functionDefinition.setParent(bkm); } if (Objects.nonNull(dmnFunctionDefinition)) { hasComponentWidthsConsumer.accept(dmnFunctionDefinition.getId(), functionDefinition); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm); return node; }
BusinessKnowledgeModelConverter implements NodeConverter<org.kie.dmn.model.api.BusinessKnowledgeModel, org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel> { @Override public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(BusinessKnowledgeModel.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 org.kie.dmn.model.api.FunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic(); final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, hasComponentWidthsConsumer); final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); node.getContent().setDefinition(bkm); if (informationItem != null) { informationItem.setParent(bkm); } if (functionDefinition != null) { functionDefinition.setParent(bkm); } if (Objects.nonNull(dmnFunctionDefinition)) { hasComponentWidthsConsumer.accept(dmnFunctionDefinition.getId(), functionDefinition); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm); return node; } }
BusinessKnowledgeModelConverter implements NodeConverter<org.kie.dmn.model.api.BusinessKnowledgeModel, org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel> { @Override public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(BusinessKnowledgeModel.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 org.kie.dmn.model.api.FunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic(); final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, hasComponentWidthsConsumer); final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); node.getContent().setDefinition(bkm); if (informationItem != null) { informationItem.setParent(bkm); } if (functionDefinition != null) { functionDefinition.setParent(bkm); } if (Objects.nonNull(dmnFunctionDefinition)) { hasComponentWidthsConsumer.accept(dmnFunctionDefinition.getId(), functionDefinition); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm); return node; } BusinessKnowledgeModelConverter(final FactoryManager factoryManager); }
BusinessKnowledgeModelConverter implements NodeConverter<org.kie.dmn.model.api.BusinessKnowledgeModel, org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel> { @Override public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(BusinessKnowledgeModel.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 org.kie.dmn.model.api.FunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic(); final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, hasComponentWidthsConsumer); final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); node.getContent().setDefinition(bkm); if (informationItem != null) { informationItem.setParent(bkm); } if (functionDefinition != null) { functionDefinition.setParent(bkm); } if (Objects.nonNull(dmnFunctionDefinition)) { hasComponentWidthsConsumer.accept(dmnFunctionDefinition.getId(), functionDefinition); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm); return node; } BusinessKnowledgeModelConverter(final FactoryManager factoryManager); @Override Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn,
                                                             final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); @Override org.kie.dmn.model.api.BusinessKnowledgeModel dmnFromNode(final Node<View<BusinessKnowledgeModel>, ?> node,
                                                                    final Consumer<ComponentWidths> componentWidthsConsumer); }
BusinessKnowledgeModelConverter implements NodeConverter<org.kie.dmn.model.api.BusinessKnowledgeModel, org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel> { @Override public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) { @SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(BusinessKnowledgeModel.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 org.kie.dmn.model.api.FunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic(); final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, hasComponentWidthsConsumer); final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new BackgroundSet(), new FontSet(), new GeneralRectangleDimensionsSet()); node.getContent().setDefinition(bkm); if (informationItem != null) { informationItem.setParent(bkm); } if (functionDefinition != null) { functionDefinition.setParent(bkm); } if (Objects.nonNull(dmnFunctionDefinition)) { hasComponentWidthsConsumer.accept(dmnFunctionDefinition.getId(), functionDefinition); } DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm); return node; } BusinessKnowledgeModelConverter(final FactoryManager factoryManager); @Override Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final org.kie.dmn.model.api.BusinessKnowledgeModel dmn,
                                                             final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); @Override org.kie.dmn.model.api.BusinessKnowledgeModel dmnFromNode(final Node<View<BusinessKnowledgeModel>, ?> node,
                                                                    final Consumer<ComponentWidths> componentWidthsConsumer);  }