@Test public void testEvaluateSuccess() { final Set<String> candidateRoles = new HashSet<String>(1) {{ add("drole2"); }}; when(context.getParentRoles()).thenReturn(PARENT_ROLES); when(context.getCandidateRoles()).thenReturn(candidateRoles); final RuleViolations violations = tested.evaluate(RULE, context); assertNotNull(violations); assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext()); }
@Override public RuleViolations evaluate(final CanDock rule, final DockingContext context) { final DefaultRuleViolations results = new DefaultRuleViolations(); final boolean present = context.getCandidateRoles() .stream() .filter(cr -> rule.getAllowedRoles().contains(cr)) .findAny() .isPresent(); if (!present) { results.addViolation(new DockingRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }
DockingEvaluationHandler implements RuleEvaluationHandler<CanDock, DockingContext> { @Override public RuleViolations evaluate(final CanDock rule, final DockingContext context) { final DefaultRuleViolations results = new DefaultRuleViolations(); final boolean present = context.getCandidateRoles() .stream() .filter(cr -> rule.getAllowedRoles().contains(cr)) .findAny() .isPresent(); if (!present) { results.addViolation(new DockingRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; } }
DockingEvaluationHandler implements RuleEvaluationHandler<CanDock, DockingContext> { @Override public RuleViolations evaluate(final CanDock rule, final DockingContext context) { final DefaultRuleViolations results = new DefaultRuleViolations(); final boolean present = context.getCandidateRoles() .stream() .filter(cr -> rule.getAllowedRoles().contains(cr)) .findAny() .isPresent(); if (!present) { results.addViolation(new DockingRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }  }
DockingEvaluationHandler implements RuleEvaluationHandler<CanDock, DockingContext> { @Override public RuleViolations evaluate(final CanDock rule, final DockingContext context) { final DefaultRuleViolations results = new DefaultRuleViolations(); final boolean present = context.getCandidateRoles() .stream() .filter(cr -> rule.getAllowedRoles().contains(cr)) .findAny() .isPresent(); if (!present) { results.addViolation(new DockingRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }  @Override Class<CanDock> getRuleType(); @Override Class<DockingContext> getContextType(); @Override boolean accepts(final CanDock rule,
                           final DockingContext context); @Override RuleViolations evaluate(final CanDock rule,
                                   final DockingContext context); }
DockingEvaluationHandler implements RuleEvaluationHandler<CanDock, DockingContext> { @Override public RuleViolations evaluate(final CanDock rule, final DockingContext context) { final DefaultRuleViolations results = new DefaultRuleViolations(); final boolean present = context.getCandidateRoles() .stream() .filter(cr -> rule.getAllowedRoles().contains(cr)) .findAny() .isPresent(); if (!present) { results.addViolation(new DockingRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }  @Override Class<CanDock> getRuleType(); @Override Class<DockingContext> getContextType(); @Override boolean accepts(final CanDock rule,
                           final DockingContext context); @Override RuleViolations evaluate(final CanDock rule,
                                   final DockingContext context);  }