### Question:
StudentToStudentParentAssociationValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { Set<String> validIds = new HashSet<String>(); if (!areParametersValid(EntityNames.STUDENT_PARENT_ASSOCIATION, entityType, ids)) { return Collections.emptySet(); } Entity entity = SecurityUtil.getSLIPrincipal().getEntity(); List<Entity> elist = entity.getEmbeddedData().get("studentParentAssociation"); if (elist != null ) { for (Entity e : elist) { validIds.add(e.getEntityId()); } } validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids);  }### Answer:
@Test public void testValidStudentParentAssociation() { Set<String> ids = new HashSet<String>(); for (Entity e : studentParentAssociationList) { String s = e.getEntityId(); ids.add(s); } boolean valid = validator.validate(EntityNames.STUDENT_PARENT_ASSOCIATION, ids).containsAll(ids); Assert.assertTrue(valid); }
@Test public void testOneInvalidStudentParentAssociation() { Set<String> ids = new HashSet<String>(); for (Entity e : studentParentAssociationList) { String s = e.getEntityId(); ids.add(s); } ids.add("invalidID"); boolean valid = validator.validate(EntityNames.STUDENT_PARENT_ASSOCIATION, ids).containsAll(ids); Assert.assertTrue(!valid); }
@Test public void testEmptyStudentParentAssociation() { Set<String> ids = new HashSet<String>(); ids.add("invalidID"); boolean valid = validator.validate(EntityNames.STUDENT_PARENT_ASSOCIATION, ids).containsAll(ids); Assert.assertTrue(!valid); }