Search in sources :

Example 21 with NodeImpl

use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testBuildToolboxForDecisionType.

@Test
@SuppressWarnings("unchecked")
public void testBuildToolboxForDecisionType() {
    final Node<View<Decision>, Edge> decisionNode = new NodeImpl<>("decisionNode1");
    final Decision decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    final Optional<Toolbox<?>> _toolbox = tested.build(canvasHandler, decisionNode);
    assertTrue(_toolbox.isPresent());
    Toolbox<?> toolbox = _toolbox.get();
    assertTrue(toolbox instanceof ActionsToolbox);
    final ActionsToolbox actionsToolbox = (ActionsToolbox) toolbox;
    assertEquals("decisionNode1", actionsToolbox.getElementUUID());
    assertEquals(2, actionsToolbox.size());
    final Iterator<ToolboxAction> actionsIt = actionsToolbox.iterator();
    assertEquals(deleteNodeAction, actionsIt.next());
    assertEquals(editDecisionToolboxAction, actionsIt.next());
    assertFalse(actionsIt.hasNext());
    verify(view, times(1)).init(eq(actionsToolbox));
    verify(view, times(2)).addButton(any(Glyph.class), anyString(), any(Consumer.class));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ActionsToolboxView(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolboxView) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Consumer(java.util.function.Consumer) ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Toolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.Toolbox) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 22 with NodeImpl

use of org.kie.workbench.common.stunner.core.graph.impl.NodeImpl in project kie-wb-common by kiegroup.

the class AcyclicDirectedGraphWalkerTest method checkSimpleWalk.

@Test
@SuppressWarnings("unchecked")
public void checkSimpleWalk() {
    final Node node1 = new NodeImpl<>("node1");
    final Node node2 = new NodeImpl<>("node2");
    final Node node3 = new NodeImpl<>("node3");
    final Edge c1 = new EdgeImpl<>("edge1:node1-node2");
    final Edge c2 = new EdgeImpl<>("edge2:node2-node3");
    // Connect node1 and node2 with c1
    connectNodes(node1, node2, c1);
    graph.addNode(node1);
    graph.addNode(node2);
    // Propose to connect node2 to node3 with c2
    walker = new AcyclicDirectedGraphWalker(node2, node3, c2);
    walker.traverse(graph, callback);
    verify(callback).startGraphTraversal(eq(graph));
    verify(callback).endGraphTraversal();
    verify(callback, atLeast(1)).startNodeTraversal(nodeStartVisitCaptor.capture());
    verify(callback, atLeast(1)).endNodeTraversal(nodeEndVisitCaptor.capture());
    verify(callback, atLeast(1)).startEdgeTraversal(edgeStartVisitCaptor.capture());
    verify(callback, atLeast(1)).endEdgeTraversal(edgeEndVisitCaptor.capture());
    assertEquals(3, nodeStartVisitCaptor.getAllValues().size());
    assertEquals(3, nodeEndVisitCaptor.getAllValues().size());
    assertNodeVisits(nodeStartVisitCaptor.getAllValues(), "node1", "node2", "node3");
    assertNodeVisits(nodeEndVisitCaptor.getAllValues(), "node1", "node2", "node3");
    assertEquals(2, edgeStartVisitCaptor.getAllValues().size());
    assertEquals(2, edgeEndVisitCaptor.getAllValues().size());
    assertEdgeVisits(edgeStartVisitCaptor.getAllValues(), "edge1:node1-node2", "edge2:node2-node3");
    assertEdgeVisits(edgeEndVisitCaptor.getAllValues(), "edge1:node1-node2", "edge2:node2-node3");
}
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) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Aggregations

NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)22 Test (org.junit.Test)18 Edge (org.kie.workbench.common.stunner.core.graph.Edge)9 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)7 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)7 Node (org.kie.workbench.common.stunner.core.graph.Node)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)4 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)4 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)4 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)4 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 RuleViolations (org.kie.workbench.common.stunner.core.rule.RuleViolations)3 Consumer (java.util.function.Consumer)2 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 ExclusiveGateway (org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway)2 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)2