use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ContextEntryPropertyConverterTest method testDMNFromWBWithNullWBExpression.
@Test
public void testDMNFromWBWithNullWBExpression() {
final ContextEntry wb = new ContextEntry();
final InformationItem informationItem = new InformationItem();
wb.setVariable(informationItem);
wb.setExpression(null);
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()).isInstanceOf(org.kie.dmn.model.api.LiteralExpression.class);
final org.kie.dmn.model.api.LiteralExpression literalExpression = (org.kie.dmn.model.api.LiteralExpression) dmn.getExpression();
assertThat(literalExpression.getText()).isEqualTo(ContextEntry.DEFAULT_EXPRESSION_VALUE);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationEditorDefinition method enrich.
@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Relation> expression) {
expression.ifPresent(relation -> {
final InformationItem column = new InformationItem();
column.getName().setValue(RelationDefaultValueUtilities.getNewColumnName(relation));
final org.kie.workbench.common.dmn.api.definition.model.List row = new org.kie.workbench.common.dmn.api.definition.model.List();
final LiteralExpression literalExpression = new LiteralExpression();
row.getExpression().add(HasExpression.wrap(relation, literalExpression));
relation.getColumn().add(column);
relation.getRow().add(row);
// Setup parent relationships
column.setParent(relation);
row.setParent(relation);
literalExpression.setParent(row);
});
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ContextPropertyConverterTest method testDMNFromWBWithDefault.
@Test
public void testDMNFromWBWithDefault() {
final LiteralExpression defaultExpression = new LiteralExpression();
defaultExpression.getId().setValue(DEFAULT_EXPRESSION_UUID);
defaultExpression.getComponentWidths().set(0, 100.0);
final Context wb = setupDMNFromWB(Optional.of(defaultExpression));
final org.kie.dmn.model.api.Context dmn = ContextPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getContextEntry()).isNotNull();
assertThat(dmn.getContextEntry().size()).isEqualTo(2);
assertThat(dmn.getContextEntry().get(0)).isNotNull();
assertThat(dmn.getContextEntry().get(0).getExpression().getId()).isEqualTo(EXPRESSION_UUID);
assertThat(dmn.getContextEntry().get(1)).isNotNull();
assertThat(dmn.getContextEntry().get(1).getExpression().getId()).isEqualTo(DEFAULT_EXPRESSION_UUID);
verify(componentWidthsConsumer, times(2)).accept(componentWidthsCaptor.capture());
final List<ComponentWidths> componentWidths = componentWidthsCaptor.getAllValues();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.size()).isEqualTo(2);
assertThat(componentWidths.get(0).getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.get(0).getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.get(0).getWidths().get(0)).isEqualTo(200.0);
assertThat(componentWidths.get(1).getDmnElementRef().getLocalPart()).isEqualTo(DEFAULT_EXPRESSION_UUID);
assertThat(componentWidths.get(1).getWidths().size()).isEqualTo(defaultExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.get(1).getWidths().get(0)).isEqualTo(100.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ListPropertyConverterTest method testDMNFromWB.
@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);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationPropertyConverterTest method testDMNFromWB.
@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);
}
Aggregations