Skip to content

Commit

Permalink
GRAD2-2973 - Adding test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kamal-mohammed committed Nov 13, 2024
1 parent cc05dbd commit ad49285
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand All @@ -40,8 +39,8 @@ class SchoolControllerIntegrationTest {

@Autowired
private MockMvc mockMvc;
@MockBean
private SchoolService schoolServiceMock;
@Autowired
private SchoolService schoolService;

@Autowired
private SchoolRedisRepository schoolRedisRepository;
Expand Down Expand Up @@ -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")))
Expand All @@ -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")))
Expand Down

0 comments on commit ad49285

Please sign in to comment.