use of org.kie.workbench.common.dmn.api.definition.model.InformationItem 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);
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem 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.InformationItem in project kie-wb-common by kiegroup.
the class RelationGrid method doAfterHeaderSelectionChange.
@Override
public void doAfterHeaderSelectionChange(final int uiHeaderRowIndex, final int uiHeaderColumnIndex) {
if (getExpression().get().isPresent()) {
final Relation relation = getExpression().get().get();
final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, uiHeaderColumnIndex);
if (section == RelationUIModelMapperHelper.RelationSection.INFORMATION_ITEM) {
final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, uiHeaderColumnIndex);
final InformationItem domainObject = relation.getColumn().get(iiIndex);
fireDomainObjectSelectionEvent(domainObject);
return;
}
}
super.doAfterHeaderSelectionChange(uiHeaderRowIndex, uiHeaderColumnIndex);
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem 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.InformationItem 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