From cc05dbd8aee198060e3c8f5381ff9eaacb7da53c Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Tue, 12 Nov 2024 21:00:59 -0700 Subject: [PATCH] GRAD2-2973 - Adding test cases --- .../controller/v2/SchoolControllerIntegrationTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/controller/v2/SchoolControllerIntegrationTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/controller/v2/SchoolControllerIntegrationTest.java index 6ed2ff0d..7dc5f5a6 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/trax/controller/v2/SchoolControllerIntegrationTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/trax/controller/v2/SchoolControllerIntegrationTest.java @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; @@ -39,8 +40,8 @@ class SchoolControllerIntegrationTest { @Autowired private MockMvc mockMvc; - @Autowired - private SchoolService schoolService; + @MockBean + private SchoolService schoolServiceMock; @Autowired private SchoolRedisRepository schoolRedisRepository; @@ -159,7 +160,7 @@ void testReloadSchoolsIntoCache_shouldReturnOK() throws Exception { @Test void testReloadSchoolsIntoCache_shouldReturnUnprocessableEntity() throws Exception { - doThrow(Exception.class).when(schoolService).initializeSchoolCache(true); + doThrow(Exception.class).when(schoolServiceMock).initializeSchoolCache(true); mockMvc.perform(MockMvcRequestBuilders.put("/api/v2/trax/school/cache/schools") .with(jwt().jwt(jwt -> jwt.claim("scope", "UPDATE_GRAD_TRAX_CACHE"))) .accept(MediaType.APPLICATION_JSON)) @@ -176,7 +177,7 @@ void testReloadSchoolDetailssIntoCache_shouldReturnOK() throws Exception { @Test void testReloadSchoolDetailsIntoCache_shouldReturnUnprocessableEntity() throws Exception { - doThrow(Exception.class).when(schoolService).initializeSchoolDetailCache(true); + doThrow(Exception.class).when(schoolServiceMock).initializeSchoolDetailCache(true); mockMvc.perform(MockMvcRequestBuilders.put("/api/v2/trax/school/cache/school-details") .with(jwt().jwt(jwt -> jwt.claim("scope", "UPDATE_GRAD_TRAX_CACHE"))) .accept(MediaType.APPLICATION_JSON))