@Test public void testDMNFromWB() { final List wb = 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); wb.getId().setValue(LIST_UUID); wb.getDescription().setValue(LIST_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, LIST_QNAME_LOCALPART)); wb.getExpression().add(hasExpression); final org.kie.dmn.model.api.List dmn = ListPropertyConverter.dmnFromWB(wb, componentWidthsConsumer); assertThat(dmn).isNotNull(); assertThat(dmn.getId()).isNotNull(); assertThat(dmn.getId()).isEqualTo(LIST_UUID); assertThat(dmn.getDescription()).isNotNull(); assertThat(dmn.getDescription()).isEqualTo(LIST_DESCRIPTION); assertThat(dmn.getTypeRef()).isNotNull(); assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(LIST_QNAME_LOCALPART); assertThat(dmn.getExpression()).isNotNull(); assertThat(dmn.getExpression().size()).isEqualTo(1); assertThat(dmn.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.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (HasExpression hasExpression : wb.getExpression()) { final Expression e = hasExpression.getExpression(); final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer); if (Objects.nonNull(eConverted)) { eConverted.setParent(result); } result.getExpression().add(eConverted); } return result; }
ListPropertyConverter { public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (HasExpression hasExpression : wb.getExpression()) { final Expression e = hasExpression.getExpression(); final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer); if (Objects.nonNull(eConverted)) { eConverted.setParent(result); } result.getExpression().add(eConverted); } return result; } }
ListPropertyConverter { public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (HasExpression hasExpression : wb.getExpression()) { final Expression e = hasExpression.getExpression(); final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer); if (Objects.nonNull(eConverted)) { eConverted.setParent(result); } result.getExpression().add(eConverted); } return result; }  }
ListPropertyConverter { public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (HasExpression hasExpression : wb.getExpression()) { final Expression e = hasExpression.getExpression(); final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer); if (Objects.nonNull(eConverted)) { eConverted.setParent(result); } result.getExpression().add(eConverted); } return result; }  static List wbFromDMN(final org.kie.dmn.model.api.List dmn,
                                 final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); static org.kie.dmn.model.api.List dmnFromWB(final List wb,
                                                       final Consumer<ComponentWidths> componentWidthsConsumer); }
ListPropertyConverter { public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) { final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList(); result.setId(wb.getId().getValue()); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef); for (HasExpression hasExpression : wb.getExpression()) { final Expression e = hasExpression.getExpression(); final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer); if (Objects.nonNull(eConverted)) { eConverted.setParent(result); } result.getExpression().add(eConverted); } return result; }  static List wbFromDMN(final org.kie.dmn.model.api.List dmn,
                                 final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer); static org.kie.dmn.model.api.List dmnFromWB(final List wb,
                                                       final Consumer<ComponentWidths> componentWidthsConsumer);  }