@Test public void testMoveChildToCanvasRoot() { final DeleteNodeCommand.CanvasDeleteProcessor processor = mock(DeleteNodeCommand.CanvasDeleteProcessor.class); final Node node = mock(Node.class); final Element elementCanvas = mock(Element.class); final Node canvasNode = mock(Node.class); final Element parentElement = mock(Element.class); final Node nodeParent = mock(Node.class); final Point2D newPosition = new Point2D(1, 2); final CompositeCommand command = mock(CompositeCommand.class); when(elementCanvas.asNode()).thenReturn(canvasNode); doCallRealMethod().when(processor).moveChildToCanvasRoot(elementCanvas, node); when(parentElement.asNode()).thenReturn(nodeParent); when(processor.getParent(node)).thenReturn(parentElement); when(processor.getCommand()).thenReturn(command); when(processor.getChildPosition(node, parentElement)).thenReturn(newPosition); processor.moveChildToCanvasRoot(elementCanvas, node); verify(command, times(3)).addCommand(commandsCaptor.capture()); final List<AbstractCanvasGraphCommand> values = commandsCaptor.getAllValues(); final AbstractCanvasGraphCommand removeChildrenCmd = values.get(0); final AbstractCanvasGraphCommand setChildrenCmd = values.get(1); final AbstractCanvasGraphCommand updatePosition = values.get(2); assertTrue(removeChildrenCmd instanceof RemoveChildrenCommand); assertTrue(setChildrenCmd instanceof SetChildrenCommand); assertTrue(updatePosition instanceof UpdateElementPositionCommand); assertEquals(nodeParent, ((RemoveChildrenCommand) removeChildrenCmd).getParent()); assertEquals(canvasNode, ((SetChildrenCommand) setChildrenCmd).getParent()); assertEquals(node, ((UpdateElementPositionCommand) updatePosition).getElement()); assertEquals(node, getNode(((RemoveChildrenCommand) removeChildrenCmd).getChildren())); assertEquals(node, getNode(((SetChildrenCommand) setChildrenCmd).getCandidates())); assertEquals(newPosition, ((UpdateElementPositionCommand) updatePosition).getLocation()); }
CompositeCommand<AbstractCanvasHandler, CanvasViolation> getCommand() { return deleteProcessor.getCommand(); }
DeleteNodeCommand extends AbstractCanvasGraphCommand { CompositeCommand<AbstractCanvasHandler, CanvasViolation> getCommand() { return deleteProcessor.getCommand(); } }
DeleteNodeCommand extends AbstractCanvasGraphCommand { CompositeCommand<AbstractCanvasHandler, CanvasViolation> getCommand() { return deleteProcessor.getCommand(); } DeleteNodeCommand(final Node candidate);  DeleteNodeCommand(final Node candidate,
                             final SafeDeleteNodeCommand.Options options); @SuppressWarnings("unchecked")  DeleteNodeCommand(final Node candidate,
                             final SafeDeleteNodeCommand.Options options,
                             final CanvasDeleteProcessor deleteProcessor); }
DeleteNodeCommand extends AbstractCanvasGraphCommand { CompositeCommand<AbstractCanvasHandler, CanvasViolation> getCommand() { return deleteProcessor.getCommand(); } DeleteNodeCommand(final Node candidate);  DeleteNodeCommand(final Node candidate,
                             final SafeDeleteNodeCommand.Options options); @SuppressWarnings("unchecked")  DeleteNodeCommand(final Node candidate,
                             final SafeDeleteNodeCommand.Options options,
                             final CanvasDeleteProcessor deleteProcessor); Node getCandidate(); SafeDeleteNodeCommand.Options getOptions(); @Override String toString(); CanvasDeleteProcessor getDeleteProcessor(); }
DeleteNodeCommand extends AbstractCanvasGraphCommand { CompositeCommand<AbstractCanvasHandler, CanvasViolation> getCommand() { return deleteProcessor.getCommand(); } DeleteNodeCommand(final Node candidate);  DeleteNodeCommand(final Node candidate,
                             final SafeDeleteNodeCommand.Options options); @SuppressWarnings("unchecked")  DeleteNodeCommand(final Node candidate,
                             final SafeDeleteNodeCommand.Options options,
                             final CanvasDeleteProcessor deleteProcessor); Node getCandidate(); SafeDeleteNodeCommand.Options getOptions(); @Override String toString(); CanvasDeleteProcessor getDeleteProcessor();  }