### Question:
StaffToTeacherSectionAssociationValidator extends AbstractContextValidator { @Override public boolean canValidate(String entityType, boolean isTransitive) { return isStaff() && EntityNames.TEACHER_SECTION_ASSOCIATION.equals(entityType); }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }### Answer:
@Test public void testCanValidateStaffToTeacherSectionAssociation() throws Exception { setContext(seaStaff, Arrays.asList(SecureRoleRightAccessImpl.SEA_ADMINISTRATOR)); assertTrue(validator.canValidate(EntityNames.TEACHER_SECTION_ASSOCIATION, false)); assertTrue(validator.canValidate(EntityNames.TEACHER_SECTION_ASSOCIATION, true)); }
@Test public void testDeniedStaffToOtherEntities() throws Exception { setContext(seaStaff, Arrays.asList(SecureRoleRightAccessImpl.SEA_ADMINISTRATOR)); assertFalse(validator.canValidate(EntityNames.STUDENT, true)); assertFalse(validator.canValidate(EntityNames.STUDENT, false)); assertFalse(validator.canValidate(EntityNames.TEACHER, true)); assertFalse(validator.canValidate(EntityNames.TEACHER, false)); }
@Test public void testCanNotValidateAsNonStaffToTeacherSectionAssociation() throws Exception { setContext(educator, Arrays.asList(SecureRoleRightAccessImpl.EDUCATOR)); SecurityUtil.setUserContext(SecurityUtil.UserContext.TEACHER_CONTEXT); assertFalse(validator.canValidate(EntityNames.TEACHER_SECTION_ASSOCIATION, false)); assertFalse(validator.canValidate(EntityNames.TEACHER_SECTION_ASSOCIATION, true)); }