### Question:
GlobalEntityValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> entityIds) throws IllegalStateException { Set<String> result = new HashSet<String>(); if(areParametersValid(GLOBAL_WRITE_RESOURCE, entityType, entityIds)) { result = entityIds; } return result; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> entityIds); @Override SecurityUtil.UserContext getContext();  }### Answer:
@Test public void testValidateSingleAssessment() throws Exception { HashSet<String> assessmentIds = new HashSet<String>(); assessmentIds.add(helper.generateAssessment().getEntityId()); assertTrue(validator.validate(EntityNames.ASSESSMENT, assessmentIds).containsAll(assessmentIds)); }
@Test public void testValidateMultipleAssessments() throws Exception { HashSet<String> assessmentIds = new HashSet<String>(); assessmentIds.add(helper.generateAssessment().getEntityId()); assessmentIds.add(helper.generateAssessment().getEntityId()); assessmentIds.add(helper.generateAssessment().getEntityId()); assertTrue(validator.validate(EntityNames.ASSESSMENT, assessmentIds).containsAll(assessmentIds)); }
@Test public void testValidateSingleLearningObjective() throws Exception { HashSet<String> learningObjectiveIds = new HashSet<String>(); learningObjectiveIds.add(helper.generateLearningObjective().getEntityId()); assertTrue(validator.validate(EntityNames.LEARNING_OBJECTIVE, learningObjectiveIds).containsAll(learningObjectiveIds)); }
@Test public void testValidateMultipleLearningObjectives() throws Exception { HashSet<String> learningObjectiveIds = new HashSet<String>(); learningObjectiveIds.add(helper.generateLearningObjective().getEntityId()); learningObjectiveIds.add(helper.generateLearningObjective().getEntityId()); learningObjectiveIds.add(helper.generateLearningObjective().getEntityId()); assertTrue(validator.validate(EntityNames.LEARNING_OBJECTIVE, learningObjectiveIds).containsAll(learningObjectiveIds)); }
@Test public void testValidateSingleLearningStandard() throws Exception { HashSet<String> learningStandardIds = new HashSet<String>(); learningStandardIds.add(helper.generateLearningStandard().getEntityId()); assertTrue(validator.validate(EntityNames.LEARNING_STANDARD, learningStandardIds).containsAll(learningStandardIds)); }
@Test public void testValidateMultipleLearningStandards() throws Exception { HashSet<String> learningStandardIds = new HashSet<String>(); learningStandardIds.add(helper.generateLearningStandard().getEntityId()); learningStandardIds.add(helper.generateLearningStandard().getEntityId()); learningStandardIds.add(helper.generateLearningStandard().getEntityId()); assertTrue(validator.validate(EntityNames.LEARNING_STANDARD, learningStandardIds).containsAll(learningStandardIds)); }
@Test public void testValidateSingleCompetencyLevelDescriptor() throws Exception { HashSet<String> competencyLevelDescriptorIds = new HashSet<String>(); competencyLevelDescriptorIds.add(helper.generateCompetencyLevelDescriptor().getEntityId()); assertTrue(validator.validate(EntityNames.COMPETENCY_LEVEL_DESCRIPTOR, competencyLevelDescriptorIds).containsAll(competencyLevelDescriptorIds)); }
@Test public void testValidateMultipleCompetencyLevelDescriptors() throws Exception { HashSet<String> competencyLevelDescriptorIds = new HashSet<String>(); competencyLevelDescriptorIds.add(helper.generateCompetencyLevelDescriptor().getEntityId()); competencyLevelDescriptorIds.add(helper.generateCompetencyLevelDescriptor().getEntityId()); competencyLevelDescriptorIds.add(helper.generateCompetencyLevelDescriptor().getEntityId()); assertTrue(validator.validate(EntityNames.COMPETENCY_LEVEL_DESCRIPTOR, competencyLevelDescriptorIds).containsAll(competencyLevelDescriptorIds)); }
@Test(expected = IllegalArgumentException.class) public void testGuards() throws Exception { validator.validate(EntityNames.STUDENT, new HashSet<String>(Arrays.asList("student1", "student2"))); }