@Test public void testCreateChangeParentCommands() { final Node node = mock(Node.class); final SafeDeleteNodeCommand.SafeDeleteNodeCommandCallback callback = mock(SafeDeleteNodeCommand.SafeDeleteNodeCommandCallback.class); final Element<?> canvas = mock(Element.class); final Node canvasNode = mock(Node.class); final Node<?, Edge> candidate = mock(Node.class); final List<Edge> outEdges = new ArrayList<>(); final Edge e1 = mock(Edge.class); final Child child = mock(Child.class); final Node targetNode = mock(Node.class); when(node.getUUID()).thenReturn("uuid"); when(canvas.asNode()).thenReturn(canvasNode); when(e1.getContent()).thenReturn(child); when(e1.getTargetNode()).thenReturn(targetNode); when(candidate.getOutEdges()).thenReturn(outEdges); outEdges.add(e1); final SafeDeleteNodeCommand command = new SafeDeleteNodeCommand(node, callback, SafeDeleteNodeCommand.Options.defaults()); command.createChangeParentCommands(canvas, candidate); verify(callback).moveChildToCanvasRoot(canvasNode, targetNode); }
void createChangeParentCommands(final Element<?> canvas, final Node<?, Edge> candidate) { final List<Node> childNodes = GraphUtils.getChildNodes(candidate); for (final Node n : childNodes) { safeDeleteCallback.ifPresent(c -> c.moveChildToCanvasRoot(canvas.asNode(), n)); } }
SafeDeleteNodeCommand extends AbstractGraphCompositeCommand { void createChangeParentCommands(final Element<?> canvas, final Node<?, Edge> candidate) { final List<Node> childNodes = GraphUtils.getChildNodes(candidate); for (final Node n : childNodes) { safeDeleteCallback.ifPresent(c -> c.moveChildToCanvasRoot(canvas.asNode(), n)); } } }
SafeDeleteNodeCommand extends AbstractGraphCompositeCommand { void createChangeParentCommands(final Element<?> canvas, final Node<?, Edge> candidate) { final List<Node> childNodes = GraphUtils.getChildNodes(candidate); for (final Node n : childNodes) { safeDeleteCallback.ifPresent(c -> c.moveChildToCanvasRoot(canvas.asNode(), n)); } } SafeDeleteNodeCommand(final @MapsTo("candidateUUID") String candidateUUID,
                                 final @MapsTo("options") Options options);  SafeDeleteNodeCommand(final Node<?, Edge> node);  SafeDeleteNodeCommand(final Node<?, Edge> node,
                                 final Options options);  SafeDeleteNodeCommand(final Node<?, Edge> node,
                                 final SafeDeleteNodeCommandCallback safeDeleteCallback,
                                 final Options options); }
SafeDeleteNodeCommand extends AbstractGraphCompositeCommand { void createChangeParentCommands(final Element<?> canvas, final Node<?, Edge> candidate) { final List<Node> childNodes = GraphUtils.getChildNodes(candidate); for (final Node n : childNodes) { safeDeleteCallback.ifPresent(c -> c.moveChildToCanvasRoot(canvas.asNode(), n)); } } SafeDeleteNodeCommand(final @MapsTo("candidateUUID") String candidateUUID,
                                 final @MapsTo("options") Options options);  SafeDeleteNodeCommand(final Node<?, Edge> node);  SafeDeleteNodeCommand(final Node<?, Edge> node,
                                 final Options options);  SafeDeleteNodeCommand(final Node<?, Edge> node,
                                 final SafeDeleteNodeCommandCallback safeDeleteCallback,
                                 final Options options); Optional<SafeDeleteNodeCommandCallback> getSafeDeleteCallback(); boolean shouldKeepChildren(final Node<Definition<?>, Edge> candidate); GraphsProvider getGraphsProvider(); Node<?, Edge> getNode(); Options getOptions(); @Override String toString(); }
SafeDeleteNodeCommand extends AbstractGraphCompositeCommand { void createChangeParentCommands(final Element<?> canvas, final Node<?, Edge> candidate) { final List<Node> childNodes = GraphUtils.getChildNodes(candidate); for (final Node n : childNodes) { safeDeleteCallback.ifPresent(c -> c.moveChildToCanvasRoot(canvas.asNode(), n)); } } SafeDeleteNodeCommand(final @MapsTo("candidateUUID") String candidateUUID,
                                 final @MapsTo("options") Options options);  SafeDeleteNodeCommand(final Node<?, Edge> node);  SafeDeleteNodeCommand(final Node<?, Edge> node,
                                 final Options options);  SafeDeleteNodeCommand(final Node<?, Edge> node,
                                 final SafeDeleteNodeCommandCallback safeDeleteCallback,
                                 final Options options); Optional<SafeDeleteNodeCommandCallback> getSafeDeleteCallback(); boolean shouldKeepChildren(final Node<Definition<?>, Edge> candidate); GraphsProvider getGraphsProvider(); Node<?, Edge> getNode(); Options getOptions(); @Override String toString();  }