Skip to content

Commit

Permalink
GRAD2-2949 - Adding test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamal-mohammed committed Nov 19, 2024
1 parent d4ef69b commit b548fd2
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.when;

@RunWith(SpringRunner.class)
Expand Down Expand Up @@ -166,4 +168,29 @@ public SchoolDetail mockInstituteData(UUID schoolId, String minCode, String dist
return schoolDetail;
}

@Test
public void testGetSchoolForClobDataBySchoolIdFromRedisCache_shouldReturnSchool() {
UUID schoolId = UUID.randomUUID();
String schoolIdString = schoolId.toString();
SchoolDetail schoolDetail = new SchoolDetail();
schoolDetail.setSchoolId(schoolIdString);
schoolDetail.setMincode("12345");
schoolDetail.setDisplayName("My School");
ca.bc.gov.educ.api.trax.model.dto.School expected = new ca.bc.gov.educ.api.trax.model.dto.School();
expected.setSchoolId(schoolIdString);
expected.setMinCode("12345");
expected.setSchoolName("My School");
when(schoolService.getSchoolDetailBySchoolId(schoolId)).thenReturn(schoolDetail);
ca.bc.gov.educ.api.trax.model.dto.School actual = commonService.getSchoolForClobDataBySchoolIdFromRedisCache(schoolId);
assertEquals(expected, actual);
}

@Test
public void testGetSchoolForClobDataBySchoolIdFromRedisCache_shouldReturnNull() {
UUID schoolId = UUID.randomUUID();
when(schoolService.getSchoolDetailBySchoolId(schoolId)).thenReturn(null);
ca.bc.gov.educ.api.trax.model.dto.School actual = commonService.getSchoolForClobDataBySchoolIdFromRedisCache(schoolId);
assertNull(actual);
}

}

0 comments on commit b548fd2

Please sign in to comment.