diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/controller/GraduationController.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/controller/GraduationController.java index e9554081..b229e3bc 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/controller/GraduationController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/controller/GraduationController.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; import static ca.bc.gov.educ.api.graduation.service.SchoolReportsService.*; @@ -108,7 +109,7 @@ public ResponseEntity reportDataFromGraduation(@RequestBody @NotNull @PreAuthorize(PermissionsContants.GRADUATE_STUDENT) @Operation(summary = "School Report Creation", description = "When triggered, School Reports are created", tags = { "Reports" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - public ResponseEntity createAndStoreSchoolReports(@RequestBody List uniqueSchools, @RequestHeader(name="Authorization") String accessToken,@RequestParam(required = false) String type ) { + public ResponseEntity createAndStoreSchoolReports(@RequestBody List uniqueSchools, @RequestHeader(name="Authorization") String accessToken, @RequestParam(required = false) String type ) { return response.GET(gradService.createAndStoreSchoolReports(uniqueSchools,type)); } @@ -364,7 +365,7 @@ public ResponseEntity getSchoolDistrictSuppReports( @PreAuthorize(PermissionsContants.GRADUATE_STUDENT) @Operation(summary = "School Report Generation", description = "When triggered, School Report is generated", tags = { "Reports", "type=GRADREG", "type=NONGRADREG", "type=NONGRADPRJ" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - public ResponseEntity getSchoolReports(@RequestBody List uniqueSchools, @RequestParam(required = true) String type ) { + public ResponseEntity getSchoolReports(@RequestBody List uniqueSchools, @RequestParam(required = true) String type ) { byte[] resultBinary = gradService.getSchoolReports(uniqueSchools,type); if(resultBinary == null || resultBinary.length == 0) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolReports.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolReports.java index c2dab719..2351560a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolReports.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolReports.java @@ -14,4 +14,5 @@ public class SchoolReports extends BaseModel { private String reportTypeCode; private String reportTypeLabel; private String schoolOfRecord; + private UUID schoolOfRecordId; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java index c9cceda1..9b82d1e2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GradStatusService.java @@ -17,6 +17,7 @@ import org.springframework.web.reactive.function.client.WebClient; import java.util.List; +import java.util.UUID; @Service public class GradStatusService { @@ -107,8 +108,8 @@ public void restoreStudentGradStatus(String studentID, boolean isGraduated) { restService.get(String.format(educGraduationApiConstants.getUpdateGradStatusAlgoError(),studentID,isGraduated), Boolean.class); } - public List getStudentListByMinCode(String schoolOfRecord) { - var response = this.restService.get(String.format(educGraduationApiConstants.getGradStudentListSchoolReport(),schoolOfRecord), List.class); + public List getStudentListBySchoolId(UUID schoolId) { + var response = this.restService.get(String.format(educGraduationApiConstants.getGradStudentListSchoolReport(),schoolId), List.class); return jsonTransformer.convertValue(response, new TypeReference<>(){}); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GraduationService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GraduationService.java index 26c3b838..1585c58a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GraduationService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/GraduationService.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.UUID; @Service public class GraduationService { @@ -191,14 +192,13 @@ private boolean isGraduated(GraduationStudentRecord graduationStudentRecord, Gra return graduationData.isGraduated() && graduationStudentRecord.getProgramCompletionDate() != null; } - public byte[] getSchoolReports(List uniqueSchoolList, String type) { + public byte[] getSchoolReports(List uniqueSchoolList, String type) { byte[] result = new byte[0]; - for (String usl : uniqueSchoolList) { + for (UUID usl : uniqueSchoolList) { try { - List stdList = gradStatusService.getStudentListByMinCode(usl); - List schoolDetails = schoolService.getSchoolDetails(usl); - if (schoolDetails != null && !schoolDetails.isEmpty()) { - ca.bc.gov.educ.api.graduation.model.dto.institute.School schoolDetail = schoolDetails.get(0); + List stdList = gradStatusService.getStudentListBySchoolId(usl); + ca.bc.gov.educ.api.graduation.model.dto.institute.School schoolDetail = schoolService.getSchoolDetails(usl); + if (schoolDetail != null) { School schoolObj = new School(); schoolObj.setSchoolId(schoolDetail.getSchoolId()); schoolObj.setMincode(schoolDetail.getMincode()); @@ -222,25 +222,24 @@ public byte[] getSchoolReports(List uniqueSchoolList, String type) { } } } catch (Exception e) { - logger.error("Failed to generate {} report for mincode: {} due to: {}", type, usl, e.getLocalizedMessage()); + logger.error("Failed to generate {} report for schoolId: {} due to: {}", type, usl, e.getLocalizedMessage()); } } return result; } - public Integer createAndStoreSchoolReports(List uniqueSchoolList, String type) { + public Integer createAndStoreSchoolReports(List uniqueSchoolList, String type) { int numberOfReports = 0; - for (String usl : uniqueSchoolList) { + for (UUID usl : uniqueSchoolList) { try { - List stdList = gradStatusService.getStudentListByMinCode(usl); + List stdList = gradStatusService.getStudentListBySchoolId(usl); if(logger.isDebugEnabled()) { int totalStudents = ObjectUtils.defaultIfNull(stdList.size(), 0); String listOfStudents = jsonTransformer.marshall(stdList); logger.debug("*** Student List of {} Acquired {}", totalStudents, listOfStudents); } - List schoolDetails = schoolService.getSchoolDetails(usl); - if (schoolDetails != null && !schoolDetails.isEmpty()) { - ca.bc.gov.educ.api.graduation.model.dto.institute.School schoolDetail = schoolDetails.get(0); + ca.bc.gov.educ.api.graduation.model.dto.institute.School schoolDetail = schoolService.getSchoolDetails(usl); + if (schoolDetail != null) { logger.debug("*** School Details Acquired {}", schoolDetail.getDisplayName()); if (stdList != null && !stdList.isEmpty()) { School schoolObj = new School(); @@ -262,7 +261,7 @@ public Integer createAndStoreSchoolReports(List uniqueSchoolList, String } } } catch (Exception e) { - logger.error("Failed to generate {} report for mincode: {} due to: {}", type, usl, e.getLocalizedMessage()); + logger.error("Failed to generate {} report for schoolId: {} due to: {}", type, usl, e.getLocalizedMessage()); } } return numberOfReports; @@ -283,38 +282,38 @@ private List filterStudentList(List stdList, String mincode, int numberOfReports) { - Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolObj.getMincode()); + private int processGradRegReport(School schoolObj, List stdList, UUID schoolId, int numberOfReports) { + Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolId); if(studentsCount > 0) { ReportData gradReport = getReportDataObj(schoolObj, stdList); - createAndSaveSchoolReportGradRegReport(gradReport, mincode); + createAndSaveSchoolReportGradRegReport(gradReport, schoolObj.getMincode()); numberOfReports++; } return numberOfReports; } - private int processNonGradRegReport(School schoolObj, List stdList, String mincode, int numberOfReports) { - Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolObj.getMincode()); + private int processNonGradRegReport(School schoolObj, List stdList, UUID schoolId, int numberOfReports) { + Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolId); if(studentsCount > 0) { ReportData gradReport = getReportDataObj(schoolObj, stdList); - createAndSaveSchoolReportNonGradRegReport(gradReport, mincode); + createAndSaveSchoolReportNonGradRegReport(gradReport, schoolId, schoolObj.getMincode()); numberOfReports++; } return numberOfReports; } - private int processStudentNonGradPrjReport(School schoolObj, List stdList, String mincode, int numberOfReports) { - Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolObj.getMincode()); + private int processStudentNonGradPrjReport(School schoolObj, List stdList, UUID schoolId, int numberOfReports) { + Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolId); if(studentsCount > 0) { ReportData nongradProjected = getReportDataObj(schoolObj, stdList); - createAndSaveSchoolReportStudentNonGradPrjReport(nongradProjected, mincode); + createAndSaveSchoolReportStudentNonGradPrjReport(nongradProjected, schoolId, schoolObj.getMincode()); numberOfReports++; } return numberOfReports; } - private int countStudentsForAmalgamatedSchoolReport(String mincode) { - return restService.get(String.format(educGraduationApiConstants.getGradStudentCountSchoolReport(), mincode), Integer.class); + private int countStudentsForAmalgamatedSchoolReport(UUID schoolId) { + return restService.get(String.format(educGraduationApiConstants.getGradStudentCountSchoolReport(), schoolId), Integer.class); } private ReportData getReportDataObj(School schoolObj, List stdList) { @@ -417,8 +416,9 @@ private byte[] createAndSaveSchoolReportGradRegReport(ReportData data, String mi byte[] bytesSAR = getSchoolReportGradRegReport(data, mincode); String encodedPdf = getEncodedPdfFromBytes(bytesSAR); + UUID schoolId = UUID.fromString(data.getSchool().getSchoolId()); - SchoolReports requestObj = getSchoolReports(mincode, encodedPdf, GRADREG); + SchoolReports requestObj = getSchoolReports(schoolId, mincode, encodedPdf, GRADREG); updateSchoolReport(requestObj); @@ -451,10 +451,10 @@ private byte[] getSchoolReportNonGradRegReport(ReportData data, String mincode) } @Generated - private void createAndSaveSchoolReportNonGradRegReport(ReportData data, String mincode) { + private void createAndSaveSchoolReportNonGradRegReport(ReportData data, UUID schoolId, String mincode) { byte[] bytesSAR = getSchoolReportNonGradRegReport(data, mincode); String encodedPdf = getEncodedPdfFromBytes(bytesSAR); - SchoolReports requestObj = getSchoolReports(mincode, encodedPdf, NONGRADREG); + SchoolReports requestObj = getSchoolReports(schoolId, mincode, encodedPdf, NONGRADREG); updateSchoolReport(requestObj); } @@ -490,10 +490,10 @@ private byte[] getSchoolReportStudentNonGradReport(ReportData data, String minco accessToken); } - private void createAndSaveSchoolReportStudentNonGradPrjReport(ReportData data, String mincode) { + private void createAndSaveSchoolReportStudentNonGradPrjReport(ReportData data, UUID schoolId, String mincode) { byte[] bytesSAR = getSchoolReportStudentNonGradPrjReport(data, mincode); String encodedPdf = getEncodedPdfFromBytes(bytesSAR); - SchoolReports requestObj = getSchoolReports(mincode, encodedPdf, NONGRADPRJ); + SchoolReports requestObj = getSchoolReports(schoolId, mincode, encodedPdf, NONGRADPRJ); updateSchoolReport(requestObj); } @@ -505,9 +505,10 @@ private void createAndSaveSchoolReportStudentNonGradReport(ReportData data, Stri updateSchoolReport(accessToken, requestObj); } **/ - private SchoolReports getSchoolReports(String mincode, String encodedPdf, String nongradreg) { + private SchoolReports getSchoolReports(UUID schoolId, String mincode, String encodedPdf, String nongradreg) { SchoolReports requestObj = new SchoolReports(); requestObj.setReport(encodedPdf); + requestObj.setSchoolOfRecordId(schoolId); requestObj.setSchoolOfRecord(mincode); requestObj.setReportTypeCode(nongradreg); return requestObj; diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java index 987324e1..e4b95018 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java @@ -758,6 +758,7 @@ private GraduationStatus getGraduationStatus(ca.bc.gov.educ.api.graduation.model //--> Revert code back to school of record GRAD2-2758 /** gradMessage = StringUtils.replace(gradMessage, schoolOfRecord.getName(), schoolAtGrad.getName());**/ //<-- + gradStatus.setSchoolAtGrad(schoolAtGrad.getMincode()); log.debug("Replace school of record {} to school at graduation {}", schoolOfRecord.getName(), schoolAtGrad.getName()); } gradStatus.setGraduationMessage(gradMessage); diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolService.java index ea7c6454..5e7610a3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolService.java @@ -24,9 +24,9 @@ public SchoolService(EducGraduationApiConstants educGraduationApiConstants, REST this.jsonTransformer = jsonTransformer; } - public List getSchoolDetails(String mincode) { - var response = this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),mincode), List.class); - return jsonTransformer.convertValue(response, new TypeReference<>() {}); + public ca.bc.gov.educ.api.graduation.model.dto.institute.School getSchoolDetails(UUID schoolId) { + if (schoolId == null) return null; + return this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),schoolId), ca.bc.gov.educ.api.graduation.model.dto.institute.School.class); } public School getSchoolClob(String schoolId) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java index e1ce9997..3326f0d0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/util/EducGraduationApiConstants.java @@ -165,7 +165,7 @@ public class EducGraduationApiConstants { @Value("${endpoint.grad-trax-api.school-clob-by-school-id.url}") private String schoolClobBySchoolIdUrl; - @Value("${endpoint.grad-trax-api.search-schools-by-min-code.url}") + @Value("${endpoint.grad-trax-api.school-detail-by-school-id.url}") private String schoolDetails; @Value("${endpoint.grad-trax-api.district-by-min-code.url}") diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 81f2468f..858c4a9f 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -143,8 +143,8 @@ endpoint: url: ${PEN_API}api/v1/student?pen=%s grad-trax-api: - search-schools-by-min-code: - url: ${GRAD_TRAX_API}api/v2/trax/school/search?mincode=%s + school-detail-by-school-id: + url: ${GRAD_TRAX_API}api/v2/trax/school/%s school-clob-by-school-id: url: ${GRAD_TRAX_API}api/v2/trax/school-clob/%s district-by-min-code: diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/controller/GraduationControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/controller/GraduationControllerTest.java index bee21e08..d3268990 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/controller/GraduationControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/controller/GraduationControllerTest.java @@ -131,9 +131,10 @@ void testReportDataFromGraduation() { @Test void testCreateAndStoreSchoolReports() { - Mockito.when(graduationService.createAndStoreSchoolReports(List.of("12321312"),"NONGRAD")).thenReturn(1); - graduationController.createAndStoreSchoolReports(List.of("12321312"),"accessToken","NONGRAD"); - Mockito.verify(graduationService).createAndStoreSchoolReports(List.of("12321312"),"NONGRAD"); + UUID schoolId = UUID.randomUUID(); + Mockito.when(graduationService.createAndStoreSchoolReports(List.of(schoolId),"NONGRAD")).thenReturn(1); + graduationController.createAndStoreSchoolReports(List.of(schoolId),"accessToken","NONGRAD"); + Mockito.verify(graduationService).createAndStoreSchoolReports(List.of(schoolId),"NONGRAD"); } @Test @@ -343,48 +344,51 @@ void testCreateAndStoreDistrictPdfReports() { @Test void testGetSchoolReports() throws Exception { byte[] bytesSAR1 = readBinaryFile("data/sample.pdf"); - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"GRADREG")).thenReturn(bytesSAR1); - graduationController.getSchoolReports(List.of("12321312"),"GRADREG"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"GRADREG"); + UUID schoolId = UUID.randomUUID(); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"GRADREG")).thenReturn(bytesSAR1); + graduationController.getSchoolReports(List.of(schoolId),"GRADREG"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"GRADREG"); - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"NONGRADREG")).thenReturn(bytesSAR1); - graduationController.getSchoolReports(List.of("12321312"),"NONGRADREG"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"NONGRADREG"); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"NONGRADREG")).thenReturn(bytesSAR1); + graduationController.getSchoolReports(List.of(schoolId),"NONGRADREG"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"NONGRADREG"); - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"NONGRADPRJ")).thenReturn(bytesSAR1); - graduationController.getSchoolReports(List.of("12321312"),"NONGRADPRJ"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"NONGRADPRJ"); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"NONGRADPRJ")).thenReturn(bytesSAR1); + graduationController.getSchoolReports(List.of(schoolId),"NONGRADPRJ"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"NONGRADPRJ"); } @Test void testGetSchoolReportsEmpty() throws Exception { byte[] bytesSAR1 = new byte[0]; - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"GRADREG")).thenReturn(bytesSAR1); - graduationController.getSchoolReports(List.of("12321312"),"GRADREG"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"GRADREG"); + UUID schoolId = UUID.randomUUID(); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"GRADREG")).thenReturn(bytesSAR1); + graduationController.getSchoolReports(List.of(schoolId),"GRADREG"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"GRADREG"); - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"NONGRADREG")).thenReturn(bytesSAR1); - graduationController.getSchoolReports(List.of("12321312"),"NONGRADREG"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"NONGRADREG"); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"NONGRADREG")).thenReturn(bytesSAR1); + graduationController.getSchoolReports(List.of(schoolId),"NONGRADREG"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"NONGRADREG"); - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"NONGRADPRJ")).thenReturn(bytesSAR1); - graduationController.getSchoolReports(List.of("12321312"),"NONGRADPRJ"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"NONGRADPRJ"); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"NONGRADPRJ")).thenReturn(bytesSAR1); + graduationController.getSchoolReports(List.of(schoolId),"NONGRADPRJ"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"NONGRADPRJ"); } @Test void testGetSchoolReportsNull() { - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"GRADREG")).thenReturn(null); - graduationController.getSchoolReports(List.of("12321312"),"GRADREG"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"GRADREG"); - - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"NONGRADREG")).thenReturn(null); - graduationController.getSchoolReports(List.of("12321312"),"NONGRADREG"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"NONGRADREG"); - - Mockito.when(graduationService.getSchoolReports(List.of("12321312"),"NONGRADPRJ")).thenReturn(null); - graduationController.getSchoolReports(List.of("12321312"),"NONGRADPRJ"); - Mockito.verify(graduationService).getSchoolReports(List.of("12321312"),"NONGRADPRJ"); + UUID schoolId = UUID.randomUUID(); + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"GRADREG")).thenReturn(null); + graduationController.getSchoolReports(List.of(schoolId),"GRADREG"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"GRADREG"); + + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"NONGRADREG")).thenReturn(null); + graduationController.getSchoolReports(List.of(schoolId),"NONGRADREG"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"NONGRADREG"); + + Mockito.when(graduationService.getSchoolReports(List.of(schoolId),"NONGRADPRJ")).thenReturn(null); + graduationController.getSchoolReports(List.of(schoolId),"NONGRADPRJ"); + Mockito.verify(graduationService).getSchoolReports(List.of(schoolId),"NONGRADPRJ"); } @Test diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GradStatusServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GradStatusServiceTest.java index 64cecf5e..b4a979e4 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GradStatusServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GradStatusServiceTest.java @@ -296,14 +296,14 @@ public void testRestoreStudentGradStatus() { } @Test - public void testGetStudentsbyMincode() { - String mincode = "12312311"; + public void testGetStudentsBySchoolId() { + UUID schoolId = UUID.randomUUID(); GraduationStudentRecord gsr = new GraduationStudentRecord(); gsr.setLegalLastName("qweqw"); when(this.restService.get(any(String.class), any())).thenReturn(List.of(gsr)); - List res = gradStatusService.getStudentListByMinCode(mincode); + List res = gradStatusService.getStudentListBySchoolId(schoolId); assertThat(res).isNotEmpty().hasSize(1); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GraduationServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GraduationServiceTest.java index 6606cd0d..78bc3e21 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GraduationServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/GraduationServiceTest.java @@ -1946,8 +1946,8 @@ public void testCreateAndStoreSchoolReports() { ExceptionMessage exception = new ExceptionMessage(); UUID schoolId = UUID.randomUUID(); String mincode = "1231231231"; - List uniqueList = new ArrayList<>(); - uniqueList.add(schoolId.toString()); + List uniqueList = new ArrayList<>(); + uniqueList.add(schoolId); List sList = new ArrayList<>(); List nonList = new ArrayList<>(); @@ -2021,13 +2021,13 @@ public void testCreateAndStoreSchoolReports() { when(this.restService.get(any(), any())).thenReturn(1); - Mockito.when(gradStatusService.getStudentListByMinCode(schoolId.toString())).thenReturn(sList); - Mockito.when(schoolService.getSchoolDetails(schoolId.toString())).thenReturn(List.of(sTrax)); + Mockito.when(gradStatusService.getStudentListBySchoolId(schoolId)).thenReturn(sList); + Mockito.when(schoolService.getSchoolDetails(schoolId)).thenReturn(sTrax); int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG"); assertEquals(2,numberOfRecord); - Mockito.when(gradStatusService.getStudentListByMinCode(schoolId.toString())).thenReturn(List.of()); + Mockito.when(gradStatusService.getStudentListBySchoolId(schoolId)).thenReturn(List.of()); numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG"); assertEquals(0,numberOfRecord); } @@ -2099,9 +2099,9 @@ public void testCreateAndStoreStudentCertificates() { @Test public void testGetSchoolReports() { ExceptionMessage exception = new ExceptionMessage(); - String mincode = "1231231231"; - List uniqueList = new ArrayList<>(); - uniqueList.add(mincode); + UUID schoolId = UUID.randomUUID(); + List uniqueList = new ArrayList<>(); + uniqueList.add(schoolId); List sList = new ArrayList<>(); List nonList = new ArrayList<>(); @@ -2176,7 +2176,7 @@ public void testGetSchoolReports() { when(this.restService.post(any(String.class), any(), any(), any())).thenReturn(bytesSAR1); when(this.restService.post(any(String.class), any(), any())).thenReturn(bytesSAR1); - when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); + when(gradStatusService.getStudentListBySchoolId(schoolId)).thenReturn(sList); when(schoolService.getSchoolClob(sTrax.getSchoolId())).thenReturn(sTrax); byte[] result = graduationService.getSchoolReports(uniqueList,"GRADREG"); @@ -2190,9 +2190,9 @@ public void testGetSchoolReports() { @Test public void testGetSchoolReportsException() { ExceptionMessage exception = new ExceptionMessage(); - String mincode = "1231231231"; - List uniqueList = new ArrayList<>(); - uniqueList.add(mincode); + UUID schoolId = UUID.randomUUID(); + List uniqueList = new ArrayList<>(); + uniqueList.add(schoolId); byte[] result = graduationService.getSchoolReports(uniqueList,"GRADREG"); assertNotNull(result); @@ -2204,8 +2204,8 @@ public void testCreateAndStoreSchoolReports_TVR() { ExceptionMessage exception = new ExceptionMessage(); UUID schoolId = UUID.randomUUID(); String mincode = "1231231231"; - List uniqueList = new ArrayList<>(); - uniqueList.add(schoolId.toString()); + List uniqueList = new ArrayList<>(); + uniqueList.add(schoolId); List sList = new ArrayList<>(); List nonList = new ArrayList<>(); @@ -2248,8 +2248,8 @@ public void testCreateAndStoreSchoolReports_TVR() { when(this.restService.get(any(), any())).thenReturn(1); - Mockito.when(gradStatusService.getStudentListByMinCode(schoolId.toString())).thenReturn(sList); - Mockito.when(schoolService.getSchoolDetails(schoolId.toString())).thenReturn(List.of(sTrax)); + Mockito.when(gradStatusService.getStudentListBySchoolId(schoolId)).thenReturn(sList); + Mockito.when(schoolService.getSchoolDetails(schoolId)).thenReturn(sTrax); int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"TVRRUN"); assertEquals(1,numberOfRecord); diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchoolServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchoolServiceTest.java index 14d319fc..e6e0ae38 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchoolServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchoolServiceTest.java @@ -71,7 +71,7 @@ public void tearDown() { } @Test - public void testGetSchoolDetails() { + public void testGetSchoolClob() { UUID schoolId = UUID.randomUUID(); String mincode = "213123131"; School schtrax = new School(); @@ -86,6 +86,21 @@ public void testGetSchoolDetails() { assertEquals(res.getMinCode(), mincode); } + @Test + public void testGetSchoolDetails() { + UUID schoolId = UUID.randomUUID(); + String mincode = "213123131"; + ca.bc.gov.educ.api.graduation.model.dto.institute.School school = new ca.bc.gov.educ.api.graduation.model.dto.institute.School (); + school.setSchoolId(schoolId.toString()); + school.setMincode(mincode); + when(this.restService.get(any(String.class), any())).thenReturn(school); + ca.bc.gov.educ.api.graduation.model.dto.institute.School res = schoolService.getSchoolDetails(schoolId); + + assertNotNull(res); + assertEquals(res.getSchoolId(),schoolId.toString()); + assertEquals(res.getMincode(), mincode); + } + @Test public void testGetSchoolDetailsNoToken() { UUID schoolId = UUID.randomUUID(); diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 594e89fe..d32744e1 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -142,8 +142,8 @@ endpoint: by-pen: url: https://student-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/student?pen=%s grad-trax-api: - search-schools-by-min-code: - url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/school/search?mincode=%s + school-detail-by-school-id: + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/school/%s school-clob-by-school-id: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/school-clob/%s district-by-min-code: