@Test @SuppressWarnings("unchecked") public void testNotAllowed() { 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.allow(graphCommandExecutionContext); assertEquals(CommandResult.Type.ERROR, result.getType()); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context) { ensureInitialized(context); final Element<? extends Definition<?>> parent = (Element<? extends Definition<?>>) getParent(context); final Collection<RuleViolation> containmentRuleViolations = evaluate(context, contextBuilder -> contextBuilder.containment(parent, candidate)); final Collection<RuleViolation> cardinalityRuleViolations = evaluate(context, contextBuilder -> contextBuilder.cardinality(Collections.singleton(candidate), CardinalityContext.Operation.ADD)); final Collection<RuleViolation> violations = new LinkedList<RuleViolation>(); violations.addAll(containmentRuleViolations); violations.addAll(cardinalityRuleViolations); return new GraphCommandResultBuilder(violations).build(); }
AddChildNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context) { ensureInitialized(context); final Element<? extends Definition<?>> parent = (Element<? extends Definition<?>>) getParent(context); final Collection<RuleViolation> containmentRuleViolations = evaluate(context, contextBuilder -> contextBuilder.containment(parent, candidate)); final Collection<RuleViolation> cardinalityRuleViolations = evaluate(context, contextBuilder -> contextBuilder.cardinality(Collections.singleton(candidate), CardinalityContext.Operation.ADD)); final Collection<RuleViolation> violations = new LinkedList<RuleViolation>(); violations.addAll(containmentRuleViolations); violations.addAll(cardinalityRuleViolations); return new GraphCommandResultBuilder(violations).build(); } }
AddChildNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context) { ensureInitialized(context); final Element<? extends Definition<?>> parent = (Element<? extends Definition<?>>) getParent(context); final Collection<RuleViolation> containmentRuleViolations = evaluate(context, contextBuilder -> contextBuilder.containment(parent, candidate)); final Collection<RuleViolation> cardinalityRuleViolations = evaluate(context, contextBuilder -> contextBuilder.cardinality(Collections.singleton(candidate), CardinalityContext.Operation.ADD)); final Collection<RuleViolation> violations = new LinkedList<RuleViolation>(); violations.addAll(containmentRuleViolations); violations.addAll(cardinalityRuleViolations); return new GraphCommandResultBuilder(violations).build(); } AddChildNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                               final @MapsTo("candidate") Node candidate,
                               final @MapsTo("location") Point2D location);  AddChildNodeCommand(final Node<?, Edge> parent,
                               final Node candidate,
                               final Point2D location);  AddChildNodeCommand(final Node<?, Edge> parent,
                               final Node candidate); }
AddChildNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context) { ensureInitialized(context); final Element<? extends Definition<?>> parent = (Element<? extends Definition<?>>) getParent(context); final Collection<RuleViolation> containmentRuleViolations = evaluate(context, contextBuilder -> contextBuilder.containment(parent, candidate)); final Collection<RuleViolation> cardinalityRuleViolations = evaluate(context, contextBuilder -> contextBuilder.cardinality(Collections.singleton(candidate), CardinalityContext.Operation.ADD)); final Collection<RuleViolation> violations = new LinkedList<RuleViolation>(); violations.addAll(containmentRuleViolations); violations.addAll(cardinalityRuleViolations); return new GraphCommandResultBuilder(violations).build(); } AddChildNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                               final @MapsTo("candidate") Node candidate,
                               final @MapsTo("location") Point2D location);  AddChildNodeCommand(final Node<?, Edge> parent,
                               final Node candidate,
                               final Point2D location);  AddChildNodeCommand(final Node<?, Edge> parent,
                               final Node candidate); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); Node<?, Edge> getParent(); Node getCandidate(); Point2D getLocation(); @Override String toString(); }
AddChildNodeCommand extends AbstractGraphCompositeCommand { @Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context) { ensureInitialized(context); final Element<? extends Definition<?>> parent = (Element<? extends Definition<?>>) getParent(context); final Collection<RuleViolation> containmentRuleViolations = evaluate(context, contextBuilder -> contextBuilder.containment(parent, candidate)); final Collection<RuleViolation> cardinalityRuleViolations = evaluate(context, contextBuilder -> contextBuilder.cardinality(Collections.singleton(candidate), CardinalityContext.Operation.ADD)); final Collection<RuleViolation> violations = new LinkedList<RuleViolation>(); violations.addAll(containmentRuleViolations); violations.addAll(cardinalityRuleViolations); return new GraphCommandResultBuilder(violations).build(); } AddChildNodeCommand(final @MapsTo("parentUUID") String parentUUID,
                               final @MapsTo("candidate") Node candidate,
                               final @MapsTo("location") Point2D location);  AddChildNodeCommand(final Node<?, Edge> parent,
                               final Node candidate,
                               final Point2D location);  AddChildNodeCommand(final Node<?, Edge> parent,
                               final Node candidate); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> allow(final GraphCommandExecutionContext context); @Override @SuppressWarnings("unchecked") CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context); Node<?, Edge> getParent(); Node getCandidate(); Point2D getLocation(); @Override String toString();  }