Search in sources :

Example 31 with ViewImpl

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);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 32 with ViewImpl

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);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 33 with ViewImpl

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);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 34 with ViewImpl

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());
}
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 35 with ViewImpl

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);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TDecisionService(org.kie.dmn.model.v1_2.TDecisionService) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Aggregations

ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)54 Test (org.junit.Test)40 View (org.kie.workbench.common.stunner.core.graph.content.view.View)35 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)35 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)17 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Before (org.junit.Before)11 Node (org.kie.workbench.common.stunner.core.graph.Node)10 QName (javax.xml.namespace.QName)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)9 ReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess)9 TDecision (org.kie.dmn.model.v1_2.TDecision)7 BaseReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess)7 HashMap (java.util.HashMap)6 AdHocSubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)6 CallActivityPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CallActivityPropertyWriter)6 PropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter)6 SubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter)6 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)6