@Test @SuppressWarnings("unchecked") public void testExecute() { CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); assertEquals(CommandResult.Type.INFO, result.getType()); assertTrue(parentOutEdges.isEmpty()); assertTrue(candidateInEdges.isEmpty()); verify(graphIndex, times(1)).removeEdge(eq(edge)); verify(graphIndex, times(0)).removeNode(any(Node.class)); verify(graph, times(0)).addNode(any(Node.class)); verify(graphIndex, times(0)).addNode(any(Node.class)); verify(graphIndex, times(0)).addEdge(any(Edge.class)); }
@Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); parent.getOutEdges().stream() .filter(e -> e.getContent() instanceof Dock) .filter(e -> e.getTargetNode().equals(candidate)) .findFirst() .ifPresent(e -> removeDockEdge(context, parent, candidate, e)); } return results; }
UnDockNodeCommand extends AbstractGraphCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); parent.getOutEdges().stream() .filter(e -> e.getContent() instanceof Dock) .filter(e -> e.getTargetNode().equals(candidate)) .findFirst() .ifPresent(e -> removeDockEdge(context, parent, candidate, e)); } return results; } }
UnDockNodeCommand extends AbstractGraphCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); parent.getOutEdges().stream() .filter(e -> e.getContent() instanceof Dock) .filter(e -> e.getTargetNode().equals(candidate)) .findFirst() .ifPresent(e -> removeDockEdge(context, parent, candidate, e)); } return results; } UnDockNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                             final @MapsTo("candidateUUID") String candidateUUID);  UnDockNodeCommand(final Node<?, Edge> parent,
                             final Node<?, Edge> candidate); }
UnDockNodeCommand extends AbstractGraphCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); parent.getOutEdges().stream() .filter(e -> e.getContent() instanceof Dock) .filter(e -> e.getTargetNode().equals(candidate)) .findFirst() .ifPresent(e -> removeDockEdge(context, parent, candidate, e)); } return results; } UnDockNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                             final @MapsTo("candidateUUID") String candidateUUID);  UnDockNodeCommand(final Node<?, Edge> parent,
                             final Node<?, Edge> candidate); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); Node<?, Edge> getParent(); Node<?, Edge> getCandidate(); @Override String toString(); }
UnDockNodeCommand extends AbstractGraphCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); parent.getOutEdges().stream() .filter(e -> e.getContent() instanceof Dock) .filter(e -> e.getTargetNode().equals(candidate)) .findFirst() .ifPresent(e -> removeDockEdge(context, parent, candidate, e)); } return results; } UnDockNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                             final @MapsTo("candidateUUID") String candidateUUID);  UnDockNodeCommand(final Node<?, Edge> parent,
                             final Node<?, Edge> candidate); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); Node<?, Edge> getParent(); Node<?, Edge> getCandidate(); @Override String toString();  }