@Test @SuppressWarnings("unchecked") public void testExecuteCheckFailed() { final RuleViolations FAILED_VIOLATIONS = new DefaultRuleViolations() .addViolation(new ContainmentRuleViolation(graph.getUUID(), PARENT_UUID)); when(ruleManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(FAILED_VIOLATIONS); CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext); assertEquals(CommandResult.Type.ERROR, result.getType()); assertTrue(parent.getOutEdges().isEmpty()); assertTrue(candidate.getInEdges().isEmpty()); }
@Override @SuppressWarnings("unchecked") 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 String uuid = UUID.uuid(); final Edge<Parent, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Parent()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; }
SetParentNodeCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") 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 String uuid = UUID.uuid(); final Edge<Parent, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Parent()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; } }
SetParentNodeCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") 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 String uuid = UUID.uuid(); final Edge<Parent, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Parent()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; } SetParentNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                                final @MapsTo("candidateUUID") String candidateUUID);  SetParentNodeCommand(final Node<?, Edge> parent,
                                final Node<?, Edge> candidate); }
SetParentNodeCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") 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 String uuid = UUID.uuid(); final Edge<Parent, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Parent()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; } SetParentNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                                final @MapsTo("candidateUUID") String candidateUUID);  SetParentNodeCommand(final Node<?, Edge> parent,
                                final Node<?, Edge> candidate); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); @Override String toString(); }
SetParentNodeCommand extends AbstractGraphCommand { @Override @SuppressWarnings("unchecked") 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 String uuid = UUID.uuid(); final Edge<Parent, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Parent()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; } SetParentNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                                final @MapsTo("candidateUUID") String candidateUUID);  SetParentNodeCommand(final Node<?, Edge> parent,
                                final Node<?, Edge> candidate); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); @Override String toString();  }