@Test @SuppressWarnings("unchecked") public void testEvaluate() { final Node source = mock(Node.class); final Node target = mock(Node.class); final View content = mock(View.class); final DynamicReadOnly dynamicReadonly = mock(DynamicReadOnly.class); when(dynamicReadonly.isAllowOnlyVisualChange()).thenReturn(true); when(content.getDefinition()).thenReturn(dynamicReadonly); when(target.getContent()).thenReturn(content); when(context.getSource()).thenReturn(Optional.of(source)); when(context.getTarget()).thenReturn(Optional.of(target)); final RuleViolations result = check.evaluate(rule, context); assertNotNull(result); final RuleViolation violation = result.violations().iterator().next(); assertNotNull(violation); assertTrue(violation.getArguments().isPresent()); assertEquals(1, violation.getArguments().get().length); assertEquals(NoInputNodesInImportedDecisionRule.ERROR_MESSAGE, violation.getArguments().get()[0]); }
@Override public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } if (isReadOnly(oTarget)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; }
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { @Override public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } if (isReadOnly(oTarget)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; } }
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { @Override public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } if (isReadOnly(oTarget)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; }  }
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { @Override public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } if (isReadOnly(oTarget)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; }  @Override Class<NoInputNodesInImportedDecisionRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
                           final GraphConnectionContext context); @Override RuleViolations evaluate(final RuleExtension rule,
                                   final GraphConnectionContext context); }
NoInputNodesInImportedDecisionRule extends RuleExtensionHandler<NoInputNodesInImportedDecisionRule, GraphConnectionContext> { @Override public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) { final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource(); final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget(); final DefaultRuleViolations result = new DefaultRuleViolations(); if (!(oSource.isPresent() && oTarget.isPresent())) { return result; } if (isReadOnly(oTarget)) { result.addViolation(new RuleViolationImpl(ERROR_MESSAGE)); } return result; }  @Override Class<NoInputNodesInImportedDecisionRule> getExtensionType(); @Override Class<GraphConnectionContext> getContextType(); @Override boolean accepts(final RuleExtension rule,
                           final GraphConnectionContext context); @Override RuleViolations evaluate(final RuleExtension rule,
                                   final GraphConnectionContext context);  }