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