### Question:
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; }### Answer:
@Test public void returnEmptySetIfNoStudent() { Entity courseTranscript = buildCourseTranscript(); courseTranscript.getBody().remove(STUDENT_ID); courseTranscript.getBody().remove(STUDENT_ACADEMIC_RECORD_ID); assertEquals(Collections.emptySet(), underTest.findGoverningEdOrgs(courseTranscript)); }
@Test public void followStudentId() { Entity courseTranscript = buildCourseTranscript(); when(studentResolver.findGoverningEdOrgs("student1", courseTranscript)).thenReturn(new HashSet<String>(Arrays.asList("toplea2"))); assertEquals(new HashSet<String>(Arrays.asList("toplea2")), underTest.findGoverningEdOrgs(courseTranscript)); }
@Test public void noStudentIdFollowAcademicRecord() { Entity courseTranscript = buildCourseTranscript(); courseTranscript.getBody().remove(STUDENT_ID); when(studentResolver.findGoverningEdOrgs("student1", courseTranscript)).thenReturn(new HashSet<String>(Arrays.asList("toplea2"))); assertEquals(new HashSet<String>(Arrays.asList("toplea2")), underTest.findGoverningEdOrgs(courseTranscript)); }
@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)); }