@Test public void testEvaluateFailed() { final Set<String> candidateRoles = new HashSet<String>(1) {{ add("role4"); }}; when(context.getParentRoles()).thenReturn(PARENT_ROLES); when(context.getCandidateRoles()).thenReturn(candidateRoles); final RuleViolations violations = tested.evaluate(RULE, context); assertNotNull(violations); assertTrue(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext()); }
@Override public RuleViolations evaluate(final CanContain rule, final ContainmentContext 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 ContainmentRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }
ContainmentEvaluationHandler implements RuleEvaluationHandler<CanContain, ContainmentContext> { @Override public RuleViolations evaluate(final CanContain rule, final ContainmentContext 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 ContainmentRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; } }
ContainmentEvaluationHandler implements RuleEvaluationHandler<CanContain, ContainmentContext> { @Override public RuleViolations evaluate(final CanContain rule, final ContainmentContext 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 ContainmentRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }  }
ContainmentEvaluationHandler implements RuleEvaluationHandler<CanContain, ContainmentContext> { @Override public RuleViolations evaluate(final CanContain rule, final ContainmentContext 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 ContainmentRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }  @Override Class<CanContain> getRuleType(); @Override Class<ContainmentContext> getContextType(); @Override boolean accepts(final CanContain rule,
                           final ContainmentContext context); @Override RuleViolations evaluate(final CanContain rule,
                                   final ContainmentContext context); }
ContainmentEvaluationHandler implements RuleEvaluationHandler<CanContain, ContainmentContext> { @Override public RuleViolations evaluate(final CanContain rule, final ContainmentContext 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 ContainmentRuleViolation(rule.getRole(), context.getCandidateRoles().toString())); } return results; }  @Override Class<CanContain> getRuleType(); @Override Class<ContainmentContext> getContextType(); @Override boolean accepts(final CanContain rule,
                           final ContainmentContext context); @Override RuleViolations evaluate(final CanContain rule,
                                   final ContainmentContext context);  }