From 7f0fdf13eae9922bc225c480d89b4c4bb7d45cb0 Mon Sep 17 00:00:00 2001 From: Chris Ditcher Date: Tue, 1 Aug 2023 11:50:26 -0700 Subject: [PATCH 1/6] Grad release v1.8.23 (#110) * Default timezone config * Default timezone config * Update pom.xml --------- Co-authored-by: alexryba Co-authored-by: githubmamatha <106563495+githubmamatha@users.noreply.github.com> --- api/pom.xml | 2 +- .../educ/api/gradbusiness/config/EducGradBusinessApiConfig.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index ae48f71..552f933 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -11,7 +11,7 @@ ca.bc.gov educ-grad-business-api - 1.8.22 + 1.8.23 educ-grad-business-api GRAD Business API for external clients diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/config/EducGradBusinessApiConfig.java b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/config/EducGradBusinessApiConfig.java index 800464a..7cd745b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/config/EducGradBusinessApiConfig.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradbusiness/config/EducGradBusinessApiConfig.java @@ -49,4 +49,6 @@ public RestTemplate restTemplate(RestTemplateBuilder builder) { return builder.build(); } + + } From e1a12cb403082e74958d2d883d75cc7966d611a0 Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 30 Oct 2023 12:41:36 -0600 Subject: [PATCH 2/6] GRAD2-2356 Incorrect error message returned with calls from TSW to GRAD - 500 vs 200 --- .../service/GradBusinessService.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) 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 b5a9bfe..0bcfc07 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 @@ -1,11 +1,11 @@ package ca.bc.gov.educ.api.gradbusiness.service; import ca.bc.gov.educ.api.gradbusiness.model.dto.Student; -import ca.bc.gov.educ.api.gradbusiness.util.EducGradBusinessUtil; import ca.bc.gov.educ.api.gradbusiness.util.EducGradBusinessApiConstants; +import ca.bc.gov.educ.api.gradbusiness.util.EducGradBusinessUtil; import ca.bc.gov.educ.api.gradbusiness.util.EducGraduationApiConstants; import io.github.resilience4j.retry.annotation.Retry; -import org.apache.commons.io.IOUtils; +import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -19,7 +19,6 @@ import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; -import jakarta.transaction.Transactional; import java.io.IOException; import java.io.InputStream; import java.util.*; @@ -86,7 +85,9 @@ public ResponseEntity prepareReportDataByPen(String pen, String type, St type = Optional.ofNullable(type).orElse(""); try { byte[] result = webClient.get().uri(String.format(educGraduationApiConstants.getGraduateReportDataByPenUrl(), pen) + "?type=" + type).headers(h -> h.setBearerAuth(accessToken)).retrieve().bodyToMono(byte[].class).block(); - assert result != null; + if(result == null) { + result = new byte[0]; + } return handleBinaryResponse(result, "graduation_report_data.json", MediaType.APPLICATION_JSON); } catch (Exception e) { return getInternalServerErrorResponse(e); @@ -108,7 +109,9 @@ public ResponseEntity prepareReportDataByGraduation(String graduationDat headers.put(HttpHeaders.ACCEPT, Collections.singletonList(APPLICATION_JSON)); headers.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(APPLICATION_JSON)); byte[] result = webClient.post().uri(educGraduationApiConstants.getGraduateReportDataByGraduation() + "?type=" + type).headers(h -> h.addAll(headers)).body(BodyInserters.fromValue(graduationData)).retrieve().bodyToMono(byte[].class).block(); - assert result != null; + if(result == null) { + result = new byte[0]; + } return handleBinaryResponse(result, "graduation_report_data.json", MediaType.APPLICATION_JSON); } catch (Exception e) { return getInternalServerErrorResponse(e); @@ -129,7 +132,9 @@ public ResponseEntity prepareXmlTranscriptReportDataByXmlRequest(String headers.put(HttpHeaders.ACCEPT, Collections.singletonList(APPLICATION_JSON)); headers.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(APPLICATION_JSON)); byte[] result = webClient.post().uri(educGraduationApiConstants.getXmlTranscriptReportData()).headers(h -> h.addAll(headers)).body(BodyInserters.fromValue(xmlRequest)).retrieve().bodyToMono(byte[].class).block(); - assert result != null; + if(result == null) { + result = new byte[0]; + } return handleBinaryResponse(result, "xml_transcript_report_data.json", MediaType.APPLICATION_JSON); } catch (Exception e) { return getInternalServerErrorResponse(e); @@ -150,7 +155,9 @@ public ResponseEntity getStudentDemographicsByPen(String pen, String acc headers.put(HttpHeaders.ACCEPT, Collections.singletonList(APPLICATION_JSON)); headers.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(APPLICATION_JSON)); byte[] result = webClient.get().uri(String.format(educGradStudentApiConstants.getPenDemographicStudentApiUrl(), pen)).headers(h -> h.setBearerAuth(accessToken)).retrieve().bodyToMono(byte[].class).block(); - assert result != null; + if(result == null) { + result = new byte[0]; + } return handleBinaryResponse(result, "student_demog_data.json", MediaType.APPLICATION_JSON); } catch (Exception e) { return getInternalServerErrorResponse(e); @@ -209,8 +216,10 @@ public ResponseEntity getSchoolReportPDFByMincode(String mincode, String headers.put(HttpHeaders.ACCEPT, Collections.singletonList(APPLICATION_PDF)); headers.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(APPLICATION_PDF)); InputStreamResource result = webClient.get().uri(String.format(educGraduationApiConstants.getSchoolReportByMincode(), mincode,type)).headers(h -> h.setBearerAuth(accessToken)).retrieve().bodyToMono(InputStreamResource.class).block(); - assert result != null; - byte[] res = IOUtils.toByteArray(result.getInputStream()); + byte[] res = new byte[0]; + if(result != null) { + res = result.getInputStream().readAllBytes(); + } return handleBinaryResponse(res, EducGradBusinessUtil.getFileNameSchoolReports(mincode,year,month,type), MediaType.APPLICATION_PDF); } catch (Exception e) { return getInternalServerErrorResponse(e); @@ -264,16 +273,13 @@ public ResponseEntity getStudentCredentialPDFByType(String pen, String t headers.put(HttpHeaders.ACCEPT, Collections.singletonList(APPLICATION_PDF)); headers.put(HttpHeaders.CONTENT_TYPE, Collections.singletonList(APPLICATION_PDF)); InputStreamResource result = webClient.get().uri(String.format(educGraduationApiConstants.getStudentCredentialByType(), studObj.getStudentID(),type)).headers(h -> h.setBearerAuth(accessToken)).retrieve().bodyToMono(InputStreamResource.class).block(); - assert result != null; - byte[] res = IOUtils.toByteArray(result.getInputStream()); + byte[] res = new byte[0]; + if(result != null) { + res = result.getInputStream().readAllBytes(); + } return handleBinaryResponse(res, EducGradBusinessUtil.getFileNameStudentCredentials(studObj.getMincode(),pen,type), MediaType.APPLICATION_PDF); } catch (Exception e) { return getInternalServerErrorResponse(e); } } - - - - - } From b1b0f814beeac99c0453c7d985988126a6ef94f8 Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 30 Oct 2023 13:32:53 -0600 Subject: [PATCH 3/6] Test coverage --- .../EducGradBusinessApiApplicationTests.java | 61 ++++++++++++------ api/src/test/resources/data/sample.pdf | Bin 0 -> 14049 bytes 2 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 api/src/test/resources/data/sample.pdf 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 24e62c7..846cdde 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 @@ -24,6 +24,7 @@ import reactor.core.publisher.Mono; import java.io.BufferedReader; +import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; @@ -216,8 +217,9 @@ void testSchoolReportPDFByMincode() throws Exception { String mincode = "128385861"; String type = "NONGRADPRJ"; - InputStream is = getClass().getClassLoader().getResourceAsStream("json/xmlTranscriptReportRequest.json"); - InputStreamResource pdf = new InputStreamResource(is); + + byte[] samplePdf = readBinaryFile("data/sample.pdf"); + InputStreamResource pdf = new InputStreamResource(new ByteArrayInputStream(samplePdf)); when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(educGraduationApiConstants.getSchoolReportByMincode(),mincode,type))).thenReturn(this.requestHeadersMock); @@ -235,8 +237,9 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception { String mincode = "128385861"; String type = "TVRNONGRAD"; - InputStream is = getClass().getClassLoader().getResourceAsStream("json/xmlTranscriptReportRequest.json"); - InputStreamResource pdf = new InputStreamResource(is); + + byte[] samplePdf = readBinaryFile("data/sample.pdf"); + InputStreamResource pdf = new InputStreamResource(new ByteArrayInputStream(samplePdf)); UUID studentID = UUID.randomUUID(); when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); @@ -257,26 +260,28 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception { } @Test - void testSchoolReportPDFByMincode_witherror() throws Exception { + void testSchoolReportPDFByMincode_NotFound() throws Exception { String mincode = "128385861"; String type = "NONGRADPRJ"; - InputStream is = getClass().getClassLoader().getResourceAsStream("json/xmlTranscriptReportRequest.json"); + + byte[] samplePdf = new byte[0]; + InputStreamResource pdf = new InputStreamResource(new ByteArrayInputStream(samplePdf)); when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(educGraduationApiConstants.getSchoolReportByMincode(),mincode,type))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - when(this.responseMock.bodyToMono(InputStreamResource.class)).thenReturn(null); + when(this.responseMock.bodyToMono(InputStreamResource.class)).thenReturn(Mono.just(pdf)); ResponseEntity byteData = gradBusinessService.getSchoolReportPDFByMincode(mincode, type, "accessToken"); assertNotNull(byteData); - assertTrue(byteData.getBody().length > 0); + assertNull(byteData.getBody()); } @Test - void testSchoolReportPDFByMincode_witherror2() throws Exception { + void testSchoolReportPDFByMincode_Error500() throws Exception { String mincode = "128385861"; String type = "NONGRADPRJ"; @@ -292,6 +297,7 @@ void testSchoolReportPDFByMincode_witherror2() throws Exception { ResponseEntity byteData = gradBusinessService.getSchoolReportPDFByMincode(mincode, type, "accessToken"); assertNotNull(byteData); assertTrue(byteData.getBody().length > 0); + assertTrue(byteData.getStatusCode().is5xxServerError()); } @Test @@ -316,12 +322,14 @@ void testGetStudentDemographicsByPen() throws Exception { void testStudentCredentialPDFByType() throws Exception { String pen = "128385861"; - String type = "TRAN"; - InputStream is = getClass().getClassLoader().getResourceAsStream("json/xmlTranscriptReportRequest.json"); - InputStreamResource pdf = new InputStreamResource(is); + String type = "GRADREG"; + + byte[] samplePdf = readBinaryFile("data/sample.pdf"); + InputStreamResource pdf = new InputStreamResource(new ByteArrayInputStream(samplePdf)); Student sObj = new Student(); sObj.setStudentID(UUID.randomUUID().toString()); + sObj.setPen(pen); sObj.setMincode("123123112"); when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); @@ -345,22 +353,24 @@ void testStudentCredentialPDFByType() throws Exception { } @Test - void testStudentCredentialPDFByType_witherror() throws Exception { + void testStudentCredentialPDFByType_NotFound() throws Exception { String pen = "128385861"; - String type = "TRAN"; - InputStream is = getClass().getClassLoader().getResourceAsStream("json/xmlTranscriptReportRequest.json"); - InputStreamResource pdf = new InputStreamResource(is); + String type = "NONGRADREG"; + + byte[] samplePdf = new byte[0]; + InputStreamResource pdf = new InputStreamResource(new ByteArrayInputStream(samplePdf)); Student sObj = new Student(); sObj.setStudentID(UUID.randomUUID().toString()); + sObj.setPen(pen); sObj.setMincode("123123112"); when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); when(this.requestHeadersUriMock.uri(String.format(educGraduationApiConstants.getStudentCredentialByType(),sObj.getStudentID(),type))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - when(this.responseMock.bodyToMono(InputStreamResource.class)).thenReturn(null); + when(this.responseMock.bodyToMono(InputStreamResource.class)).thenReturn(Mono.just(pdf)); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; @@ -373,19 +383,23 @@ void testStudentCredentialPDFByType_witherror() throws Exception { ResponseEntity byteData = gradBusinessService.getStudentCredentialPDFByType(pen, type, "accessToken"); assertNotNull(byteData); - assertTrue(byteData.getBody().length > 0); + assertNull(byteData.getBody()); + } @Test - void testStudentCredentialPDFByType_witherror2() { + void testStudentCredentialPDFByType_Error500() throws Exception { String pen = "128385861"; String type = "TRAN"; String studentID = UUID.randomUUID().toString(); - InputStream is = getClass().getClassLoader().getResourceAsStream("json/xml_report_sample.xml"); + + byte[] samplePdf = readBinaryFile("data/sample.pdf"); + InputStreamResource pdf = new InputStreamResource(new ByteArrayInputStream(samplePdf)); Student sObj = new Student(); sObj.setStudentID(studentID); + sObj.setPen(pen); sObj.setMincode("123123112"); final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { @@ -400,6 +414,13 @@ void testStudentCredentialPDFByType_witherror2() { ResponseEntity byteData = gradBusinessService.getStudentCredentialPDFByType(pen, type, "accessToken"); assertNotNull(byteData); assertTrue(byteData.getBody().length > 0); + assertTrue(byteData.getStatusCode().is5xxServerError()); + } + + private byte[] readBinaryFile(String path) throws Exception { + ClassLoader classLoader = getClass().getClassLoader(); + InputStream inputStream = classLoader.getResourceAsStream(path); + return inputStream.readAllBytes(); } } diff --git a/api/src/test/resources/data/sample.pdf b/api/src/test/resources/data/sample.pdf new file mode 100644 index 0000000000000000000000000000000000000000..805a21e6e029c58916e8e5b48fd445353c760375 GIT binary patch literal 14049 zcma)j1yEc~vvwem1Pkr~7PlaaJHg$9yR*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Z>#sV&?YoEncbD&t@1@*V_& zM`RLmGKRwJ0bJZb#ur#S7b4S(s}~Ui3y_16m6?m3`vsD3YNG~)>@za6vIE(nW+I06 zlBOVY3ow9#gM|^u%*_h5l!5~3LB>M1FANSSZ2x6n!hhlY8Q3|v7+Kk&N&p5{W)4OU zHf9c1C;@|+831I4j-gG80W?BTVu~r0(W2l8C98mJ%>gw3FoOzJobBzcO6K=(vC4FLtb!r|RL?V zoMP=4tE2ysEhn&{Blxde0a-a&SrI8I#T3N Date: Mon, 30 Oct 2023 13:54:47 -0600 Subject: [PATCH 4/6] Test coverage --- .../EducGradBusinessApiApplicationTests.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) 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 846cdde..1e51b42 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 @@ -115,6 +115,25 @@ void testReportDataByPen() throws Exception { json = new String(byteData.getBody()); assertEquals(json,reportData); + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(educGraduationApiConstants.getGraduateReportDataByPenUrl(),"128385861") + "?type=CERT")).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(new byte[0])); + + byteData = gradBusinessService.prepareReportDataByPen(pen, "CERT", "accessToken"); + assertNotNull(byteData); + assertNull(byteData.getBody()); + + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(educGraduationApiConstants.getGraduateReportDataByPenUrl(),"128385861") + "?type=CERT")).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(byte[].class)).thenReturn(null); + + byteData = gradBusinessService.prepareReportDataByPen(pen, "CERT", "accessToken"); + assertNotNull(byteData); + assertTrue(byteData.getStatusCode().is5xxServerError()); } @@ -172,6 +191,30 @@ void testReportDataByGraduationData() throws Exception { json = new String(byteData.getBody()); assertEquals(json,reportData); + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(educGraduationApiConstants.getGraduateReportDataByGraduation() + "?type=CERT")).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(new byte[0])); + + byteData = gradBusinessService.prepareReportDataByGraduation(studentGradData, "CERT", "accessToken"); + assertNotNull(byteData); + assertNull(byteData.getBody()); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(educGraduationApiConstants.getGraduateReportDataByGraduation() + "?type=CERT")).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(byte[].class)).thenReturn(null); + + byteData = gradBusinessService.prepareReportDataByGraduation(studentGradData, "CERT", "accessToken"); + assertNotNull(byteData); + assertTrue(byteData.getStatusCode().is5xxServerError()); + } @org.junit.jupiter.api.Test @@ -257,6 +300,20 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception { ResponseEntity byteData = gradBusinessService.getAmalgamatedSchoolReportPDFByMincode(mincode, type, "accessToken"); assertNotNull(byteData); assertNotNull(byteData.getBody()); + + pdf = new InputStreamResource(new ByteArrayInputStream(new byte[0])); + + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(educGraduationApiConstants.getStudentCredentialByType(),studentID,"ACHV"))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(InputStreamResource.class)).thenReturn(Mono.just(pdf)); + + byteData = gradBusinessService.getAmalgamatedSchoolReportPDFByMincode(mincode, type, "accessToken"); + assertNotNull(byteData); + assertNotNull(byteData.getBody()); + assertTrue(byteData.getStatusCode().is5xxServerError()); + } @Test @@ -316,6 +373,27 @@ void testGetStudentDemographicsByPen() throws Exception { ResponseEntity byteData = gradBusinessService.getStudentDemographicsByPen(pen,"accessToken"); assertNotNull(byteData); assertTrue(byteData.getBody().length > 0); + + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(educGradStudentApiConstants.getPenDemographicStudentApiUrl(),pen))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(new byte[0])); + + byteData = gradBusinessService.getStudentDemographicsByPen(pen,"accessToken"); + assertNotNull(byteData); + assertNull(byteData.getBody()); + + when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); + when(this.requestHeadersUriMock.uri(String.format(educGradStudentApiConstants.getPenDemographicStudentApiUrl(),pen))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(byte[].class)).thenThrow(); + + byteData = gradBusinessService.getStudentDemographicsByPen(pen,"accessToken"); + assertNotNull(byteData); + assertTrue(byteData.getBody().length > 0); + assertTrue(byteData.getStatusCode().is5xxServerError()); } @Test From 1cb597b604903789e42e577b6809e650c885a04f Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 3 Nov 2023 08:56:28 -0600 Subject: [PATCH 5/6] Fix test error --- .../gradbusiness/EducGradBusinessApiApplicationTests.java | 6 ------ 1 file changed, 6 deletions(-) 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 be5e6e4..7e5c70e 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 @@ -255,12 +255,6 @@ private String readFile(String jsonPath) throws Exception { return sb.toString(); } - private byte[] readBinaryFile(String path) throws Exception { - ClassLoader classLoader = getClass().getClassLoader(); - InputStream inputStream = classLoader.getResourceAsStream(path); - return inputStream.readAllBytes(); - } - @Test void testSchoolReportPDFByMincode() throws Exception { From 32b46fb2d53b22486fc0d269685296fa55f8ae3d Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Fri, 17 Nov 2023 00:45:09 +0530 Subject: [PATCH 6/6] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 552f933..970cf2a 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -11,7 +11,7 @@ ca.bc.gov educ-grad-business-api - 1.8.23 + 1.8.24 educ-grad-business-api GRAD Business API for external clients