Search in sources :

Example 1 with TRelation

use of org.kie.dmn.model.v1_1.TRelation 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

QName (javax.xml.namespace.QName)1 Test (org.junit.Test)1 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)1 TList (org.kie.dmn.model.v1_2.TList)1 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)1 TRelation (org.kie.dmn.model.v1_2.TRelation)1 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)1 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)1