From b548fd28005eec709a3db9c84bf0ee49ee8f6127 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Tue, 19 Nov 2024 12:26:59 -0700 Subject: [PATCH] GRAD2-2949 - Adding test case. --- .../service/institute/CommonServiceTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/CommonServiceTest.java index c02fe59d..e103dcb8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/institute/CommonServiceTest.java @@ -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) @@ -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); + } + }