From 4691f8dc624739ad3c6107928db14f844cbc2346 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 17 Nov 2023 17:28:17 -0700 Subject: [PATCH] Fix XML template --- .../api/gradbusiness/controller/GradBusinessController.java | 4 ++-- .../educ/api/gradbusiness/service/GradBusinessService.java | 5 +++-- .../gradbusiness/EducGradBusinessApiApplicationTests.java | 2 +- .../gradbusiness/EducGradBusinessApiControllerTests.java | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/GradBusinessController.java b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/GradBusinessController.java index 1cb73c6..0be003d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/GradBusinessController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/controller/GradBusinessController.java @@ -140,8 +140,8 @@ public ResponseEntity studentCredentialByType(@PathVariable String pen, @PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')") @Operation(summary = "Get Transcript Report pdf by PEN and optional xml type parameter", description = "Get Transcript Report pdf by PEN and optional xml type parameter", tags = { "Graduation Data" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - public ResponseEntity studentTranscriptByType(@PathVariable String pen, @RequestParam(required = false) String type, @RequestHeader(name="Authorization") String accessToken) { - return gradBusinessService.getStudentTranscriptPDFByType(pen, type, accessToken.replace(BEARER, "")); + public ResponseEntity studentTranscriptByType(@PathVariable String pen, @RequestParam(required = false) String type, @RequestParam(required = false) String interim, @RequestHeader(name="Authorization") String accessToken) { + return gradBusinessService.getStudentTranscriptPDFByType(pen, type, interim, accessToken.replace(BEARER, "")); } @GetMapping(EducGraduationApiConstants.AMALGAMATED_SCHOOL_REPORT_PDF) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java index e678309..b740b69 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/service/GradBusinessService.java @@ -286,10 +286,11 @@ public ResponseEntity getStudentCredentialPDFByType(String pen, String t @Transactional - public ResponseEntity getStudentTranscriptPDFByType(String pen, String type, String accessToken) { + public ResponseEntity getStudentTranscriptPDFByType(String pen, String type, String interim, String accessToken) { try { byte[] reportData = prepareReportDataByPen(pen, type, accessToken).getBody(); - boolean isPreview = (StringUtils.isNotBlank(type) && StringUtils.equalsAnyIgnoreCase(type, "xml", "interim")); + boolean isPreview = (StringUtils.isNotBlank(type) && StringUtils.equalsAnyIgnoreCase(type, "xml", "interim") || + StringUtils.isNotBlank(interim) && StringUtils.equalsAnyIgnoreCase(interim, "xml", "interim")); StringBuilder reportRequest = new StringBuilder(); String reportOptions = "\"options\": {\n" + " \"cacheReport\": false,\n" + 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 7e5c70e..fdaf090 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 @@ -460,7 +460,7 @@ void testStudentTranscriptPDFByTypeByPen() throws Exception { when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(transcriptPdfSample)); - ResponseEntity transcriptPdf = gradBusinessService.getStudentTranscriptPDFByType(pen, "xml", "accessToken"); + ResponseEntity transcriptPdf = gradBusinessService.getStudentTranscriptPDFByType(pen, "xml", null,"accessToken"); assertNotNull(transcriptPdf.getBody()); assertEquals(transcriptPdfSample,transcriptPdf.getBody()); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiControllerTests.java b/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiControllerTests.java index f5e9375..fbe0ade 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiControllerTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradbusiness/EducGradBusinessApiControllerTests.java @@ -234,9 +234,9 @@ void testStudentTranscriptPDFByType() throws Exception { .contentType(MediaType.APPLICATION_XML) .body(greBPack); - Mockito.when(gradBusinessService.getStudentTranscriptPDFByType("12312321","xml", "accessToken")).thenReturn(response); - gradBusinessController.studentTranscriptByType("12312321", "xml","accessToken"); - Mockito.verify(gradBusinessService).getStudentTranscriptPDFByType("12312321","xml", "accessToken"); + Mockito.when(gradBusinessService.getStudentTranscriptPDFByType("12312321","xml", null,"accessToken")).thenReturn(response); + gradBusinessController.studentTranscriptByType("12312321", "xml", null, "accessToken"); + Mockito.verify(gradBusinessService).getStudentTranscriptPDFByType("12312321","xml", null,"accessToken"); }