diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/controller/v2/CommonController.java b/api/src/main/java/ca/bc/gov/educ/api/trax/controller/v2/CommonController.java index 158a40cd..b0ada35a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/controller/v2/CommonController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/controller/v2/CommonController.java @@ -71,6 +71,19 @@ public ResponseEntity getSchoolForClobDataBySchoolId(@PathVariable UUID } } + @GetMapping(EducGradTraxApiConstants.GRAD_SCHOOL_CLOB_URL_MAPPING_V2 + EducGradTraxApiConstants.GET_SCHOOL_SEARCH_MAPPING) + @PreAuthorize(PermissionsConstants.READ_SCHOOL_DATA) + @Operation(summary = "Find a School Clob data by MinCode for GRAD Algorithm Data from cache", description = "Get a School Clob data by MinCode for GRAD Algorithm Data from cache", tags = { "Algorithm Data" }) + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "400", description = "BAD REQUEST"), + @ApiResponse(responseCode = "422", description = "UNPROCESSABLE CONTENT"), + @ApiResponse(responseCode = "204", description = "NO CONTENT")}) + public ResponseEntity getSchoolForClobDataByMinCode(@RequestParam(value = "mincode", required = false) String mincode) { + log.debug("getSchoolClobData by minCode: {}", mincode); + return response.GET(commonService.getSchoolForClobDataByMinCodeFromRedisCache(mincode)); + + } + @GetMapping(EducGradTraxApiConstants.GRAD_SCHOOLS_BY_DISTRICT_URL_MAPPING_V2 + EducGradTraxApiConstants.GET_DISTRICT_BY_DISTNO_MAPPING) @PreAuthorize(PermissionsConstants.READ_SCHOOL_DATA) @Operation(summary = "Find Schools Clob data by District Number for GRAD Algorithm Data from cache", description = "Get Schools Clob data by District Number for GRAD Algorithm Data from cache", tags = { "Algorithm Data" }) diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/controller/CommonControllerTest.java index 208fdae2..99c64b37 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/trax/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/trax/controller/CommonControllerTest.java @@ -96,4 +96,18 @@ public void testGetSchoolClobData_whenMinCode_isNot_Found() { Mockito.verify(commonService).getSchoolForClobDataBySchoolIdFromRedisCache(schoolId); } + @Test + public void testGetSchoolClobDataByParams() { + School school = new School(); + UUID schoolId = UUID.randomUUID(); + school.setSchoolId(schoolId.toString()); + school.setSchoolName("Test School"); + school.setMinCode("12345678"); + + Mockito.when(commonService.getSchoolForClobDataByMinCodeFromRedisCache(school.getMinCode())).thenReturn(school); + commonController.getSchoolForClobDataByMinCode(school.getMinCode()); + Mockito.verify(commonService).getSchoolForClobDataByMinCodeFromRedisCache(school.getMinCode()); + } + + }