### Question:
SafeDeleteNodeCommand extends AbstractGraphCompositeCommand { public Node<?, Edge> getNode() { return node; } 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();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testDeleteStartNode() { this.tested = new SafeDeleteNodeCommand(graphHolder.startNode); final CommandResult<RuleViolation> result = tested.allow(graphTestHandler.graphCommandExecutionContext); final List<Command<GraphCommandExecutionContext, RuleViolation>> commands = tested.getCommands(); assertNotNull(commands); assertTrue(3 == commands.size()); final DeleteConnectorCommand delete1 = (DeleteConnectorCommand) commands.get(0); assertNotNull(delete1); assertEquals(graphHolder.edge1, delete1.getEdge()); final RemoveChildrenCommand removeChild = (RemoveChildrenCommand) commands.get(1); assertNotNull(removeChild); assertEquals(graphHolder.parentNode, removeChild.getParent()); assertEquals(graphHolder.startNode, removeChild.getCandidates().iterator().next()); final DeregisterNodeCommand deleteNode = (DeregisterNodeCommand) commands.get(2); assertNotNull(deleteNode); assertEquals(graphHolder.startNode, deleteNode.getNode()); assertEquals(CommandResult.Type.INFO, result.getType()); }
@Test @SuppressWarnings("unchecked") public void testDeleteEndNode() { this.tested = new SafeDeleteNodeCommand(graphHolder.endNode); final CommandResult<RuleViolation> result = tested.allow(graphTestHandler.graphCommandExecutionContext); final List<Command<GraphCommandExecutionContext, RuleViolation>> commands = tested.getCommands(); assertNotNull(commands); assertTrue(3 == commands.size()); final DeleteConnectorCommand delete2 = (DeleteConnectorCommand) commands.get(0); assertNotNull(delete2); assertEquals(graphHolder.edge2, delete2.getEdge()); final RemoveChildrenCommand removeChild = (RemoveChildrenCommand) commands.get(1); assertNotNull(removeChild); assertEquals(graphHolder.parentNode, removeChild.getParent()); assertEquals(graphHolder.endNode, removeChild.getCandidates().iterator().next()); final DeregisterNodeCommand deleteNode = (DeregisterNodeCommand) commands.get(2); assertNotNull(deleteNode); assertEquals(graphHolder.endNode, deleteNode.getNode()); assertEquals(CommandResult.Type.INFO, result.getType()); }
@Test @SuppressWarnings("unchecked") public void testDeleteIntermediateNode() { this.tested = new SafeDeleteNodeCommand(graphHolder.intermNode); final CommandResult<RuleViolation> result = tested.allow(graphTestHandler.graphCommandExecutionContext); final List<Command<GraphCommandExecutionContext, RuleViolation>> commands = tested.getCommands(); assertNotNull(commands); assertTrue(4 == commands.size()); final DeleteConnectorCommand delete2 = (DeleteConnectorCommand) commands.get(0); assertNotNull(delete2); assertEquals(graphHolder.edge2, delete2.getEdge()); final SetConnectionTargetNodeCommand setConnectionNewTarget = (SetConnectionTargetNodeCommand) commands.get(1); assertNotNull(setConnectionNewTarget); assertEquals(graphHolder.edge1, setConnectionNewTarget.getEdge()); assertEquals(graphHolder.startNode, setConnectionNewTarget.getSourceNode()); assertEquals(graphHolder.endNode, setConnectionNewTarget.getTargetNode()); final RemoveChildrenCommand removeChild = (RemoveChildrenCommand) commands.get(2); assertNotNull(removeChild); assertEquals(graphHolder.parentNode, removeChild.getParent()); assertEquals(graphHolder.intermNode, removeChild.getCandidates().iterator().next()); final DeregisterNodeCommand deleteNode = (DeregisterNodeCommand) commands.get(3); assertNotNull(deleteNode); assertEquals(graphHolder.intermNode, deleteNode.getNode()); assertEquals(CommandResult.Type.INFO, result.getType()); }