From 90f7ab8d15f50bfbb7be74a6b04b8d2e5c6c26fa Mon Sep 17 00:00:00 2001 From: githubmamatha Date: Mon, 6 Jan 2025 11:31:51 -0800 Subject: [PATCH] Part 7 - Updated API responses --- ...va => SchoolAndDistrictReportsController.java} | 15 +++++++++------ .../EducGradBusinessApiApplicationTests.java | 2 -- .../v2/DistrictReportServiceTest.java | 2 -- 3 files changed, 9 insertions(+), 10 deletions(-) rename api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/{SchoolAndDistrictController.java => SchoolAndDistrictReportsController.java} (78%) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictController.java b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictReportsController.java similarity index 78% rename from api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictController.java rename to api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictReportsController.java index b87d85f..d29391b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/v2/SchoolAndDistrictReportsController.java @@ -20,22 +20,23 @@ @RestController @RequestMapping(EducGraduationApiConstants.GRAD_BUSINESS_API_ROOT_MAPPING) @Slf4j -@OpenAPIDefinition(info = @Info(title = "API for School Data.", description = "This Read API is for Reading school data from TRAX.", version = "2"), +@OpenAPIDefinition(info = @Info(title = "API for School and District reports.", description = "This Read API is for Reading school and district data from TRAX.", version = "2"), security = {@SecurityRequirement(name = "OAUTH2", scopes = {"GET_GRADUATION_DATA"})}) -public class SchoolAndDistrictController { +public class SchoolAndDistrictReportsController { private final GradBusinessService gardBusinessService; - @Autowired - public SchoolAndDistrictController(GradBusinessService gardBusinessService) { + public SchoolAndDistrictReportsController(GradBusinessService gardBusinessService) { this.gardBusinessService = gardBusinessService; } @GetMapping(EducGradBusinessApiConstants.SCHOOL_REPORT_PDF_MINCODE_V2) @PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')") @Operation(summary = "Get School Report pdf from graduation by mincode and report type", description = "Get School Report pdf from graduation by mincode and report type", tags = { "Graduation Data" }) - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "400", description = "NOT FOUND"), + @ApiResponse(responseCode = "500", description = "INTERNAL SERVER ERROR.")}) public ResponseEntity schoolReportByMincode(@PathVariable String mincode,@RequestParam(name = "type") String type) { return gardBusinessService.getSchoolReportPDFByMincode(mincode, type); } @@ -43,7 +44,9 @@ public ResponseEntity schoolReportByMincode(@PathVariable String mincode @GetMapping(EducGradBusinessApiConstants.DISTRICT_REPORT_PDF_DISTCODE_V2) @PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')") @Operation(summary = "Get District Report pdf from graduation by distcode and report type", description = "Get District Report pdf from graduation by distcode and report type", tags = { "Graduation Data" }) - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), + @ApiResponse(responseCode = "400", description = "NOT FOUND"), + @ApiResponse(responseCode = "500", description = "INTERNAL SERVER ERROR.")}) public ResponseEntity districtReportByDistrictCode(@PathVariable String distcode, @RequestParam(name = "type") String type) { return gardBusinessService.getDistrictReportPDFByDistcode(distcode, type); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiApplicationTests.java b/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiApplicationTests.java index 900e672..2bb9cc8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiApplicationTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiApplicationTests.java @@ -312,7 +312,6 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception { ResponseEntity byteData = gradBusinessService.getAmalgamatedSchoolReportPDFByMincode(mincode, type, "accessToken"); assertNotNull(byteData); - //assertNotNull(byteData.getBody()); pdf = new InputStreamResource(new ByteArrayInputStream(new byte[0])); @@ -324,7 +323,6 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception { byteData = gradBusinessService.getAmalgamatedSchoolReportPDFByMincode(mincode, type, "accessToken"); assertNotNull(byteData); - //assertNull(byteData.getBody()); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/v2/DistrictReportServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/v2/DistrictReportServiceTest.java index 849fae6..9523765 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/v2/DistrictReportServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/v2/DistrictReportServiceTest.java @@ -19,7 +19,6 @@ import org.springframework.web.reactive.function.client.WebClient; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.Collections; import java.util.UUID; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -80,7 +79,6 @@ void testDistrictReportByDistrictCode_NotFound() { when(this.restService.get(any(String.class), any())).thenReturn(pdf); ResponseEntity byteData = gradBusinessService.getDistrictReportPDFByDistcode(distCode, type); - //assertNotNull(byteData); assertEquals(HttpStatus.NOT_FOUND, byteData.getStatusCode()); assertNull(byteData.getBody()); }