### Question:
GenericToGlobalClassPeriodWriteValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.CLASS_PERIOD, entityType, ids)) { return Collections.emptySet(); } Set<String> edOrgLineage = getEdorgDescendents(getDirectEdorgs()); NeutralQuery query = new NeutralQuery(new NeutralCriteria(ParameterConstants.ID, NeutralCriteria.CRITERIA_IN, ids, false)); query.addCriteria(new NeutralCriteria(ParameterConstants.EDUCATION_ORGANIZATION_ID, NeutralCriteria.CRITERIA_IN, edOrgLineage)); return Sets.newHashSet(getRepo().findAllIds(entityType, query)); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }### Answer:
@Test public void testFilterClassPeriodDataFromLEA() { setupStaff(staffLea, lea.getEntityId()); Set<String> expectedIds = new HashSet<String>(Arrays.asList(classPeriodLea.getEntityId(), classPeriodSchoolLea.getEntityId())); Set<String> actual = validator.validate(EntityNames.CLASS_PERIOD, classPeriodIds); Assert.assertEquals(expectedIds, actual); }
@Test public void testFilterClassPeriodDataFromSchool() { setupStaff(staffSchoolLea, schoolParentLea.getEntityId()); Set<String> expectedIds = new HashSet<String>(Arrays.asList(classPeriodSchoolLea.getEntityId())); Set<String> actual = validator.validate(EntityNames.CLASS_PERIOD, classPeriodIds); Assert.assertEquals(expectedIds, actual); }
@Test public void testFilterClassPeriodDataFromSchool2() { setupStaff(staffSchoolNoParent, schoolNoParent.getEntityId()); Set<String> expectedIds = new HashSet<String>(Arrays.asList(classPeriodSchoolNoParent.getEntityId())); Set<String> actual = validator.validate(EntityNames.CLASS_PERIOD, classPeriodIds); Assert.assertEquals(expectedIds, actual); }