use of org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final FunctionDefinition wb = new FunctionDefinition();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.getId().setValue(FUNCTION_DEFINITION_UUID);
wb.getDescription().setValue(FUNCTION_DEFINITION_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, FUNCTION_DEFINITION_QNAME_LOCALPART));
wb.setKind(FunctionDefinition.Kind.JAVA);
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.FunctionDefinition dmn = FunctionDefinitionPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(FUNCTION_DEFINITION_UUID);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(FUNCTION_DEFINITION_DESCRIPTION);
assertThat(dmn.getTypeRef()).isNotNull();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(FUNCTION_DEFINITION_QNAME_LOCALPART);
assertThat(dmn.getKind()).isNotNull();
assertThat(dmn.getKind()).isEqualTo(FunctionKind.JAVA);
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().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);
}
use of org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths in project kie-wb-common by kiegroup.
the class InvocationPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final Invocation wb = new Invocation();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.getId().setValue(INVOCATION_UUID);
wb.getDescription().setValue(INVOCATION_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, INVOCATION_QNAME_LOCALPART));
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.Invocation dmn = InvocationPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(INVOCATION_UUID);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(INVOCATION_DESCRIPTION);
assertThat(dmn.getTypeRef()).isNotNull();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().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);
}
use of org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths in project kie-wb-common by kiegroup.
the class ContextEntryPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final ContextEntry wb = new ContextEntry();
final InformationItem informationItem = new InformationItem();
wb.setVariable(informationItem);
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.ContextEntry dmn = ContextEntryPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getVariable()).isNotNull();
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().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);
}
use of org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverterTest method assertDMNFromWBConversion.
private void assertDMNFromWBConversion(final Expression wb, final Class dmnClass, final double... expectedComponentWidths) {
final org.kie.dmn.model.api.Expression dmn = ExpressionPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isInstanceOf(dmnClass);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
final List<Double> widths = componentWidths.getWidths();
assertThat(widths.size()).isEqualTo(wb.getRequiredComponentWidthCount());
assertThat(widths.size()).isEqualTo(expectedComponentWidths.length);
IntStream.range(0, expectedComponentWidths.length).forEach(i -> assertThat(widths.get(i)).isEqualTo(expectedComponentWidths[i]));
}
use of org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths in project kie-wb-common by kiegroup.
the class BindingPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final Binding wb = new Binding();
final InformationItem informationItem = new InformationItem();
wb.setParameter(informationItem);
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.Binding dmn = BindingPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getParameter()).isNotNull();
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().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);
}
Aggregations