use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToAbsoluteBoundsWhenChild.
@Test
public void testConvertToAbsoluteBoundsWhenChild() {
final Node<View, Edge> parent = new NodeImpl<>(UUID.uuid());
final View parentView = new ViewImpl<>(new Decision(), Bounds.create(100, 200, 1000, 2000));
parent.setContent(parentView);
final Node<View, Edge> child = new NodeImpl<>(UUID.uuid());
final View childView = new ViewImpl<>(new Decision(), Bounds.create(10, 20, 50, 60));
child.setContent(childView);
final Edge<Child, Node> edge = new EdgeImpl<>(UUID.uuid());
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
parent.getOutEdges().add(edge);
child.getInEdges().add(edge);
PointUtils.convertToAbsoluteBounds(child);
final Bound ulBound = child.getContent().getBounds().getUpperLeft();
final Bound lrBound = child.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(110);
assertThat(ulBound.getY()).isEqualTo(220);
assertThat(lrBound.getX()).isEqualTo(150);
assertThat(lrBound.getY()).isEqualTo(260);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToRelativeBoundsWhenNotChild.
@Test
public void testConvertToRelativeBoundsWhenNotChild() {
final Node<View, ?> node = new NodeImpl<>(UUID.uuid());
final View nodeView = new ViewImpl<>(new Decision(), Bounds.create(10, 20, 50, 60));
node.setContent(nodeView);
PointUtils.convertToRelativeBounds(node);
final Bound ulBound = node.getContent().getBounds().getUpperLeft();
final Bound lrBound = node.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(10);
assertThat(ulBound.getY()).isEqualTo(20);
assertThat(lrBound.getX()).isEqualTo(50);
assertThat(lrBound.getY()).isEqualTo(60);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToRelativeBoundsWhenChild.
@Test
public void testConvertToRelativeBoundsWhenChild() {
final Node<View, Edge> parent = new NodeImpl<>(UUID.uuid());
final View parentView = new ViewImpl<>(new Decision(), Bounds.create(100, 200, 1000, 2000));
parent.setContent(parentView);
final Node<View, Edge> child = new NodeImpl<>(UUID.uuid());
final View childView = new ViewImpl<>(new Decision(), Bounds.create(110, 220, 150, 260));
child.setContent(childView);
final Edge<Child, Node> edge = new EdgeImpl<>(UUID.uuid());
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
parent.getOutEdges().add(edge);
child.getInEdges().add(edge);
PointUtils.convertToRelativeBounds(child);
final Bound ulBound = child.getContent().getBounds().getUpperLeft();
final Bound lrBound = child.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(10);
assertThat(ulBound.getY()).isEqualTo(20);
assertThat(lrBound.getX()).isEqualTo(50);
assertThat(lrBound.getY()).isEqualTo(60);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl 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());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl in project kie-wb-common by kiegroup.
the class DecisionServiceConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final DecisionService wb = new DecisionService();
final InformationItemPrimary informationItem = new InformationItemPrimary();
wb.getId().setValue(DECISION_SERVICE_UUID);
wb.getName().setValue(DECISION_SERVICE_NAME);
wb.getDescription().setValue(DECISION_SERVICE_DESCRIPTION);
wb.setVariable(informationItem);
final Node<View<DecisionService>, ?> node = new NodeImpl<>(UUID.uuid());
final View<DecisionService> view = new ViewImpl<>(wb, Bounds.create());
node.setContent(view);
final org.kie.dmn.model.api.DecisionService dmn = converter.dmnFromNode(node, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(DECISION_SERVICE_UUID);
assertThat(dmn.getName()).isNotNull();
assertThat(dmn.getName()).isEqualTo(DECISION_SERVICE_NAME);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(DECISION_SERVICE_DESCRIPTION);
assertThat(dmn.getVariable()).isNotNull();
assertThat(dmn.getVariable().getName()).isEqualTo(DECISION_SERVICE_NAME);
verifyNoMoreInteractions(componentWidthsConsumer);
}
Aggregations