@Test @SuppressWarnings("unchecked") public void testExecute() { CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); assertEquals(CommandResult.Type.INFO, result.getType()); assertTrue(parentInEdges.isEmpty()); assertTrue(candidateOutEdges.isEmpty()); verify(graphIndex, times(1)).removeEdge(any(Edge.class)); 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); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getInEdges().remove(edge); candidate.getOutEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; }
RemoveParentCommand 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); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getInEdges().remove(edge); candidate.getOutEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; } }
RemoveParentCommand 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); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getInEdges().remove(edge); candidate.getOutEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; } RemoveParentCommand(final @MapsTo("parentUUID") String parentUUID,
                               final @MapsTo("candidateUUID") String candidateUUID);  RemoveParentCommand(final Node<?, Edge> parent,
                               final Node<?, Edge> candidate); }
RemoveParentCommand 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); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getInEdges().remove(edge); candidate.getOutEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; } RemoveParentCommand(final @MapsTo("parentUUID") String parentUUID,
                               final @MapsTo("candidateUUID") String candidateUUID);  RemoveParentCommand(final Node<?, Edge> parent,
                               final Node<?, Edge> candidate); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); @Override String toString(); }
RemoveParentCommand 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); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getInEdges().remove(edge); candidate.getOutEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; } RemoveParentCommand(final @MapsTo("parentUUID") String parentUUID,
                               final @MapsTo("candidateUUID") String candidateUUID);  RemoveParentCommand(final Node<?, Edge> parent,
                               final Node<?, Edge> candidate); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); @Override String toString();  }