Search in sources :

Example 6 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class InformationItemPrimaryPropertyConverterTest method testDmnFromWBWhenWBIsNotNull.

@Test
public void testDmnFromWBWhenWBIsNotNull() {
    final String expectedId = "id";
    final String expectedName = "name";
    final Id id = new Id(expectedId);
    final Name name = new Name(expectedName);
    final String qNameNamespaceURI = "qName namespaceURI";
    final String qNameLocalPart = "qName local part";
    final String qNamePrefix = "qName prefix";
    final InformationItemPrimary wb = mock(InformationItemPrimary.class);
    final QName qName = mock(QName.class);
    final javax.xml.namespace.QName expectedQName = new javax.xml.namespace.QName(qNameNamespaceURI, qNameLocalPart, qNamePrefix);
    final NamedElement parentElement = mock(NamedElement.class);
    when(wb.getId()).thenReturn(id);
    when(wb.getName()).thenReturn(name);
    when(wb.getTypeRef()).thenReturn(qName);
    when(wb.getParent()).thenReturn(parentElement);
    when(parentElement.getName()).thenReturn(name);
    when(qName.getNamespaceURI()).thenReturn(qNameNamespaceURI);
    when(qName.getLocalPart()).thenReturn(qNameLocalPart);
    when(qName.getPrefix()).thenReturn(qNamePrefix);
    final TInformationItem informationItem = InformationItemPrimaryPropertyConverter.dmnFromWB(wb, wb);
    final String actualId = informationItem.getId();
    final String actualName = informationItem.getName();
    final javax.xml.namespace.QName actualQName = informationItem.getTypeRef();
    assertEquals(expectedId, actualId);
    assertEquals(expectedName, actualName);
    assertEquals(expectedQName, actualQName);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 7 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class InformationItemPrimaryPropertyConverterTest method testWBGetNameWhenParentDoesNotHaveName.

@Test
public void testWBGetNameWhenParentDoesNotHaveName() {
    final InformationItemPrimary parent = mock(InformationItemPrimary.class);
    final String name = InformationItemPrimaryPropertyConverter.getParentName(parent);
    assertTrue(name.isEmpty());
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Test(org.junit.Test)

Example 8 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class InformationItemPrimaryPropertyConverterTest method testWbFromDMNWhenDMNIsNotNull.

@Test
public void testWbFromDMNWhenDMNIsNotNull() {
    final String id = "id";
    final Id expectedId = new Id(id);
    final String qNameNamespaceURI = "qName namespaceURI";
    final String qNameLocalPart = "qName local part";
    final String qNamePrefix = "qName prefix";
    final QName expectedTypeRef = new QName(qNameNamespaceURI, qNameLocalPart, qNamePrefix);
    final javax.xml.namespace.QName qName = mock(javax.xml.namespace.QName.class);
    final org.kie.dmn.model.api.InformationItem dmn = mock(org.kie.dmn.model.api.InformationItem.class);
    when(dmn.getId()).thenReturn(id);
    when(dmn.getTypeRef()).thenReturn(qName);
    when(qName.getNamespaceURI()).thenReturn(qNameNamespaceURI);
    when(qName.getLocalPart()).thenReturn(qNameLocalPart);
    when(qName.getPrefix()).thenReturn(qNamePrefix);
    final InformationItemPrimary informationItemPrimary = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn, dmn);
    final Id actualId = informationItemPrimary.getId();
    final QName actualTypeRef = informationItemPrimary.getTypeRef();
    assertEquals(expectedId, actualId);
    assertEquals(expectedTypeRef, actualTypeRef);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) InformationItem(org.kie.dmn.model.api.InformationItem) Test(org.junit.Test)

Example 9 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class InformationItemPrimaryPropertyConverterTest method testDmnFromWBWhenWBIsNull.

@Test
public void testDmnFromWBWhenWBIsNull() {
    final InformationItemPrimary wb = null;
    final InformationItem informationItem = InformationItemPrimaryPropertyConverter.dmnFromWB(wb, wb);
    assertNull(informationItem);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) InformationItem(org.kie.dmn.model.api.InformationItem) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Test(org.junit.Test)

Example 10 with InformationItemPrimary

use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.

the class DecisionConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    final Decision wb = new Decision();
    final LiteralExpression literalExpression = new LiteralExpression();
    final InformationItemPrimary informationItem = new InformationItemPrimary();
    literalExpression.getComponentWidths().set(0, 200.0);
    literalExpression.getId().setValue(EXPRESSION_UUID);
    wb.getId().setValue(DECISION_UUID);
    wb.getName().setValue(DECISION_NAME);
    wb.getDescription().setValue(DECISION_DESCRIPTION);
    wb.setVariable(informationItem);
    wb.setExpression(literalExpression);
    final Node<View<Decision>, ?> node = new NodeImpl<>(UUID.uuid());
    final View<Decision> view = new ViewImpl<>(wb, Bounds.create());
    node.setContent(view);
    final org.kie.dmn.model.api.Decision dmn = converter.dmnFromNode(node, componentWidthsConsumer);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getId()).isNotNull();
    assertThat(dmn.getId()).isEqualTo(DECISION_UUID);
    assertThat(dmn.getName()).isNotNull();
    assertThat(dmn.getName()).isEqualTo(DECISION_NAME);
    assertThat(dmn.getDescription()).isNotNull();
    assertThat(dmn.getDescription()).isEqualTo(DECISION_DESCRIPTION);
    assertThat(dmn.getVariable()).isNotNull();
    assertThat(dmn.getVariable().getName()).isEqualTo(DECISION_NAME);
    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);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TDecision(org.kie.dmn.model.v1_2.TDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) Test(org.junit.Test)

Aggregations

InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)39 Test (org.junit.Test)21 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)18 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)17 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)13 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)12 Node (org.kie.workbench.common.stunner.core.graph.Node)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)8 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)8 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)7 GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)6 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)5 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)5 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)5 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)5 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)4 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)4 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)4