From 397cece5d5c159e4cf6765e4a5bd89558cd7c959 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Wed, 20 Nov 2024 14:44:01 -0800 Subject: [PATCH] GRAD2-2761: replaced minCode with schoolId for School v2 endpoint & schoolAtGradId is added in. GRAD2-2761: replaced minCode with schoolId for School v2 endpoint & schoolAtGradId is added in. --- .../GradAlgorithmGraduationStudentRecord.java | 1 + .../model/dto/GradSearchStudent.java | 1 + .../model/dto/GraduationStudentRecord.java | 1 + .../model/dto/ReportGradStudentData.java | 2 + .../educ/api/graduation/model/dto/School.java | 4 +- .../model/dto/institute/School.java | 34 +++ .../api/graduation/model/report/School.java | 9 + .../graduation/process/AlgorithmSupport.java | 4 +- .../graduation/service/GraduationService.java | 22 +- .../api/graduation/service/ReportService.java | 32 ++- .../service/SchoolReportsService.java | 55 +++-- .../api/graduation/service/SchoolService.java | 26 +- .../util/EducGraduationApiConstants.java | 5 +- api/src/main/resources/application.yaml | 7 +- .../service/GraduationServiceTest.java | 31 +-- .../graduation/service/ReportServiceTest.java | 224 ++++++++++++------ .../service/SchooReportsServiceTest.java | 4 +- .../graduation/service/SchoolServiceTest.java | 14 +- api/src/test/resources/application.yaml | 6 +- api/src/test/resources/json/gradstatus.json | 6 +- 20 files changed, 332 insertions(+), 156 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/institute/School.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradAlgorithmGraduationStudentRecord.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradAlgorithmGraduationStudentRecord.java index 1f41f26b..a93d0b4f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradAlgorithmGraduationStudentRecord.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradAlgorithmGraduationStudentRecord.java @@ -28,6 +28,7 @@ public class GradAlgorithmGraduationStudentRecord { private String studentCitizenship; private UUID studentID; private String schoolAtGrad; + private UUID schoolAtGradId; private String consumerEducationRequirementMet; private String schoolAtGradName; @JsonFormat(pattern=DEFAULT_DATE_FORMAT) diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradSearchStudent.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradSearchStudent.java index 3167edd9..2c3a844a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradSearchStudent.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GradSearchStudent.java @@ -37,6 +37,7 @@ public class GradSearchStudent { private String trueStudentID; private String program; private String schoolOfRecord; + private String schoolOfRecordId; private String schoolOfRecordName; private String schoolOfRecordindependentAffiliation; private String studentGrade; diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GraduationStudentRecord.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GraduationStudentRecord.java index dbf0cc2e..e7c1d3a1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GraduationStudentRecord.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/GraduationStudentRecord.java @@ -35,6 +35,7 @@ public class GraduationStudentRecord extends BaseModel { private String studentStatusName; private UUID studentID; private String schoolAtGrad; + private UUID schoolAtGradId; private String schoolAtGradName; private String legalFirstName; private String legalMiddleNames; diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/ReportGradStudentData.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/ReportGradStudentData.java index d3c0b75b..317db842 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/ReportGradStudentData.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/ReportGradStudentData.java @@ -16,6 +16,8 @@ public class ReportGradStudentData implements Serializable { private UUID graduationStudentRecordId; private String mincode; private String mincodeAtGrad; + private String schoolOfRecordId; + private String schoolAtGradId; private String pen; private String firstName; private String middleName; diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/School.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/School.java index 6dc4d605..ae842c0e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/School.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/School.java @@ -21,7 +21,7 @@ public class School { private String postal; private String openFlag; private String schoolCategoryCode; - private String schoolCategoryCodeInstitute; + private String schoolCategoryLegacyCode; public String getSchoolName() { return schoolName != null ? schoolName.trim(): null; @@ -53,7 +53,7 @@ public String getOpenFlag() { @Override public String toString() { - return "School [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolCategoryCodeInstitute=" + schoolCategoryCodeInstitute + return "School [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolCategoryLegacyCode=" + schoolCategoryLegacyCode + ", schoolName=" + schoolName + ", districtName=" + districtName + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" + certificateEligibility + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" + provCode + ", countryCode=" + countryCode + ", postal=" + postal + ", openFlag=" + openFlag + "]"; diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/institute/School.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/institute/School.java new file mode 100644 index 00000000..199eef3c --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/institute/School.java @@ -0,0 +1,34 @@ +package ca.bc.gov.educ.api.graduation.model.dto.institute; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.stereotype.Component; + +@Data +@EqualsAndHashCode +@Component("instituteSchool") +@JsonIgnoreProperties(ignoreUnknown = true) +public class School { + + private String schoolId; + private String districtId; + private String mincode; + private String independentAuthorityId; + private String schoolNumber; + private String faxNumber; + private String phoneNumber; + private String email; + private String website; + private String displayName; + private String displayNameNoSpecialChars; + private String schoolReportingRequirementCode; + private String schoolOrganizationCode; + private String schoolCategoryCode; + private String facilityTypeCode; + private String openedDate; + private String closedDate; + private boolean canIssueTranscripts; + private boolean canIssueCertificates; + +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/School.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/School.java index d600fc42..2e62ac0e 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/School.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/report/School.java @@ -11,6 +11,7 @@ public class School implements Serializable { private static final long serialVersionUID = 2L; + private String schoolId; private String mincode; private String name; private String typeIndicator; @@ -27,6 +28,14 @@ public class School implements Serializable { private List students; + public String getSchoolId() { + return schoolId; + } + + public void setSchoolId(String value) { + this.schoolId = value; + } + public String getMincode() { return mincode; } diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/process/AlgorithmSupport.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/process/AlgorithmSupport.java index 991d1b77..f11acce1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/process/AlgorithmSupport.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/process/AlgorithmSupport.java @@ -61,7 +61,7 @@ public ExceptionMessage createStudentCertificateTranscriptReports(GraduationData } if(createCertificate) { reportService.saveStudentCertificateReportJasper(graduationStatusResponse, graduationDataStatus, certType, false); - graduationDataStatus.getSchool().setSchoolCategoryCode(certType.getSchoolCategoryCode()); + graduationDataStatus.getSchool().setSchoolCategoryLegacyCode(certType.getSchoolCategoryCode()); graduationDataStatus.getStudentCertificatesTranscript().addCertificateType(GradCertificateType.builder() .code(certType.getCertificateTypeCode()) .description(certType.getCertificateTypeLabel()) @@ -69,7 +69,7 @@ public ExceptionMessage createStudentCertificateTranscriptReports(GraduationData } } else { reportService.saveStudentCertificateReportJasper(graduationStatusResponse, graduationDataStatus, certType, false); - graduationDataStatus.getSchool().setSchoolCategoryCode(certType.getSchoolCategoryCode()); + graduationDataStatus.getSchool().setSchoolCategoryLegacyCode(certType.getSchoolCategoryCode()); graduationDataStatus.getStudentCertificatesTranscript().addCertificateType(GradCertificateType.builder() .code(certType.getCertificateTypeCode()) .description(certType.getCertificateTypeLabel()) 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 4e52c012..26c3b838 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 @@ -196,11 +196,13 @@ public byte[] getSchoolReports(List uniqueSchoolList, String type) { for (String usl : uniqueSchoolList) { try { List stdList = gradStatusService.getStudentListByMinCode(usl); - ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(usl); - if (schoolDetails != null) { + List schoolDetails = schoolService.getSchoolDetails(usl); + if (schoolDetails != null && !schoolDetails.isEmpty()) { + ca.bc.gov.educ.api.graduation.model.dto.institute.School schoolDetail = schoolDetails.get(0); School schoolObj = new School(); - schoolObj.setMincode(schoolDetails.getMinCode()); - schoolObj.setName(schoolDetails.getSchoolName()); + schoolObj.setSchoolId(schoolDetail.getSchoolId()); + schoolObj.setMincode(schoolDetail.getMincode()); + schoolObj.setName(schoolDetail.getDisplayName()); ReportData gradReport; switch (type) { case GRADREG: @@ -236,13 +238,15 @@ public Integer createAndStoreSchoolReports(List uniqueSchoolList, String String listOfStudents = jsonTransformer.marshall(stdList); logger.debug("*** Student List of {} Acquired {}", totalStudents, listOfStudents); } - ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(usl); - if (schoolDetails != null) { - logger.debug("*** School Details Acquired {}", schoolDetails.getSchoolName()); + List schoolDetails = schoolService.getSchoolDetails(usl); + if (schoolDetails != null && !schoolDetails.isEmpty()) { + ca.bc.gov.educ.api.graduation.model.dto.institute.School schoolDetail = schoolDetails.get(0); + logger.debug("*** School Details Acquired {}", schoolDetail.getDisplayName()); if (stdList != null && !stdList.isEmpty()) { School schoolObj = new School(); - schoolObj.setMincode(schoolDetails.getMinCode()); - schoolObj.setName(schoolDetails.getSchoolName()); + schoolObj.setSchoolId(schoolDetail.getSchoolId()); + schoolObj.setMincode(schoolDetail.getMincode()); + schoolObj.setName(schoolDetail.getDisplayName()); if (TVRRUN.equalsIgnoreCase(type)) { List nonGradPrjStudents = processStudentList(filterStudentList(stdList, NONGRADPRJ), type); logger.debug("*** Process processStudentNonGradPrjReport {} for {} students", schoolObj.getMincode(), nonGradPrjStudents.size()); 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 f5113ac6..987324e1 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 @@ -53,8 +53,8 @@ public ReportService(JsonTransformer jsonTransformer, EducGraduationApiConstants public ProgramCertificateTranscript getTranscript(GraduationStudentRecord gradResponse, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, ExceptionMessage exception) { ProgramCertificateReq req = new ProgramCertificateReq(); req.setProgramCode(gradResponse.getProgram()); - req.setSchoolCategoryCode(StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolCategoryCode())? - getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecord()) : graduationDataStatus.getSchool().getSchoolCategoryCode()); + req.setSchoolCategoryCode(StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolCategoryLegacyCode())? + getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecordId()) : graduationDataStatus.getSchool().getSchoolCategoryLegacyCode()); try { return restService.post(educGraduationApiConstants.getTranscript(), req, ProgramCertificateTranscript.class); } catch (Exception e) { @@ -72,8 +72,8 @@ public List getCertificateList(GraduationStudentRe req.setOptionalProgram(optionalPrograms.getOptionalProgramCode()); } } - req.setSchoolCategoryCode(StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolCategoryCode())? - getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecord()) : graduationDataStatus.getSchool().getSchoolCategoryCode()); + req.setSchoolCategoryCode(StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolCategoryLegacyCode())? + getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecordId()) : graduationDataStatus.getSchool().getSchoolCategoryLegacyCode()); try { var response = restService.post(educGraduationApiConstants.getCertList(), req, List.class); return jsonTransformer.convertValue(response, new TypeReference>() {}); @@ -84,9 +84,10 @@ public List getCertificateList(GraduationStudentRe } } - public String getSchoolCategoryCode(String mincode) { - ca.bc.gov.educ.api.graduation.model.dto.School school = this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(), mincode), ca.bc.gov.educ.api.graduation.model.dto.School.class); - return (school == null) ? null : school.getSchoolCategoryCode(); + public String getSchoolCategoryCode(UUID schoolId) { + if (schoolId == null) return null; + ca.bc.gov.educ.api.graduation.model.dto.School school = this.restService.get(String.format(educGraduationApiConstants.getSchoolClobBySchoolIdUrl(), schoolId), ca.bc.gov.educ.api.graduation.model.dto.School.class); + return (school == null) ? null : school.getSchoolCategoryLegacyCode(); } public List getStudentsForSchoolYearEndReport(String accessToken) { @@ -120,6 +121,12 @@ public List getStudentsForSchoolReport() { public ReportData prepareTranscriptData(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, GraduationStudentRecord gradResponse, boolean xml, ExceptionMessage exception) { try { + ca.bc.gov.educ.api.graduation.model.dto.School schoolClob = graduationDataStatus.getSchool(); + if (schoolClob == null || StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolId())) { + schoolClob = schoolService.getSchoolClob(gradResponse.getSchoolOfRecordId()); + graduationDataStatus.setSchool(schoolClob); + } + School schoolAtGrad = getSchoolAtGradData(graduationDataStatus); School schoolOfRecord = getSchoolData(graduationDataStatus.getSchool()); //--> Revert code back to school of record GRAD2-2758 @@ -129,7 +136,6 @@ public ReportData prepareTranscriptData(ca.bc.gov.educ.api.graduation.model.dto. String mincode = schoolAtGrad.getMincode(); traxSchool = schoolService.getTraxSchoolDetails(mincode, exception); } **/ - ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(schoolOfRecord.getMincode()); //<-- GraduationStatus graduationStatus = getGraduationStatus(graduationDataStatus, schoolAtGrad, schoolOfRecord); GraduationData graduationData = getGraduationData(graduationDataStatus, gradResponse); @@ -146,7 +152,7 @@ public ReportData prepareTranscriptData(ca.bc.gov.educ.api.graduation.model.dto. data.setTranscript(getTranscriptData(graduationDataStatus, gradResponse, xml, exception)); data.setNonGradReasons(isGraduated(gradResponse.getProgramCompletionDate(), graduationDataStatus.getGradStatus().getProgram()) ? new ArrayList<>() : getNonGradReasons(data.getGradProgram().getCode().getCode(), graduationDataStatus.getNonGradReasons(), xml, true)); data.setIssueDate(EducGraduationApiUtils.formatIssueDateForReportJasper(new java.sql.Date(System.currentTimeMillis()).toString())); - if(schoolDetails != null && !"N".equalsIgnoreCase(schoolDetails.getCertificateEligibility())) { + if(schoolClob != null && !"N".equalsIgnoreCase(schoolClob.getCertificateEligibility())) { if ("SCCP".equalsIgnoreCase(data.getGradProgram().getCode().getCode())) { data.getStudent().setSccDate(graduationStatus.getProgramCompletionDate()); } @@ -712,8 +718,8 @@ private Student getStudentData(GradSearchStudent gradStudent, GraduationStudentR } private School getSchoolAtGradData(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus) { - if (graduationDataStatus.getGradStatus() != null && !StringUtils.isBlank(graduationDataStatus.getGradStatus().getSchoolAtGrad())) { - ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(graduationDataStatus.getGradStatus().getSchoolAtGrad()); + if (graduationDataStatus.getGradStatus() != null && graduationDataStatus.getGradStatus().getSchoolAtGradId() != null) { + ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolClob(graduationDataStatus.getGradStatus().getSchoolAtGradId()); if (schoolDetails != null) { return getSchoolData(schoolDetails); } @@ -730,9 +736,11 @@ private School getSchoolData(ca.bc.gov.educ.api.graduation.model.dto.School scho addRess.setRegion(school.getProvCode()); addRess.setStreetLine1(school.getAddress1()); addRess.setStreetLine2(school.getAddress2()); - schObj.setTypeIndicator("02".equalsIgnoreCase(school.getSchoolCategoryCode())? "02" : ""); + schObj.setTypeIndicator("02".equalsIgnoreCase(school.getSchoolCategoryLegacyCode())? "02" : ""); schObj.setAddress(addRess); + schObj.setSchoolId(school.getSchoolId()); schObj.setMincode(school.getMinCode()); + schObj.setSchoolCategoryCode(school.getSchoolCategoryLegacyCode()); schObj.setName(school.getSchoolName()); schObj.setSignatureCode(school.getMinCode().substring(0, 3)); schObj.setDistno(school.getMinCode().substring(0, 3)); diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java index 51d7bfb3..f1cf192f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolReportsService.java @@ -333,14 +333,13 @@ private Integer createAndStoreDistrictReports(String reportType, List> districtSchoolsMap = new HashMap<>(); for (ReportGradStudentData reportGradStudentData : reportGradStudentDataList) { - String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad(); - String districtCode = StringUtils.substring(mincode, 0, 3); - String schoolCategoryCode = reportService.getSchoolCategoryCode(mincode); - if(!StringUtils.equalsAnyIgnoreCase(schoolCategoryCode, "02")) { + String schoolId = StringUtils.isBlank(reportGradStudentData.getSchoolAtGradId()) ? reportGradStudentData.getSchoolOfRecordId() : reportGradStudentData.getSchoolAtGradId(); + String schoolCategoryLegacyCode = reportService.getSchoolCategoryCode(StringUtils.isNotBlank(schoolId)? UUID.fromString(schoolId) : null); + if(!StringUtils.equalsAnyIgnoreCase(schoolCategoryLegacyCode, "02")) { School district = populateDistrictObjectByReportGradStudentData(districtSchoolsMap, reportGradStudentData); processDistrictSchoolMap(districtSchoolsMap.get(district), reportGradStudentData); } else { - logger.debug("Skip {} independent school {} for district {}", schoolCategoryCode, mincode, districtCode); + logger.debug("Skip {} independent school {} for district {}", schoolCategoryLegacyCode, schoolId, reportGradStudentData.getDistrictName()); } } for (var entry : districtSchoolsMap.entrySet()) { @@ -422,6 +421,7 @@ private ReportRequest buildSchoolYearEndReportRequest(School school) { reportRequest.setOptions(reportOptions); ReportData headerData = new ReportData(); School headerSchool = new School(); + headerSchool.setSchoolId(school.getSchoolId()); headerSchool.setMincode(school.getMincode()); headerSchool.setName(school.getName()); headerData.setSchool(headerSchool); @@ -469,6 +469,7 @@ private School populateDistrictObjectByReportGradStudentData(Map Revert code back to school of record GRAD2-2758 /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ + String schoolId = reportGradStudentData.getSchoolOfRecordId(); String mincode = reportGradStudentData.getMincode(); //<-- String distcode = StringUtils.substring(mincode, 0, 3); @@ -484,6 +485,7 @@ private School populateDistrictObjectByReportGradStudentData(Map Revert code back to school of record GRAD2-2758 - /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ - String mincode = reportGradStudentData.getMincode(); - //<-- - ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(mincode); + /** String schoolId = reportGradStudentData.getSchoolAtGradId() == null? reportGradStudentData.getSchoolOfRecordId() : reportGradStudentData.getSchoolAtGradId();**/ + String schoolId = reportGradStudentData.getSchoolOfRecordId(); School school = new School(); school.setStudents(new ArrayList<>()); - if(schoolDetails != null) { - school.setDistno(StringUtils.substring(schoolDetails.getMinCode(), 0, 3)); - school.setMincode(schoolDetails.getMinCode()); - school.setName(schoolDetails.getSchoolName()); + + ca.bc.gov.educ.api.graduation.model.dto.School schoolClob = schoolService.getSchoolClob(schoolId); + if (schoolClob != null) { + school.setDistno(StringUtils.substring(schoolClob.getMinCode(), 0, 3)); + school.setSchoolId(schoolId); + school.setMincode(schoolClob.getMinCode()); + school.setName(schoolClob.getSchoolName()); school.setTypeBanner("Principal"); Address address = new Address(); - address.setStreetLine1(schoolDetails.getAddress1()); - address.setStreetLine2(schoolDetails.getAddress2()); - address.setCity(schoolDetails.getCity()); - address.setRegion(schoolDetails.getProvCode()); - address.setCountry(schoolDetails.getCountryCode()); - address.setCode(schoolDetails.getPostal()); + address.setStreetLine1(schoolClob.getAddress1()); + address.setStreetLine2(schoolClob.getAddress2()); + address.setCity(schoolClob.getCity()); + address.setRegion(schoolClob.getProvCode()); + address.setCountry(schoolClob.getCountryCode()); + address.setCode(schoolClob.getPostal()); school.setAddress(address); return school; } @@ -520,13 +523,13 @@ private School populateSchoolObjectByReportGradStudentData(ReportGradStudentData private School populateSchoolObjectByReportGradStudentData(Map schoolMap, ReportGradStudentData reportGradStudentData) { //--> Revert code back to school of record GRAD2-2758 - /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ - String mincode = reportGradStudentData.getMincode(); + /** String schoolId = reportGradStudentData.getSchoolAtGradId() == null? reportGradStudentData.getSchoolOfRecordId() : reportGradStudentData.getSchoolAtGradId();**/ + String schoolId = reportGradStudentData.getSchoolOfRecordId(); //<-- - School school = schoolMap.get(mincode); + School school = schoolMap.get(schoolId); if (school == null) { school = populateSchoolObjectByReportGradStudentData(reportGradStudentData); - schoolMap.put(mincode, school); + schoolMap.put(schoolId, school); } return school; } @@ -534,7 +537,8 @@ private School populateSchoolObjectByReportGradStudentData(Map s private void processDistrictSchoolMap(List schools, ReportGradStudentData reportGradStudentData) { boolean addNewSchool = true; //--> Revert code back to school of record GRAD2-2758 - /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ + /** String schoolId = reportGradStudentData.getSchoolAtGradId() == null? reportGradStudentData.getSchoolOfRecordId() : reportGradStudentData.getSchoolAtGradId();**/ + String schoolId = reportGradStudentData.getSchoolOfRecordId(); String mincode = reportGradStudentData.getMincode(); //<-- String distNo = StringUtils.substring(mincode, 0, 3); @@ -545,8 +549,9 @@ private void processDistrictSchoolMap(List schools, ReportGradStudentDat } } if (addNewSchool) { - ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(mincode); + ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolClob(schoolId); School school = new School(); + school.setSchoolId(schoolId); school.setDistno(distNo); school.setMincode(mincode); school.setName(schoolDetails != null ? schoolDetails.getSchoolName() : reportGradStudentData.getSchoolName()); 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 2bd1c6cd..ea7c6454 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 @@ -2,21 +2,41 @@ import ca.bc.gov.educ.api.graduation.model.dto.*; import ca.bc.gov.educ.api.graduation.util.EducGraduationApiConstants; +import ca.bc.gov.educ.api.graduation.util.JsonTransformer; +import com.fasterxml.jackson.core.type.TypeReference; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.UUID; + @Service public class SchoolService { EducGraduationApiConstants educGraduationApiConstants; RESTService restService; + + JsonTransformer jsonTransformer; @Autowired - public SchoolService(EducGraduationApiConstants educGraduationApiConstants, RESTService restService) { + public SchoolService(EducGraduationApiConstants educGraduationApiConstants, RESTService restService, JsonTransformer jsonTransformer) { this.educGraduationApiConstants = educGraduationApiConstants; this.restService = restService; + 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 School getSchoolClob(String schoolId) { + if (StringUtils.isBlank(schoolId)) return null; + return getSchoolClob(UUID.fromString(schoolId)); } - public School getSchoolDetails(String mincode) { - return this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),mincode), + public School getSchoolClob(UUID schoolId) { + if (schoolId == null) return null; + return this.restService.get(String.format(educGraduationApiConstants.getSchoolClobBySchoolIdUrl(),schoolId), School.class); } 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 6a0df1fe..82f7d8ae 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 @@ -161,7 +161,10 @@ public class EducGraduationApiConstants { @Value("${endpoint.pen-student-api.by-pen.url}") private String penStudentApiByPenUrl; - @Value("${endpoint.grad-trax-api.school-by-min-code.url}") + @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}") 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 8268f243..81f2468f 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -142,12 +142,13 @@ endpoint: by-pen: url: ${PEN_API}api/v1/student?pen=%s - grad-trax-api: - school-by-min-code: + search-schools-by-min-code: + url: ${GRAD_TRAX_API}api/v2/trax/school/search?mincode=%s + school-clob-by-school-id: url: ${GRAD_TRAX_API}api/v2/trax/school-clob/%s district-by-min-code: - url: ${GRAD_TRAX_API}api/v2/trax/district/%s + url: ${GRAD_TRAX_API}api/v2/trax/district?distNo=%s #Splunk LogHelper splunk: 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 1a597d83..6606cd0d 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 @@ -1944,9 +1944,10 @@ public void testcreateReportNCert2() { @Test public void testCreateAndStoreSchoolReports() { ExceptionMessage exception = new ExceptionMessage(); + UUID schoolId = UUID.randomUUID(); String mincode = "1231231231"; List uniqueList = new ArrayList<>(); - uniqueList.add(mincode); + uniqueList.add(schoolId.toString()); List sList = new ArrayList<>(); List nonList = new ArrayList<>(); @@ -1991,9 +1992,9 @@ public void testCreateAndStoreSchoolReports() { sList.add(gsr); - School sTrax = new School(); - sTrax.setAddress1("!23123"); - sTrax.setMinCode("1231231231"); + ca.bc.gov.educ.api.graduation.model.dto.institute.School sTrax = new ca.bc.gov.educ.api.graduation.model.dto.institute.School(); + sTrax.setSchoolId(schoolId.toString()); + sTrax.setMincode("1231231231"); byte[] bytesSAR1 = "Any String you want".getBytes(); @@ -2020,13 +2021,13 @@ public void testCreateAndStoreSchoolReports() { when(this.restService.get(any(), any())).thenReturn(1); - Mockito.when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); - Mockito.when(schoolService.getSchoolDetails(mincode)).thenReturn(sTrax); + Mockito.when(gradStatusService.getStudentListByMinCode(schoolId.toString())).thenReturn(sList); + Mockito.when(schoolService.getSchoolDetails(schoolId.toString())).thenReturn(List.of(sTrax)); int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG"); assertEquals(2,numberOfRecord); - Mockito.when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(List.of()); + Mockito.when(gradStatusService.getStudentListByMinCode(schoolId.toString())).thenReturn(List.of()); numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG"); assertEquals(0,numberOfRecord); } @@ -2146,6 +2147,7 @@ public void testGetSchoolReports() { sList.add(gsr); School sTrax = new School(); + sTrax.setSchoolId(UUID.randomUUID().toString()); sTrax.setAddress1("!23123"); sTrax.setMinCode("1231231231"); @@ -2175,7 +2177,7 @@ public void testGetSchoolReports() { when(this.restService.post(any(String.class), any(), any())).thenReturn(bytesSAR1); when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); - when(schoolService.getSchoolDetails(mincode)).thenReturn(sTrax); + when(schoolService.getSchoolClob(sTrax.getSchoolId())).thenReturn(sTrax); byte[] result = graduationService.getSchoolReports(uniqueList,"GRADREG"); assertNotNull(result); @@ -2200,9 +2202,10 @@ public void testGetSchoolReportsException() { @Test public void testCreateAndStoreSchoolReports_TVR() { ExceptionMessage exception = new ExceptionMessage(); + UUID schoolId = UUID.randomUUID(); String mincode = "1231231231"; List uniqueList = new ArrayList<>(); - uniqueList.add(mincode); + uniqueList.add(schoolId.toString()); List sList = new ArrayList<>(); List nonList = new ArrayList<>(); @@ -2227,9 +2230,9 @@ public void testCreateAndStoreSchoolReports_TVR() { } sList.add(gsr); - School sTrax = new School(); - sTrax.setAddress1("!23123"); - sTrax.setMinCode("1231231231"); + ca.bc.gov.educ.api.graduation.model.dto.institute.School sTrax = new ca.bc.gov.educ.api.graduation.model.dto.institute.School(); + sTrax.setSchoolId(schoolId.toString()); + sTrax.setMincode(mincode); byte[] bytesSAR = "Any String you want".getBytes(); @@ -2245,8 +2248,8 @@ public void testCreateAndStoreSchoolReports_TVR() { when(this.restService.get(any(), any())).thenReturn(1); - Mockito.when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); - Mockito.when(schoolService.getSchoolDetails(mincode)).thenReturn(sTrax); + Mockito.when(gradStatusService.getStudentListByMinCode(schoolId.toString())).thenReturn(sList); + Mockito.when(schoolService.getSchoolDetails(schoolId.toString())).thenReturn(List.of(sTrax)); int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"TVRRUN"); assertEquals(1,numberOfRecord); diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/ReportServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/ReportServiceTest.java index 0072115c..45937b88 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/ReportServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/ReportServiceTest.java @@ -227,6 +227,7 @@ public void testSaveStudentCertificateReport() { @Test public void testSaveStudentTranscriptReport() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; String pen="212321123"; boolean isGraduated= false; @@ -243,10 +244,12 @@ public void testSaveStudentTranscriptReport() { byte[] bytesSAR = RandomUtils.nextBytes(20); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getTranscriptReport()), any(), eq(byte[].class))).thenReturn(bytesSAR); when(this.restService.post(eq(String.format(constants.getUpdateGradStudentTranscript(),isGraduated)), any(), eq(GradStudentReports.class))).thenReturn(rep); @@ -258,12 +261,14 @@ public void testSaveStudentTranscriptReport() { @Test public void testGetCertificateList_whenAPIisDown_throwsException() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); gradResponse.setProgramCompletionDate(null); gradResponse.setSchoolOfRecord("06011033"); + gradResponse.setSchoolOfRecordId(UUID.fromString(schoolId)); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); @@ -272,12 +277,13 @@ public void testGetCertificateList_whenAPIisDown_throwsException() { gradAlgorithmGraduationStatus.setProgram("2018-EN"); gradAlgorithmGraduationStatus.setProgramCompletionDate(null); gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); + gradAlgorithmGraduationStatus.setSchoolOfRecordId(UUID.fromString(schoolId)); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); - schoolObj.setSchoolId(UUID.randomUUID().toString()); GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); @@ -297,11 +303,12 @@ public void testGetCertificateList_whenAPIisDown_throwsException() { list.add(spgm); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); - - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenThrow(new RuntimeException("Test - API is down")); @@ -315,6 +322,7 @@ public void testGetCertificateList_whenAPIisDown_throwsException() { @Test public void testGetCertificateList() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); @@ -333,8 +341,8 @@ public void testGetCertificateList() { gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); - schoolObj.setSchoolId(UUID.randomUUID().toString()); GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); @@ -362,9 +370,10 @@ public void testGetCertificateList() { School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); @@ -375,12 +384,14 @@ public void testGetCertificateList() { @Test public void testGetCertificateList_PFProgram() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-PF"); gradResponse.setProgramCompletionDate(null); gradResponse.setSchoolOfRecord("06011033"); + gradResponse.setSchoolOfRecordId(UUID.fromString(schoolId)); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); @@ -389,12 +400,13 @@ public void testGetCertificateList_PFProgram() { gradAlgorithmGraduationStatus.setProgram("2018-EN"); gradAlgorithmGraduationStatus.setProgramCompletionDate(null); gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); + gradAlgorithmGraduationStatus.setSchoolOfRecordId(UUID.fromString(schoolId)); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); - schoolObj.setSchoolId(UUID.randomUUID().toString()); GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setGradMessage("Not Graduated"); @@ -423,9 +435,10 @@ public void testGetCertificateList_PFProgram() { School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); List listCC = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); @@ -434,12 +447,14 @@ public void testGetCertificateList_PFProgram() { @Test public void testGetCertificateList_PFProgram_nodogwood() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-PF"); gradResponse.setProgramCompletionDate(null); gradResponse.setSchoolOfRecord("06011033"); + gradResponse.setSchoolOfRecordId(UUID.fromString(schoolId)); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); @@ -452,8 +467,8 @@ public void testGetCertificateList_PFProgram_nodogwood() { gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); - schoolObj.setSchoolId(UUID.randomUUID().toString()); GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); @@ -474,9 +489,10 @@ public void testGetCertificateList_PFProgram_nodogwood() { School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); @@ -493,6 +509,7 @@ public void testGetCertificateList_PFProgram_nodogwood() { @Test public void testGetCertificateList_emptyOptionalProgram() { UUID studentID = new UUID(1, 1); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setStudentID(studentID); @@ -500,15 +517,16 @@ public void testGetCertificateList_emptyOptionalProgram() { gradResponse.setProgram("2018-EN"); gradResponse.setProgramCompletionDate(null); gradResponse.setSchoolOfRecord("06011033"); + gradResponse.setSchoolOfRecordId(UUID.fromString(schoolId)); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); - - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); @@ -519,8 +537,8 @@ public void testGetCertificateList_emptyOptionalProgram() { gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); - schoolObj.setSchoolId(UUID.randomUUID().toString()); GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); @@ -546,12 +564,14 @@ public void testGetCertificateList_emptyOptionalProgram() { @Test public void testGetCertificateList_FrenchImmersion() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); gradResponse.setProgramCompletionDate(null); gradResponse.setSchoolOfRecord("06011033"); + gradResponse.setSchoolOfRecordId(UUID.fromString(schoolId)); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); @@ -564,6 +584,7 @@ public void testGetCertificateList_FrenchImmersion() { gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); schoolObj.setSchoolId(UUID.randomUUID().toString()); @@ -586,9 +607,10 @@ public void testGetCertificateList_FrenchImmersion() { School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); StudentOptionalProgram spgm = new StudentOptionalProgram(); spgm.setPen("123090109"); @@ -606,12 +628,14 @@ public void testGetCertificateList_FrenchImmersion() { @Test public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); gradResponse.setProgramCompletionDate(null); gradResponse.setSchoolOfRecord("06011033"); + gradResponse.setSchoolOfRecordId(UUID.fromString(schoolId)); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); @@ -620,10 +644,12 @@ public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { gradAlgorithmGraduationStatus.setProgram("2018-EN"); gradAlgorithmGraduationStatus.setProgramCompletionDate(null); gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); + gradAlgorithmGraduationStatus.setSchoolOfRecordId(UUID.fromString(schoolId)); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); schoolObj.setSchoolId(UUID.randomUUID().toString()); @@ -655,9 +681,10 @@ public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); List listCC = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); @@ -736,9 +763,10 @@ public void testPrepareReportData() { School schoolDetails = new School(); schoolDetails.setMinCode("1123"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), "06011033"), School.class)).thenReturn(schoolDetails); GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); @@ -900,9 +928,10 @@ public void testPrepareReportData_nullProgramData() { School schoolDetails = new School(); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); @@ -979,9 +1008,10 @@ public void testPrepareReportData_exams_notnull(String program,String accessToke School schoolDetails = new School(); schoolDetails.setMinCode("06011033"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); @@ -1072,9 +1102,10 @@ public void testPrepareReportData_Desig_3() { School schoolDetails = new School(); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); @@ -1166,9 +1197,10 @@ public void testPrepareReportData_Desig_4() { School schoolDetails = new School(); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); @@ -1193,6 +1225,7 @@ public void testPrepareReportData_Desig_4() { public void testPrepareReportData_Desig_2() { String accessToken = "accessToken"; + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -1202,6 +1235,7 @@ public void testPrepareReportData_Desig_2() { gradAlgorithmGraduationStatus.setStudentStatus("A"); School schoolObj = new School(); + schoolObj.setSchoolId(schoolId); schoolObj.setMinCode("09323027"); schoolObj.setSchoolId(UUID.randomUUID().toString()); @@ -1239,7 +1273,8 @@ public void testPrepareReportData_Desig_2() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); graduationDataStatus.setGradStudent(stuObj); + graduationDataStatus.setStudentAssessments(sAssessments); + graduationDataStatus.setGradStudent(stuObj); GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode("2018-EN"); @@ -1315,6 +1350,7 @@ public void testIsGraduatedForSCCPWithWrongDateFormat() { @Test public void testSaveStudentAchievementReport() throws Exception { String studentID = new UUID(1, 1).toString(); + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; String accessToken = "accessToken"; String pen = "212321123"; boolean isGraduated = false; @@ -1325,10 +1361,12 @@ public void testSaveStudentAchievementReport() throws Exception { ExceptionMessage exception = new ExceptionMessage(); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolId), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getAchievementReport()), any(), eq(byte[].class))).thenReturn(bytesSAR); when(this.restService.post(eq(String.format(constants.getUpdateGradStudentReport(),isGraduated)), any(), eq(GradStudentReports.class))).thenReturn(rep); @@ -1393,20 +1431,7 @@ public void testStudentAchievementReport() throws Exception { @Test public void testGetTranscript() throws Exception { - School schoolDetails = new School(); - schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); - - GraduationProgramCode gradProgram = new GraduationProgramCode(); - gradProgram.setProgramCode("1950"); - gradProgram.setProgramName("1950 Adult Graduation Program"); - - ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); - programCertificateTranscript.setPcId(UUID.randomUUID()); - programCertificateTranscript.setGraduationProgramCode(gradProgram.getProgramCode()); - programCertificateTranscript.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); - programCertificateTranscript.setCertificateTypeCode("E"); - + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -1420,7 +1445,23 @@ public void testGetTranscript() throws Exception { graduationStudentRecord.setStudentID(UUID.fromString(gradSearchStudent.getStudentID())); graduationStudentRecord.setUpdateDate(LocalDateTime.now()); - when(this.restService.get(String.format(constants.getSchoolDetails(), "09323027"), School.class)).thenReturn(schoolDetails); + School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); + + GraduationProgramCode gradProgram = new GraduationProgramCode(); + gradProgram.setProgramCode("1950"); + gradProgram.setProgramName("1950 Adult Graduation Program"); + + ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); + programCertificateTranscript.setPcId(UUID.randomUUID()); + programCertificateTranscript.setGraduationProgramCode(gradProgram.getProgramCode()); + programCertificateTranscript.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); + programCertificateTranscript.setCertificateTypeCode("E"); + + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); @@ -1431,10 +1472,7 @@ public void testGetTranscript() throws Exception { @Test public void testGetTranscriptException() throws Exception { - School schoolDetails = new School(); - schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); - + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -1448,7 +1486,13 @@ public void testGetTranscriptException() throws Exception { graduationStudentRecord.setStudentID(UUID.fromString(gradSearchStudent.getStudentID())); graduationStudentRecord.setUpdateDate(LocalDateTime.now()); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); + + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenThrow(new RuntimeException()); @@ -1461,6 +1505,7 @@ public void testGetTranscriptException() throws Exception { @Test public void testReportDataByPen() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -1511,10 +1556,12 @@ public void testReportDataByPen() throws Exception { when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); @@ -1539,7 +1586,7 @@ public void testReportDataByPen() throws Exception { schtrax.setSchoolName("ROBERT DDGELL"); schtrax.setAddress1("My Address"); - when(this.restService.get(String.format(constants.getSchoolDetails(),schtrax.getMinCode()), School.class)).thenReturn(schtrax); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schtrax.getMinCode()), School.class)).thenReturn(schtrax); District distInstitute = new District(); distInstitute.setDistrictNumber("005"); @@ -1703,6 +1750,7 @@ public void testReportDataByPen_withErrors() throws Exception { @Test public void testTranscriptReportByPen() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -1728,10 +1776,12 @@ public void testTranscriptReportByPen() throws Exception { when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -1828,6 +1878,7 @@ public void testTranscriptReportByPenException() throws Exception { @Test public void testReportDataByGraduationData() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -1850,10 +1901,12 @@ public void testReportDataByGraduationData() throws Exception { when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -1912,6 +1965,7 @@ public void testReportDataByGraduationData() throws Exception { @Test public void testReportDataByGraduationData_GSRNULL() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); @@ -1926,9 +1980,11 @@ public void testReportDataByGraduationData_GSRNULL() throws Exception { when(this.restService.get(String.format(constants.getReadGradStudentRecord(),gradStatus.getGradStudent().getStudentID()), GraduationStudentRecord.class)).thenReturn(null); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -2010,6 +2066,7 @@ public void testReportDataByGraduationData_StudentNull() throws Exception { @Test public void testReportDataByGraduationData_EXCEPTION() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -2033,10 +2090,12 @@ public void testReportDataByGraduationData_EXCEPTION() throws Exception { School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); @@ -2056,6 +2115,7 @@ public void testReportDataByGraduationData_EXCEPTION() throws Exception { @Test public void testPrepareCertificateData() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -2085,10 +2145,12 @@ public void testPrepareCertificateData() throws Exception { when(this.restService.get(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()), List.class)).thenReturn(List.of(studentOptionalProgram)); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); @@ -2113,6 +2175,7 @@ public void testPrepareCertificateData() throws Exception { @Test public void testPrepareCertificateData_GSRNULL() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); @@ -2128,10 +2191,12 @@ public void testPrepareCertificateData_GSRNULL() throws Exception { School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -2163,6 +2228,7 @@ public void testPrepareCertificateData_StudentNull() throws Exception { @Test public void testPrepareCertificateData_EXCEPTION() throws Exception { + String schoolId = "b69bc244-b93b-2a9f-d2b1-3d8ffae92866"; GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); @@ -2172,6 +2238,7 @@ public void testPrepareCertificateData_EXCEPTION() throws Exception { graduationStudentRecord.setProgramCompletionDate("2003/01"); graduationStudentRecord.setStudentID(UUID.fromString(gradStatus.getGradStudent().getStudentID())); graduationStudentRecord.setUpdateDate(LocalDateTime.now()); + graduationStudentRecord.setSchoolOfRecordId(gradStatus.getGradStatus().getSchoolOfRecordId()); String studentGradData = readFile("json/gradstatus.json"); assertNotNull(studentGradData); @@ -2186,10 +2253,12 @@ public void testPrepareCertificateData_EXCEPTION() throws Exception { School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(),schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -2292,11 +2361,14 @@ public void testRemoveDuplicatedAssessments() throws Exception { @Test public void testGetSchoolCategoryCode() { + UUID schoolId = UUID.randomUUID(); School schoolDetails = new School(); + schoolDetails.setSchoolId(schoolId.toString()); schoolDetails.setMinCode("09323027"); - schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolDetails(), "09323027"), School.class)).thenReturn(schoolDetails); - var result = reportService.getSchoolCategoryCode(schoolDetails.getMinCode()); + schoolDetails.setSchoolCategoryCode("INDEPEN"); + schoolDetails.setSchoolCategoryLegacyCode("02"); + when(this.restService.get(String.format(constants.getSchoolClobBySchoolIdUrl(), schoolDetails.getSchoolId()), School.class)).thenReturn(schoolDetails); + var result = reportService.getSchoolCategoryCode(schoolId); assertThat(result).isNotNull(); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchooReportsServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchooReportsServiceTest.java index c4433420..c8f8ff8d 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchooReportsServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/graduation/service/SchooReportsServiceTest.java @@ -151,7 +151,7 @@ public void testSchoolReports() { traxSchool.setAddress1("1231"); when(this.restService.get(any(String.class), any(), any())).thenReturn(traxSchool); - when(this.schoolService.getSchoolDetails(any(String.class))).thenReturn(traxSchool); + when(this.schoolService.getSchoolClob(any(String.class))).thenReturn(traxSchool); mockTokenResponseObject(); @@ -165,7 +165,7 @@ public void testSchoolReports() { disttrax.setDistrictNumber("005"); disttrax.setDisplayName("My District"); - when(this.schoolService.getSchoolDetails(any(String.class))).thenReturn(traxSchool); + when(this.schoolService.getSchoolClob(any(String.class))).thenReturn(traxSchool); when(this.schoolService.getDistrictDetails(disttrax.getDistrictNumber())).thenReturn(disttrax); reportsCount = schoolReportsService.createAndStoreDistrictReports(DISTREP_YE_SD, "accessToken"); 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 87ce7ba9..14d319fc 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 @@ -17,6 +17,7 @@ import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; +import java.util.UUID; import java.util.function.Consumer; import static org.junit.Assert.assertEquals; @@ -71,29 +72,34 @@ public void tearDown() { @Test public void testGetSchoolDetails() { + UUID schoolId = UUID.randomUUID(); String mincode = "213123131"; - String accessToken = "accessToken"; School schtrax = new School(); + schtrax.setSchoolId(schoolId.toString()); schtrax.setMinCode(mincode); schtrax.setAddress1("1231"); when(this.restService.get(any(String.class), any())).thenReturn(schtrax); - School res = schoolService.getSchoolDetails(mincode); + School res = schoolService.getSchoolClob(schtrax.getSchoolId()); assertNotNull(res); - assertEquals(res.getMinCode(),mincode); + assertEquals(res.getSchoolId(),schoolId.toString()); + assertEquals(res.getMinCode(), mincode); } @Test public void testGetSchoolDetailsNoToken() { + UUID schoolId = UUID.randomUUID(); String mincode = "213123131"; School schtrax = new School(); + schtrax.setSchoolId(schoolId.toString()); schtrax.setMinCode(mincode); schtrax.setAddress1("1231"); mockTokenResponseObject(); when(this.restService.get(any(String.class), any())).thenReturn(schtrax); - School res = schoolService.getSchoolDetails(mincode); + School res = schoolService.getSchoolClob(schoolId); assertNotNull(res); + assertEquals(res.getSchoolId(),schoolId.toString()); assertEquals(res.getMinCode(),mincode); } diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 53b1ae5f..594e89fe 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -142,10 +142,12 @@ endpoint: by-pen: url: https://student-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/student?pen=%s grad-trax-api: - school-by-min-code: + 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-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: - url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/district/%s + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/district?distNo=%s #Splunk LogHelper splunk: diff --git a/api/src/test/resources/json/gradstatus.json b/api/src/test/resources/json/gradstatus.json index aacd16eb..9c002380 100644 --- a/api/src/test/resources/json/gradstatus.json +++ b/api/src/test/resources/json/gradstatus.json @@ -25,6 +25,7 @@ "trueStudentID": null, "program": "2018-EN", "schoolOfRecord": "09323027", + "schoolOfRecordId": "b69bc244-b93b-2a9f-d2b1-3d8ffae92866", "schoolOfRecordName": "DE L'ANSE-AU-SABLE", "schoolOfRecordindependentAffiliation": "", "studentGrade": "11", @@ -40,10 +41,12 @@ "honoursStanding": null, "recalculateGradStatus": null, "schoolOfRecord": "09323027", + "schoolOfRecordId": "b69bc244-b93b-2a9f-d2b1-3d8ffae92866", "studentGrade": "11", "studentStatus": "CUR", "studentID": "ac339d70-7649-1a2e-8176-4a33cd87651e", - "schoolAtGrad": "00502001" + "schoolAtGrad": "00502001", + "schoolAtGradId": "66f823ab-101b-e912-c006-a09077e613eb" }, "gradProgram": { "programCode": "1950", @@ -623,6 +626,7 @@ ], "school": { "minCode": "09323027", + "schoolId": "b69bc244-b93b-2a9f-d2b1-3d8ffae92866", "schoolName": "DE L'ANSE-AU-SABLE", "districtName": "SOUTHEAST KOOTENAY", "transcriptEligibility": "Y",