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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations