@Test public void testDifferentEdOrgs() { Entity courseTranscript = buildCourseTranscript(); Entity studentAcademicRecord = buildStudentAcademicRecord(); studentAcademicRecord.getBody().put(STUDENT_ID, "student2"); when(repo.findById(EntityNames.STUDENT_ACADEMIC_RECORD, "studentacademicrecord1")).thenReturn(studentAcademicRecord); when(studentResolver.findGoverningEdOrgs("student1", courseTranscript)).thenReturn(new HashSet<String>(Arrays.asList("edOrg1"))); when(studentResolver.findGoverningEdOrgs("student2", courseTranscript)).thenReturn(new HashSet<String>(Arrays.asList("edOrg2"))); assertEquals(new HashSet<String>(Arrays.asList("edOrg1", "edOrg2")), underTest.findGoverningEdOrgs(courseTranscript)); }
@Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); if (entity == null) { return edOrgs; } String studentId = (String) entity.getBody().get(STUDENT_ID); if (studentId != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs(studentId, entity)); } String studentAcademicRecordId = (String) entity.getBody().get(STUDENT_ACADEMIC_RECORD_ID); if (studentAcademicRecordId != null) { Entity studentAcademicRecord = repo.findById(EntityNames.STUDENT_ACADEMIC_RECORD, studentAcademicRecordId); if (studentAcademicRecord != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs((String) studentAcademicRecord.getBody().get(STUDENT_ID), entity)); } } return edOrgs; }
CourseTranscriptContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); if (entity == null) { return edOrgs; } String studentId = (String) entity.getBody().get(STUDENT_ID); if (studentId != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs(studentId, entity)); } String studentAcademicRecordId = (String) entity.getBody().get(STUDENT_ACADEMIC_RECORD_ID); if (studentAcademicRecordId != null) { Entity studentAcademicRecord = repo.findById(EntityNames.STUDENT_ACADEMIC_RECORD, studentAcademicRecordId); if (studentAcademicRecord != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs((String) studentAcademicRecord.getBody().get(STUDENT_ID), entity)); } } return edOrgs; } }
CourseTranscriptContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); if (entity == null) { return edOrgs; } String studentId = (String) entity.getBody().get(STUDENT_ID); if (studentId != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs(studentId, entity)); } String studentAcademicRecordId = (String) entity.getBody().get(STUDENT_ACADEMIC_RECORD_ID); if (studentAcademicRecordId != null) { Entity studentAcademicRecord = repo.findById(EntityNames.STUDENT_ACADEMIC_RECORD, studentAcademicRecordId); if (studentAcademicRecord != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs((String) studentAcademicRecord.getBody().get(STUDENT_ID), entity)); } } return edOrgs; }  }
CourseTranscriptContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); if (entity == null) { return edOrgs; } String studentId = (String) entity.getBody().get(STUDENT_ID); if (studentId != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs(studentId, entity)); } String studentAcademicRecordId = (String) entity.getBody().get(STUDENT_ACADEMIC_RECORD_ID); if (studentAcademicRecordId != null) { Entity studentAcademicRecord = repo.findById(EntityNames.STUDENT_ACADEMIC_RECORD, studentAcademicRecordId); if (studentAcademicRecord != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs((String) studentAcademicRecord.getBody().get(STUDENT_ID), entity)); } } return edOrgs; }  @Override Set<String> findGoverningEdOrgs(Entity entity); }
CourseTranscriptContextResolver implements ContextResolver { @Override public Set<String> findGoverningEdOrgs(Entity entity) { Set<String> edOrgs = new HashSet<String>(); if (entity == null) { return edOrgs; } String studentId = (String) entity.getBody().get(STUDENT_ID); if (studentId != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs(studentId, entity)); } String studentAcademicRecordId = (String) entity.getBody().get(STUDENT_ACADEMIC_RECORD_ID); if (studentAcademicRecordId != null) { Entity studentAcademicRecord = repo.findById(EntityNames.STUDENT_ACADEMIC_RECORD, studentAcademicRecordId); if (studentAcademicRecord != null) { edOrgs.addAll(studentResolver.findGoverningEdOrgs((String) studentAcademicRecord.getBody().get(STUDENT_ID), entity)); } } return edOrgs; }  @Override Set<String> findGoverningEdOrgs(Entity entity); static final String ED_ORG_REFERENCE; static final String STUDENT_ACADEMIC_RECORD_ID; static final String STUDENT_ID; }