@Test public void testHeterogeneousList() { List<String> ids = Arrays.asList("Just Cause", "Armaggedon", "Awareness", "Chaos Mastery", "Life Mastery", "Death and Decay", "Node Mastery", "Artificer", "Warlord", "Conjurer"); Set<String> sca = new HashSet<String>(); List<String> successes = new ArrayList<String>(); for (String id : ids) { if (Math.random() > 0.33) { sca.add(this.vth.generateStaffCohort("Sky Drake", id, false, true).getEntityId()); } else if (Math.random() > 0.5) { String id2 = this.vth.generateStaffCohort(USER_ID, id, false, true).getEntityId(); sca.add(id2); successes.add(id2); } else { sca.add("Earth Elemental"); } } Assert.assertFalse(val.validate(EntityNames.STAFF_COHORT_ASSOCIATION, sca).equals(sca)); for (String id : sca) { Set<String> single = Collections.singleton(id); if (successes.contains(id)) { Assert.assertTrue(val.validate(EntityNames.STAFF_COHORT_ASSOCIATION, single).equals(single)); } else { Assert.assertFalse(val.validate(EntityNames.STAFF_COHORT_ASSOCIATION, single).equals(single)); } } }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_COHORT_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); nq.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<String> result = getRepo().findAllIds(EntityNames.STAFF_COHORT_ASSOCIATION, nq); return Sets.newHashSet(result); }
TeacherToStaffCohortAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_COHORT_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); nq.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<String> result = getRepo().findAllIds(EntityNames.STAFF_COHORT_ASSOCIATION, nq); return Sets.newHashSet(result); } }
TeacherToStaffCohortAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_COHORT_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); nq.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<String> result = getRepo().findAllIds(EntityNames.STAFF_COHORT_ASSOCIATION, nq); return Sets.newHashSet(result); }  }
TeacherToStaffCohortAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_COHORT_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); nq.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<String> result = getRepo().findAllIds(EntityNames.STAFF_COHORT_ASSOCIATION, nq); return Sets.newHashSet(result); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
TeacherToStaffCohortAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.STAFF_COHORT_ASSOCIATION, entityType, ids)) { return Collections.EMPTY_SET; } NeutralQuery nq = new NeutralQuery(new NeutralCriteria(ParameterConstants.STAFF_ID, NeutralCriteria.OPERATOR_EQUAL, SecurityUtil.getSLIPrincipal().getEntity().getEntityId())); nq.addCriteria(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids)); Iterable<String> result = getRepo().findAllIds(EntityNames.STAFF_COHORT_ASSOCIATION, nq); return Sets.newHashSet(result); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }