@Test public void testCanNotGetAccessToGradeDueToGradeLookup() throws Exception { Set<String> grades = new HashSet<String>(); Map<String, Object> association = buildStudentSectionAssociation("student123", "section123", DateTime.now() .minusDays(3)); Entity studentSectionAssociation = new MongoEntity(EntityNames.STUDENT_SECTION_ASSOCIATION, association); ; Entity gradeEntity = helper.generateGrade(studentSectionAssociation.getEntityId()); grades.add(gradeEntity.getEntityId()); Mockito.when(mockRepo.findAll(Mockito.eq(EntityNames.GRADE), Mockito.any(NeutralQuery.class))).thenReturn( new ArrayList<Entity>()); assertFalse(validator.validate(EntityNames.GRADE, grades).equals(grades)); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); } }
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }  }
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
StaffToSubStudentSectionAssociationEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(SUB_ENTITIES_OF_STUDENT_SECTION, entityType, ids)) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentSectionAssociationIds = getIdsContainedInFieldOnEntities(entityType, new ArrayList<String>( ids), ParameterConstants.STUDENT_SECTION_ASSOCIATION_ID); if (studentSectionAssociationIds.isEmpty()) { return Collections.EMPTY_SET; } Map<String, Set<String>> studentIds = getIdsContainedInFieldOnEntities(EntityNames.STUDENT_SECTION_ASSOCIATION, new ArrayList<String>(studentSectionAssociationIds.keySet()), ParameterConstants.STUDENT_ID); if (studentIds.isEmpty()) { return Collections.EMPTY_SET; } Set<String> validStudents = validator.validate(EntityNames.STUDENT, studentIds.keySet()); Set<String> validSSA = getValidIds(validStudents, studentIds); return getValidIds(validSSA, studentSectionAssociationIds); }  @Override boolean canValidate(String entityType, boolean through); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }