From ad49285909cbdac2f4949b306dd8ca1e72542755 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Tue, 12 Nov 2024 22:09:05 -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 7dc5f5a6..a28c89bc 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 @@ -26,8 +26,7 @@ import java.util.UUID; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -40,8 +39,8 @@ class SchoolControllerIntegrationTest { @Autowired private MockMvc mockMvc; - @MockBean - private SchoolService schoolServiceMock; + @Autowired + private SchoolService schoolService; @Autowired private SchoolRedisRepository schoolRedisRepository; @@ -160,6 +159,7 @@ void testReloadSchoolsIntoCache_shouldReturnOK() throws Exception { @Test void testReloadSchoolsIntoCache_shouldReturnUnprocessableEntity() throws Exception { + SchoolService schoolServiceMock = mock(SchoolService.class); 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"))) @@ -177,6 +177,7 @@ void testReloadSchoolDetailssIntoCache_shouldReturnOK() throws Exception { @Test void testReloadSchoolDetailsIntoCache_shouldReturnUnprocessableEntity() throws Exception { + SchoolService schoolServiceMock = mock(SchoolService.class); 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")))