Search in sources :

Example 11 with TLiteralExpression

use of org.kie.dmn.model.v1_1.TLiteralExpression in project kie-wb-common by kiegroup.

the class DecisionConverterTest method testWBFromDMN.

@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
    final Node<View<Decision>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
    final View<Decision> view = new ViewImpl<>(new Decision(), Bounds.create());
    factoryNode.setContent(view);
    when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(Decision.class)))).thenReturn(element);
    when(element.asNode()).thenReturn(factoryNode);
    final org.kie.dmn.model.api.Decision dmn = new TDecision();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setId(DECISION_UUID);
    dmn.setName(DECISION_NAME);
    dmn.setDescription(DECISION_DESCRIPTION);
    dmn.setVariable(informationItem);
    dmn.setExpression(literalExpression);
    final Node<View<Decision>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
    final Decision wb = (Decision) DefinitionUtils.getElementDefinition(node);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(DECISION_UUID);
    assertThat(wb.getName()).isNotNull();
    assertThat(wb.getName().getValue()).isEqualTo(DECISION_NAME);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_DESCRIPTION);
    assertThat(wb.getVariable()).isNotNull();
    assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_NAME);
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) TDecision(org.kie.dmn.model.v1_2.TDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) TDecision(org.kie.dmn.model.v1_2.TDecision) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Test(org.junit.Test)

Example 12 with TLiteralExpression

use of org.kie.dmn.model.v1_1.TLiteralExpression in project kie-wb-common by kiegroup.

the class ListPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.List dmn = new TList();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setId(LIST_UUID);
    dmn.setDescription(LIST_DESCRIPTION);
    dmn.setTypeRef(new QName(LIST_QNAME_LOCALPART));
    dmn.getExpression().add(literalExpression);
    final List wb = ListPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(LIST_UUID);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(LIST_DESCRIPTION);
    assertThat(wb.getTypeRef()).isNotNull();
    assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(LIST_QNAME_LOCALPART);
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().size()).isEqualTo(1);
    assertThat(wb.getExpression().get(0).getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression().get(0).getExpression());
}
Also used : TList(org.kie.dmn.model.v1_2.TList) QName(javax.xml.namespace.QName) List(org.kie.workbench.common.dmn.api.definition.model.List) TList(org.kie.dmn.model.v1_2.TList) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Test(org.junit.Test)

Example 13 with TLiteralExpression

use of org.kie.dmn.model.v1_1.TLiteralExpression in project kie-wb-common by kiegroup.

the class RelationPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.Relation dmn = new TRelation();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    final org.kie.dmn.model.api.List list = new TList();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    list.getExpression().add(literalExpression);
    dmn.setId(RELATION_UUID);
    dmn.setDescription(RELATION_DESCRIPTION);
    dmn.setTypeRef(new QName(RELATION_QNAME_LOCALPART));
    dmn.getColumn().add(informationItem);
    dmn.getRow().add(list);
    final Relation wb = RelationPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(RELATION_UUID);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(RELATION_DESCRIPTION);
    assertThat(wb.getTypeRef()).isNotNull();
    assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(RELATION_QNAME_LOCALPART);
    assertThat(wb.getColumn()).isNotNull();
    assertThat(wb.getColumn().size()).isEqualTo(1);
    assertThat(wb.getColumn().get(0)).isNotNull();
    assertThat(wb.getRow()).isNotNull();
    assertThat(wb.getRow().size()).isEqualTo(1);
    assertThat(wb.getRow().get(0)).isNotNull();
    assertThat(wb.getRow().get(0).getExpression()).isNotNull();
    assertThat(wb.getRow().get(0).getExpression().size()).isEqualTo(1);
    assertThat(wb.getRow().get(0).getExpression().get(0).getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getRow().get(0).getExpression().get(0).getExpression());
}
Also used : QName(javax.xml.namespace.QName) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) TList(org.kie.dmn.model.v1_2.TList) TRelation(org.kie.dmn.model.v1_2.TRelation) TRelation(org.kie.dmn.model.v1_2.TRelation) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Test(org.junit.Test)

Aggregations

TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)13 Test (org.junit.Test)10 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)8 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)7 QName (javax.xml.namespace.QName)6 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)4 TFunctionDefinition (org.kie.dmn.model.v1_2.TFunctionDefinition)3 UnaryTests (org.kie.dmn.model.api.UnaryTests)2 TContextEntry (org.kie.dmn.model.v1_2.TContextEntry)2 TDecision (org.kie.dmn.model.v1_2.TDecision)2 TList (org.kie.dmn.model.v1_2.TList)2 TUnaryTests (org.kie.dmn.model.v1_2.TUnaryTests)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)2 View (org.kie.workbench.common.stunner.core.graph.content.view.View)2 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)2 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)2 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)1 Decision (org.kie.dmn.model.api.Decision)1 DecisionTable (org.kie.dmn.model.api.DecisionTable)1 ImportedValues (org.kie.dmn.model.api.ImportedValues)1