@Test @SuppressWarnings("unchecked") public void testPrepareVisit() throws Exception { final Node root = new NodeImpl(UUID.randomUUID().toString()); final Node parent1 = new NodeImpl(UUID.randomUUID().toString()); final Node parent2 = new NodeImpl(UUID.randomUUID().toString()); final Node parent3 = new NodeImpl(UUID.randomUUID().toString()); final Node child1 = new NodeImpl(UUID.randomUUID().toString()); final Node child2 = new NodeImpl(UUID.randomUUID().toString()); final Node child3 = new NodeImpl(UUID.randomUUID().toString()); final Edge parentEdge1 = new EdgeImpl<>(UUID.randomUUID().toString()); final Edge parentEdge2 = new EdgeImpl<>(UUID.randomUUID().toString()); final Edge parentEdge3 = new EdgeImpl<>(UUID.randomUUID().toString()); final Edge childEdge1 = new EdgeImpl<>(UUID.randomUUID().toString()); final Edge childEdge2 = new EdgeImpl<>(UUID.randomUUID().toString()); final Edge childEdge3 = new EdgeImpl<>(UUID.randomUUID().toString()); parentEdge1.setSourceNode(root); parentEdge1.setTargetNode(parent1); parentEdge2.setSourceNode(root); parentEdge2.setTargetNode(parent2); parentEdge3.setSourceNode(root); parentEdge3.setTargetNode(parent3); childEdge1.setSourceNode(parent1); childEdge1.setTargetNode(child1); childEdge2.setSourceNode(parent2); childEdge2.setTargetNode(child2); childEdge3.setSourceNode(parent3); childEdge3.setTargetNode(child3); parentEdge1.setContent(new Child()); parentEdge2.setContent(new Child()); parentEdge3.setContent(new Child()); childEdge1.setContent(new Child()); childEdge2.setContent(new Child()); childEdge3.setContent(new Child()); root.getOutEdges().add(parentEdge1); root.getOutEdges().add(parentEdge2); root.getOutEdges().add(parentEdge3); parent1.getInEdges().add(parentEdge1); parent1.getOutEdges().add(childEdge1); parent2.getInEdges().add(parentEdge2); parent2.getOutEdges().add(childEdge2); parent3.getInEdges().add(parentEdge3); parent3.getOutEdges().add(childEdge3); child1.getInEdges().add(childEdge1); child2.getInEdges().add(childEdge2); child3.getInEdges().add(childEdge3); final Graph graph = new GraphImpl(UUID.randomUUID().toString(), new GraphNodeStoreImpl()); graph.addNode(root); graph.addNode(parent1); graph.addNode(parent2); graph.addNode(parent3); graph.addNode(child1); graph.addNode(child2); graph.addNode(child3); final Shape rootShape = mock(Shape.class); final Shape parentShape1 = mock(Shape.class); final Shape parentShape2 = mock(Shape.class); final Shape parentShape3 = mock(Shape.class); final Shape childShape1 = mock(Shape.class); final Shape childShape2 = mock(Shape.class); final Shape childShape3 = mock(Shape.class); final Canvas canvas = mock(Canvas.class); when(canvas.getShape(eq(root.getUUID()))).thenReturn(rootShape); when(canvas.getShape(eq(parent1.getUUID()))).thenReturn(parentShape1); when(canvas.getShape(eq(parent2.getUUID()))).thenReturn(parentShape2); when(canvas.getShape(eq(parent3.getUUID()))).thenReturn(parentShape3); when(canvas.getShape(eq(child1.getUUID()))).thenReturn(childShape1); when(canvas.getShape(eq(child2.getUUID()))).thenReturn(childShape2); when(canvas.getShape(eq(child3.getUUID()))).thenReturn(childShape3); final Diagram diagram = mock(Diagram.class); when(diagram.getGraph()).thenReturn(graph); final CanvasHandler handler = mock(CanvasHandler.class); when(handler.getDiagram()).thenReturn(diagram); when(handler.getCanvas()).thenReturn(canvas); final List<Shape> shapes = new LinkedList<>(); shapes.add(rootShape); shapes.add(parentShape1); shapes.add(childShape1); shapes.add(parentShape2); shapes.add(childShape2); shapes.add(parentShape3); shapes.add(childShape3); final CaseManagementCanvasHighlightVisitor visitor = new CaseManagementCanvasHighlightVisitor(); visitor.run(handler, () -> { }); assertThat(visitor.getShapes(), is(shapes)); }
@Override @SuppressWarnings("unchecked") protected void prepareVisit(Command command) { final Graph graph = canvasHandler.getDiagram().getGraph(); new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()) .traverse(graph, new ChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(List<Node<View, Edge>> parents, Node<View, Edge> node) { addShape(node.getUUID()); return true; } @Override public void startGraphTraversal(Graph<DefinitionSet, Node<View, Edge>> graph) { } @Override public void startEdgeTraversal(Edge<Child, Node> edge) { } @Override public void endEdgeTraversal(Edge<Child, Node> edge) { } @Override public void startNodeTraversal(Node<View, Edge> node) { addShape(node.getUUID()); } @Override public void endNodeTraversal(Node<View, Edge> node) { } @Override public void endGraphTraversal() { command.execute(); } private void addShape(final String uuid) { final Shape shape = canvasHandler.getCanvas().getShape(uuid); if (null != shape) { shapes.add(shape); } } }); }
CaseManagementCanvasHighlightVisitor extends CanvasHighlightVisitor { @Override @SuppressWarnings("unchecked") protected void prepareVisit(Command command) { final Graph graph = canvasHandler.getDiagram().getGraph(); new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()) .traverse(graph, new ChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(List<Node<View, Edge>> parents, Node<View, Edge> node) { addShape(node.getUUID()); return true; } @Override public void startGraphTraversal(Graph<DefinitionSet, Node<View, Edge>> graph) { } @Override public void startEdgeTraversal(Edge<Child, Node> edge) { } @Override public void endEdgeTraversal(Edge<Child, Node> edge) { } @Override public void startNodeTraversal(Node<View, Edge> node) { addShape(node.getUUID()); } @Override public void endNodeTraversal(Node<View, Edge> node) { } @Override public void endGraphTraversal() { command.execute(); } private void addShape(final String uuid) { final Shape shape = canvasHandler.getCanvas().getShape(uuid); if (null != shape) { shapes.add(shape); } } }); } }
CaseManagementCanvasHighlightVisitor extends CanvasHighlightVisitor { @Override @SuppressWarnings("unchecked") protected void prepareVisit(Command command) { final Graph graph = canvasHandler.getDiagram().getGraph(); new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()) .traverse(graph, new ChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(List<Node<View, Edge>> parents, Node<View, Edge> node) { addShape(node.getUUID()); return true; } @Override public void startGraphTraversal(Graph<DefinitionSet, Node<View, Edge>> graph) { } @Override public void startEdgeTraversal(Edge<Child, Node> edge) { } @Override public void endEdgeTraversal(Edge<Child, Node> edge) { } @Override public void startNodeTraversal(Node<View, Edge> node) { addShape(node.getUUID()); } @Override public void endNodeTraversal(Node<View, Edge> node) { } @Override public void endGraphTraversal() { command.execute(); } private void addShape(final String uuid) { final Shape shape = canvasHandler.getCanvas().getShape(uuid); if (null != shape) { shapes.add(shape); } } }); }  }
CaseManagementCanvasHighlightVisitor extends CanvasHighlightVisitor { @Override @SuppressWarnings("unchecked") protected void prepareVisit(Command command) { final Graph graph = canvasHandler.getDiagram().getGraph(); new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()) .traverse(graph, new ChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(List<Node<View, Edge>> parents, Node<View, Edge> node) { addShape(node.getUUID()); return true; } @Override public void startGraphTraversal(Graph<DefinitionSet, Node<View, Edge>> graph) { } @Override public void startEdgeTraversal(Edge<Child, Node> edge) { } @Override public void endEdgeTraversal(Edge<Child, Node> edge) { } @Override public void startNodeTraversal(Node<View, Edge> node) { addShape(node.getUUID()); } @Override public void endNodeTraversal(Node<View, Edge> node) { } @Override public void endGraphTraversal() { command.execute(); } private void addShape(final String uuid) { final Shape shape = canvasHandler.getCanvas().getShape(uuid); if (null != shape) { shapes.add(shape); } } }); }   }
CaseManagementCanvasHighlightVisitor extends CanvasHighlightVisitor { @Override @SuppressWarnings("unchecked") protected void prepareVisit(Command command) { final Graph graph = canvasHandler.getDiagram().getGraph(); new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()) .traverse(graph, new ChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(List<Node<View, Edge>> parents, Node<View, Edge> node) { addShape(node.getUUID()); return true; } @Override public void startGraphTraversal(Graph<DefinitionSet, Node<View, Edge>> graph) { } @Override public void startEdgeTraversal(Edge<Child, Node> edge) { } @Override public void endEdgeTraversal(Edge<Child, Node> edge) { } @Override public void startNodeTraversal(Node<View, Edge> node) { addShape(node.getUUID()); } @Override public void endNodeTraversal(Node<View, Edge> node) { } @Override public void endGraphTraversal() { command.execute(); } private void addShape(final String uuid) { final Shape shape = canvasHandler.getCanvas().getShape(uuid); if (null != shape) { shapes.add(shape); } } }); }    }