@Test public void testDMNFromWB() { final Relation wb = new Relation(); final InformationItem informationItem = new InformationItem(); final List list = new List(); final LiteralExpression literalExpression = new LiteralExpression(); final HasExpression hasExpression = HasExpression.wrap(wb, literalExpression); literalExpression.getComponentWidths().set(0, 200.0); literalExpression.getId().setValue(EXPRESSION_UUID); list.getExpression().add(hasExpression); wb.getId().setValue(RELATION_UUID); wb.getDescription().setValue(RELATION_DESCRIPTION); wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, RELATION_QNAME_LOCALPART)); wb.getColumn().add(informationItem); wb.getRow().add(list); final org.kie.dmn.model.api.Relation dmn = RelationPropertyConverter.dmnFromWB(wb, componentWidthsConsumer); assertThat(dmn).isNotNull(); assertThat(dmn.getId()).isNotNull(); assertThat(dmn.getId()).isEqualTo(RELATION_UUID); assertThat(dmn.getDescription()).isNotNull(); assertThat(dmn.getDescription()).isEqualTo(RELATION_DESCRIPTION); assertThat(dmn.getTypeRef()).isNotNull(); assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(RELATION_QNAME_LOCALPART); assertThat(dmn.getColumn()).isNotNull(); assertThat(dmn.getColumn().size()).isEqualTo(1); assertThat(dmn.getColumn().get(0)).isNotNull(); assertThat(dmn.getRow()).isNotNull(); assertThat(dmn.getRow().size()).isEqualTo(1); assertThat(dmn.getRow().get(0)).isNotNull(); assertThat(dmn.getRow().get(0).getExpression()).isNotNull(); assertThat(dmn.getRow().get(0).getExpression().size()).isEqualTo(1); assertThat(dmn.getRow().get(0).getExpression().get(0).getId()).isEqualTo(EXPRESSION_UUID); verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture()); final ComponentWidths componentWidths = componentWidthsCaptor.getValue(); assertThat(componentWidths).isNotNull(); assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID); assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount()); assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0); }
public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (InformationItem iitem : wb.getColumn()) { final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem); if (iitemConverted != null) { iitemConverted.setParent(result); } result.getColumn().add(iitemConverted); } for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) { final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer); if (listConverted != null) { listConverted.setParent(result); } result.getRow().add(listConverted); } return result; }
RelationPropertyConverter { public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (InformationItem iitem : wb.getColumn()) { final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem); if (iitemConverted != null) { iitemConverted.setParent(result); } result.getColumn().add(iitemConverted); } for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) { final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer); if (listConverted != null) { listConverted.setParent(result); } result.getRow().add(listConverted); } return result; } }
RelationPropertyConverter { public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (InformationItem iitem : wb.getColumn()) { final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem); if (iitemConverted != null) { iitemConverted.setParent(result); } result.getColumn().add(iitemConverted); } for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) { final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer); if (listConverted != null) { listConverted.setParent(result); } result.getRow().add(listConverted); } return result; }  }
RelationPropertyConverter { public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (InformationItem iitem : wb.getColumn()) { final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem); if (iitemConverted != null) { iitemConverted.setParent(result); } result.getColumn().add(iitemConverted); } for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) { final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer); if (listConverted != null) { listConverted.setParent(result); } result.getRow().add(listConverted); } return result; }  static Relation wbFromDMN(final org.kie.dmn.model.api.Relation dmn,
                                     final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb,
                                                           final Consumer<ComponentWidths> componentWidthsConsumer); }
RelationPropertyConverter { public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (InformationItem iitem : wb.getColumn()) { final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem); if (iitemConverted != null) { iitemConverted.setParent(result); } result.getColumn().add(iitemConverted); } for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) { final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer); if (listConverted != null) { listConverted.setParent(result); } result.getRow().add(listConverted); } return result; }  static Relation wbFromDMN(final org.kie.dmn.model.api.Relation dmn,
                                     final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb,
                                                           final Consumer<ComponentWidths> componentWidthsConsumer);  }