From 0cd1f8da4c3921f28a72e6718877b19aef5e0a09 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 8 Oct 2024 08:50:25 -0700 Subject: [PATCH 1/2] GRAD2-2761: initial commit to utilize the school clob data from institute RedisCache in grad-trax-api. GRAD2-2761: initial commit to utilize the school clob data from institute RedisCache in grad-trax-api. --- .../api/graduation/model/dto/District.java | 29 + .../graduation/model/dto/DistrictTrax.java | 57 - .../GradAlgorithmGraduationStudentRecord.java | 1 + .../model/dto/GraduationStudentRecord.java | 1 + .../educ/api/graduation/model/dto/School.java | 102 +- .../api/graduation/model/dto/SchoolTrax.java | 114 -- .../graduation/service/GraduationService.java | 50 +- .../api/graduation/service/ReportService.java | 51 +- .../service/SchoolReportsService.java | 43 +- .../api/graduation/service/SchoolService.java | 24 +- api/src/main/resources/application.yaml | 4 +- .../service/GraduationServiceTest.java | 55 +- .../graduation/service/ReportServiceTest.java | 1220 +++-------------- .../service/SchooReportsServiceTest.java | 18 +- .../graduation/service/SchoolServiceTest.java | 69 +- api/src/test/resources/application.yaml | 10 +- api/src/test/resources/json/gradstatus.json | 16 +- 17 files changed, 432 insertions(+), 1432 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/District.java delete mode 100644 api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/DistrictTrax.java delete mode 100644 api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolTrax.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/District.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/District.java new file mode 100644 index 00000000..4ca718ad --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/District.java @@ -0,0 +1,29 @@ +package ca.bc.gov.educ.api.graduation.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Component; + +@Data +@EqualsAndHashCode(callSuper = true) +@Component +@NoArgsConstructor +@AllArgsConstructor +public class District extends BaseModel { + + private String districtId; + private String districtNumber; + private String faxNumber; + private String phoneNumber; + private String email; + private String website; + private String displayName; + private String districtRegionCode; + private String districtStatusCode; + + public String getDistrictName() { + return displayName; + } +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/DistrictTrax.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/DistrictTrax.java deleted file mode 100644 index 5219fafe..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/DistrictTrax.java +++ /dev/null @@ -1,57 +0,0 @@ -package ca.bc.gov.educ.api.graduation.model.dto; - -import lombok.Data; -import org.springframework.stereotype.Component; - -@Data -@Component -public class DistrictTrax { - - private String districtNumber; - private String districtName; - private String districtSeq; - private String schoolETPSystem; - private String superIntendent; - private String djdeFlash; - private String activeFlag; - private String address1; - private String address2; - private String city; - private String provCode; - private String countryCode; - private String postal; - - public String getDistrictName() { - return districtName != null ? districtName.trim(): null; - } - - public String getDistrictSeq() { return districtSeq != null ? districtSeq.trim(): null; } - - public String getSchoolETPSystem() { return schoolETPSystem != null ? schoolETPSystem.trim(): null; } - - public String getSuperIntendent() {return superIntendent != null ? superIntendent.trim(): null;} - - public String getDjdeFlash() { return djdeFlash != null ? djdeFlash.trim(): null; } - - public String getActiveFlag() { return activeFlag != null ? activeFlag.trim(): null; } - - public String getAddress1() { return address1 != null ? address1.trim(): null; } - - public String getAddress2() { return address2 != null ? address2.trim(): null; } - - public String getCity() { return postal != null ? city.trim(): null; } - - public String getPostal() { return postal != null ? postal.trim(): null; } - - @Override - public String toString() { - return "District [districtNumber=" + districtNumber + ", districtName=" + districtName + ", districtSeq=" - + districtSeq + ", schoolETPSystem=" + schoolETPSystem + ", superIntendent=" + superIntendent - + ", djdeFlash=" + djdeFlash + ", activeFlag=" + activeFlag + ", address1=" + address1 + ", address2=" - + address2 + ", city=" + city + ", provCode=" + provCode + ", countryCode=" + countryCode + ", postal=" - + postal + "]"; - } - - -} - 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 93df8035..1f41f26b 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 @@ -22,6 +22,7 @@ public class GradAlgorithmGraduationStudentRecord { private String honoursStanding; private String recalculateGradStatus; private String schoolOfRecord; + private UUID schoolOfRecordId; private String studentGrade; private String studentStatus; private String studentCitizenship; 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 5ea0546a..dbf0cc2e 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 @@ -28,6 +28,7 @@ public class GraduationStudentRecord extends BaseModel { private String honoursStanding; private String recalculateGradStatus; private String schoolOfRecord; + private UUID schoolOfRecordId; private String schoolName; private String studentGrade; private String studentStatus; 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 913947ef..6dc4d605 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 @@ -8,41 +8,29 @@ public class School { private String minCode; - private String schoolName; - private String districtName; - private String schoolCategoryCode; - private String transcriptEligibility; - private String certificateEligibility; - private String independentDesignation; - private String mailerType; - private String address1; - private String address2; - private String city; - private String provCode; - private String provinceName; - private String countryCode; - private String countryName; - private String postal; - private String independentAffiliation; - private String openFlag; - private String signatureDistrict; - private String newMinCode; - private String schoolOrg; - private String appendTrans; - private String ministryContact; - private String principalName; - private String schoolPhone; - private String schoolFax; - private String schoolEmail; - + private String schoolId; + private String schoolName; + private String districtName; + private String transcriptEligibility; + private String certificateEligibility; + private String address1; + private String address2; + private String city; + private String provCode; + private String countryCode; + private String postal; + private String openFlag; + private String schoolCategoryCode; + private String schoolCategoryCodeInstitute; + public String getSchoolName() { return schoolName != null ? schoolName.trim(): null; } - + public String getDistrictName() { return districtName != null ? districtName.trim(): null; } - + public String getAddress1() { return address1 != null ? address1.trim(): null; } @@ -55,61 +43,21 @@ public String getCity() { return city != null ? city.trim(): null; } - public String getProvinceName() { - return provinceName != null ? provinceName.trim(): null; - } - - public String getCountryName() { - return countryName != null ? countryName.trim(): null; - } - public String getPostal() { return postal != null ? postal.trim(): null; } - - public String getIndependentDesignation() { - return independentDesignation != null ? independentDesignation.trim(): null; - } - - public String getIndependentAffiliation() { - return independentAffiliation != null ? independentAffiliation.trim(): null; - } - + public String getOpenFlag() { return openFlag != null ? openFlag.trim(): null; } - - public String getSignatureDistrict() { - return signatureDistrict != null ? signatureDistrict.trim(): null; - } - - public String getSchoolEmail() { - return schoolEmail != null ? schoolEmail.trim(): null; - } - - public String getPrincipalName() { - return principalName != null ? principalName.trim(): null; - } - - public String getAppendTrans() { - return appendTrans != null ? appendTrans.trim(): null; - } - - public String getMinistryContact() { - return ministryContact != null ? ministryContact.trim(): null; - } @Override public String toString() { - return "School [minCode=" + minCode + ", schoolName=" + schoolName + ", districtName=" + districtName - + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" - + certificateEligibility + ", independentDesignation=" + independentDesignation + ", mailerType=" - + mailerType + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" - + provCode + ", provinceName=" + provinceName + ", countryCode=" + countryCode + ", countryName=" - + countryName + ", postal=" + postal + ", independentAffiliation=" + independentAffiliation - + ", openFlag=" + openFlag + ", signatureDistrict=" + signatureDistrict + ", newMinCode=" + newMinCode - + ", schoolOrg=" + schoolOrg + ", appendTrans=" + appendTrans + ", ministryContact=" + ministryContact - + ", principalName=" + principalName + ", schoolPhone=" + schoolPhone + ", schoolFax=" + schoolFax - + ", schoolEmail=" + schoolEmail + "]"; - } + return "School [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolCategoryCodeInstitute=" + schoolCategoryCodeInstitute + + ", 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/SchoolTrax.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolTrax.java deleted file mode 100644 index 6920d81d..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/SchoolTrax.java +++ /dev/null @@ -1,114 +0,0 @@ -package ca.bc.gov.educ.api.graduation.model.dto; - -import lombok.Data; -import org.springframework.stereotype.Component; - -@Data -@Component -public class SchoolTrax { - - private String minCode; - private String schoolName; - private String districtName; - private String transcriptEligibility; - private String certificateEligibility; - private String independentDesignation; - private String mailerType; - private String address1; - private String address2; - private String city; - private String provCode; - private String provinceName; - private String countryCode; - private String countryName; - private String postal; - private String independentAffiliation; - private String openFlag; - private String signatureDistrict; - private String newMinCode; - private String schoolOrg; - private String appendTrans; - private String ministryContact; - private String principalName; - private String schoolPhone; - private String schoolFax; - private String schoolEmail; - - public String getSchoolName() { - return schoolName != null ? schoolName.trim(): null; - } - - public String getDistrictName() { - return districtName != null ? districtName.trim(): null; - } - - public String getAddress1() { - return address1 != null ? address1.trim(): null; - } - - public String getAddress2() { - return address2 != null ? address2.trim(): null; - } - - public String getCity() { - return city != null ? city.trim(): null; - } - - public String getProvinceName() { - return provinceName != null ? provinceName.trim(): null; - } - - public String getCountryName() { - return countryName != null ? countryName.trim(): null; - } - - public String getPostal() { - return postal != null ? postal.trim(): null; - } - - public String getIndependentDesignation() { - return independentDesignation != null ? independentDesignation.trim(): null; - } - - public String getIndependentAffiliation() { - return independentAffiliation != null ? independentAffiliation.trim(): null; - } - - public String getOpenFlag() { - return openFlag != null ? openFlag.trim(): null; - } - - public String getSignatureDistrict() { - return signatureDistrict != null ? signatureDistrict.trim(): null; - } - - public String getSchoolEmail() { - return schoolEmail != null ? schoolEmail.trim(): null; - } - - public String getPrincipalName() { - return principalName != null ? principalName.trim(): null; - } - - public String getAppendTrans() { - return appendTrans != null ? appendTrans.trim(): null; - } - - public String getMinistryContact() { - return ministryContact != null ? ministryContact.trim(): null; - } - - @Override - public String toString() { - return "School [minCode=" + minCode + ", schoolName=" + schoolName + ", districtName=" + districtName - + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" - + certificateEligibility + ", independentDesignation=" + independentDesignation + ", mailerType=" - + mailerType + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" - + provCode + ", provinceName=" + provinceName + ", countryCode=" + countryCode + ", countryName=" - + countryName + ", postal=" + postal + ", independentAffiliation=" + independentAffiliation - + ", openFlag=" + openFlag + ", signatureDistrict=" + signatureDistrict + ", newMinCode=" + newMinCode - + ", schoolOrg=" + schoolOrg + ", appendTrans=" + appendTrans + ", ministryContact=" + ministryContact - + ", principalName=" + principalName + ", schoolPhone=" + schoolPhone + ", schoolFax=" + schoolFax - + ", schoolEmail=" + schoolEmail + "]"; - } -} 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 30d7d2b1..4e52c012 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,7 +196,7 @@ public byte[] getSchoolReports(List uniqueSchoolList, String type) { for (String usl : uniqueSchoolList) { try { List stdList = gradStatusService.getStudentListByMinCode(usl); - SchoolTrax schoolDetails = schoolService.getTraxSchoolDetails(usl, new ExceptionMessage()); + ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(usl); if (schoolDetails != null) { School schoolObj = new School(); schoolObj.setMincode(schoolDetails.getMinCode()); @@ -228,7 +228,6 @@ public byte[] getSchoolReports(List uniqueSchoolList, String type) { public Integer createAndStoreSchoolReports(List uniqueSchoolList, String type) { int numberOfReports = 0; - ExceptionMessage exception = new ExceptionMessage(); for (String usl : uniqueSchoolList) { try { List stdList = gradStatusService.getStudentListByMinCode(usl); @@ -237,7 +236,7 @@ public Integer createAndStoreSchoolReports(List uniqueSchoolList, String String listOfStudents = jsonTransformer.marshall(stdList); logger.debug("*** Student List of {} Acquired {}", totalStudents, listOfStudents); } - SchoolTrax schoolDetails = schoolService.getTraxSchoolDetails(usl, exception); + ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(usl); if (schoolDetails != null) { logger.debug("*** School Details Acquired {}", schoolDetails.getSchoolName()); if (stdList != null && !stdList.isEmpty()) { @@ -324,12 +323,12 @@ private ReportData getReportDataObj(School schoolObj, List stdList) { } /** - private int processStudentNonGradReport(School schoolObj, List stdList, String mincode, String accessToken, int numberOfReports) { - ReportData nongradProjected = getReportDataObj(schoolObj, stdList); - createAndSaveSchoolReportStudentNonGradReport(nongradProjected, mincode, accessToken); - numberOfReports++; - return numberOfReports; - }**/ + private int processStudentNonGradReport(School schoolObj, List stdList, String mincode, String accessToken, int numberOfReports) { + ReportData nongradProjected = getReportDataObj(schoolObj, stdList); + createAndSaveSchoolReportStudentNonGradReport(nongradProjected, mincode, accessToken); + numberOfReports++; + return numberOfReports; + }**/ @SneakyThrows private List processStudentList(List gradStudList, String type) { @@ -350,15 +349,15 @@ private List processStudentList(List gradStudL //Grad2-1931 - mchintha std.setConsumerEducReqt(gsr.getConsumerEducationRequirementMet()); std.setGraduationStatus(GraduationStatus.builder() - .programCompletionDate(gsr.getProgramCompletionDate()) - .honours(gsr.getHonoursStanding()) - .gpa(gsr.getGpa()) - .programName(gsr.getProgramName()) - .studentStatus(gsr.getStudentStatus()) - .studentStatusName(gsr.getStudentStatusName()) - .studentGrade(gsr.getStudentGrade()) - .schoolAtGrad(gsr.getSchoolAtGrad()) - .schoolOfRecord(gsr.getSchoolOfRecord()) + .programCompletionDate(gsr.getProgramCompletionDate()) + .honours(gsr.getHonoursStanding()) + .gpa(gsr.getGpa()) + .programName(gsr.getProgramName()) + .studentStatus(gsr.getStudentStatus()) + .studentStatusName(gsr.getStudentStatusName()) + .studentGrade(gsr.getStudentGrade()) + .schoolAtGrad(gsr.getSchoolAtGrad()) + .schoolOfRecord(gsr.getSchoolOfRecord()) .build()); if (type.equalsIgnoreCase(REGALG)) { ca.bc.gov.educ.api.graduation.model.report.GraduationData gradData = new ca.bc.gov.educ.api.graduation.model.report.GraduationData(); @@ -495,12 +494,12 @@ private void createAndSaveSchoolReportStudentNonGradPrjReport(ReportData data, S } /** - private void createAndSaveSchoolReportStudentNonGradReport(ReportData data, String mincode, String accessToken) { - byte[] bytesSAR = getSchoolReportStudentNonGradReport(data, mincode, accessToken); - String encodedPdf = getEncodedPdfFromBytes(bytesSAR); - SchoolReports requestObj = getSchoolReports(mincode, encodedPdf, NONGRADPRJ); - updateSchoolReport(accessToken, requestObj); - } **/ + private void createAndSaveSchoolReportStudentNonGradReport(ReportData data, String mincode, String accessToken) { + byte[] bytesSAR = getSchoolReportStudentNonGradReport(data, mincode, accessToken); + String encodedPdf = getEncodedPdfFromBytes(bytesSAR); + SchoolReports requestObj = getSchoolReports(mincode, encodedPdf, NONGRADPRJ); + updateSchoolReport(accessToken, requestObj); + } **/ private SchoolReports getSchoolReports(String mincode, String encodedPdf, String nongradreg) { SchoolReports requestObj = new SchoolReports(); @@ -509,5 +508,4 @@ private SchoolReports getSchoolReports(String mincode, String encodedPdf, String requestObj.setReportTypeCode(nongradreg); return requestObj; } - -} \ No newline at end of file +} 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 10e59806..f5113ac6 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,7 +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(getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecord())); + req.setSchoolCategoryCode(StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolCategoryCode())? + getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecord()) : graduationDataStatus.getSchool().getSchoolCategoryCode()); try { return restService.post(educGraduationApiConstants.getTranscript(), req, ProgramCertificateTranscript.class); } catch (Exception e) { @@ -71,7 +72,8 @@ public List getCertificateList(GraduationStudentRe req.setOptionalProgram(optionalPrograms.getOptionalProgramCode()); } } - req.setSchoolCategoryCode(getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecord())); + req.setSchoolCategoryCode(StringUtils.isBlank(graduationDataStatus.getSchool().getSchoolCategoryCode())? + getSchoolCategoryCode(graduationDataStatus.getGradStatus().getSchoolOfRecord()) : graduationDataStatus.getSchool().getSchoolCategoryCode()); try { var response = restService.post(educGraduationApiConstants.getCertList(), req, List.class); return jsonTransformer.convertValue(response, new TypeReference>() {}); @@ -83,9 +85,8 @@ public List getCertificateList(GraduationStudentRe } public String getSchoolCategoryCode(String mincode) { - // Send to restclient instead - CommonSchool commonSchool = this.restService.get(String.format(educGraduationApiConstants.getSchoolCategoryCode(), mincode), CommonSchool.class); - return (commonSchool == null) ? null : commonSchool.getSchoolCategoryCode(); + 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 List getStudentsForSchoolYearEndReport(String accessToken) { @@ -119,7 +120,7 @@ public List getStudentsForSchoolReport() { public ReportData prepareTranscriptData(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, GraduationStudentRecord gradResponse, boolean xml, ExceptionMessage exception) { try { - School schoolAtGrad = getSchoolAtGradData(graduationDataStatus, exception); + School schoolAtGrad = getSchoolAtGradData(graduationDataStatus); School schoolOfRecord = getSchoolData(graduationDataStatus.getSchool()); //--> Revert code back to school of record GRAD2-2758 /** @@ -128,7 +129,7 @@ public ReportData prepareTranscriptData(ca.bc.gov.educ.api.graduation.model.dto. String mincode = schoolAtGrad.getMincode(); traxSchool = schoolService.getTraxSchoolDetails(mincode, exception); } **/ - SchoolTrax traxSchool = schoolService.getTraxSchoolDetails(schoolOfRecord.getMincode(), 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); @@ -145,7 +146,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(traxSchool != null && !"N".equalsIgnoreCase(traxSchool.getCertificateEligibility())) { + if(schoolDetails != null && !"N".equalsIgnoreCase(schoolDetails.getCertificateEligibility())) { if ("SCCP".equalsIgnoreCase(data.getGradProgram().getCode().getCode())) { data.getStudent().setSccDate(graduationStatus.getProgramCompletionDate()); } @@ -325,6 +326,7 @@ private void addIntoTranscriptList(TranscriptResult transcriptResult, List()); - return schObj; - } - - @SuppressWarnings("DuplicatedCode") private School getSchoolData(ca.bc.gov.educ.api.graduation.model.dto.School school) { School schObj = new School(); Address addRess = new Address(); @@ -750,7 +730,7 @@ 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(school.getIndependentDesignation()); + schObj.setTypeIndicator("02".equalsIgnoreCase(school.getSchoolCategoryCode())? "02" : ""); schObj.setAddress(addRess); schObj.setMincode(school.getMinCode()); schObj.setName(school.getSchoolName()); @@ -1013,7 +993,7 @@ public ReportData prepareCertificateData(GraduationStudentRecord gradResponse, ReportData data = new ReportData(); GraduationData graduationData = getGraduationData(graduationDataStatus, gradResponse); School certificateSchool; - School schoolAtGrad = getSchoolAtGradData(graduationDataStatus, new ExceptionMessage()); + School schoolAtGrad = getSchoolAtGradData(graduationDataStatus); if(schoolAtGrad != null) { //schoolAtGrad certificateSchool = schoolAtGrad; @@ -1110,7 +1090,7 @@ private String generateStudentAchievementReportJasper(ReportData data) { public ReportData prepareAchievementReportData(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, List optionalProgramList, ExceptionMessage exception) { try { - School schoolAtGrad = getSchoolAtGradData(graduationDataStatus, exception); + School schoolAtGrad = getSchoolAtGradData(graduationDataStatus); School schoolOfRecord = getSchoolData(graduationDataStatus.getSchool()); ReportData data = new ReportData(); data.setSchool(schoolOfRecord); @@ -1282,3 +1262,4 @@ Date toLastDayOfMonth(Date date) { return null; } } + 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 e4f18436..51d7bfb3 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 @@ -1,9 +1,8 @@ package ca.bc.gov.educ.api.graduation.service; -import ca.bc.gov.educ.api.graduation.model.dto.DistrictTrax; +import ca.bc.gov.educ.api.graduation.model.dto.District; import ca.bc.gov.educ.api.graduation.model.dto.ReportGradStudentData; import ca.bc.gov.educ.api.graduation.model.dto.SchoolReports; -import ca.bc.gov.educ.api.graduation.model.dto.SchoolTrax; import ca.bc.gov.educ.api.graduation.model.report.*; import ca.bc.gov.educ.api.graduation.util.*; import lombok.SneakyThrows; @@ -161,8 +160,8 @@ public Integer createAndStoreSchoolDistrictYearEndReports(String accessToken, St if(isDistrictSchool) { //--> Revert code back to school of record GRAD2-2758 /** - reportGradStudentDataList.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); - reportGradStudentDataList.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); + reportGradStudentDataList.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); + reportGradStudentDataList.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); **/ reportGradStudentDataList.removeIf(st->schools != null && !schools.isEmpty() && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3))); //<-- @@ -172,8 +171,8 @@ public Integer createAndStoreSchoolDistrictYearEndReports(String accessToken, St if(isSchoolSchool) { //--> Revert code back to school of record GRAD2-2758 /** - reportGradStudentDataList.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); - reportGradStudentDataList.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); + reportGradStudentDataList.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); + reportGradStudentDataList.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); **/ reportGradStudentDataList.removeIf(st->schools != null && !schools.isEmpty() && !schools.contains(st.getMincode())); //<-- @@ -483,11 +482,11 @@ private School populateDistrictObjectByReportGradStudentData(Map()); } return district; @@ -498,21 +497,21 @@ private School populateSchoolObjectByReportGradStudentData(ReportGradStudentData /** String mincode = StringUtils.isBlank(reportGradStudentData.getMincodeAtGrad()) ? reportGradStudentData.getMincode() : reportGradStudentData.getMincodeAtGrad();**/ String mincode = reportGradStudentData.getMincode(); //<-- - SchoolTrax traxSchool = schoolService.getTraxSchoolDetails(mincode); + ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(mincode); School school = new School(); school.setStudents(new ArrayList<>()); - if(traxSchool != null) { - school.setDistno(StringUtils.substring(traxSchool.getMinCode(), 0, 3)); - school.setMincode(traxSchool.getMinCode()); - school.setName(traxSchool.getSchoolName()); + if(schoolDetails != null) { + school.setDistno(StringUtils.substring(schoolDetails.getMinCode(), 0, 3)); + school.setMincode(schoolDetails.getMinCode()); + school.setName(schoolDetails.getSchoolName()); school.setTypeBanner("Principal"); Address address = new Address(); - address.setStreetLine1(traxSchool.getAddress1()); - address.setStreetLine2(traxSchool.getAddress2()); - address.setCity(traxSchool.getCity()); - address.setRegion(traxSchool.getProvCode()); - address.setCountry(traxSchool.getCountryName()); - address.setCode(traxSchool.getPostal()); + address.setStreetLine1(schoolDetails.getAddress1()); + address.setStreetLine2(schoolDetails.getAddress2()); + address.setCity(schoolDetails.getCity()); + address.setRegion(schoolDetails.getProvCode()); + address.setCountry(schoolDetails.getCountryCode()); + address.setCode(schoolDetails.getPostal()); school.setAddress(address); return school; } @@ -546,11 +545,11 @@ private void processDistrictSchoolMap(List schools, ReportGradStudentDat } } if (addNewSchool) { - SchoolTrax schoolTrax = schoolService.getTraxSchoolDetails(mincode); + ca.bc.gov.educ.api.graduation.model.dto.School schoolDetails = schoolService.getSchoolDetails(mincode); School school = new School(); school.setDistno(distNo); school.setMincode(mincode); - school.setName(schoolTrax != null ? schoolTrax.getSchoolName() : reportGradStudentData.getSchoolName()); + school.setName(schoolDetails != null ? schoolDetails.getSchoolName() : reportGradStudentData.getSchoolName()); school.setTypeBanner("Principal"); schools.add(processDistrictSchool(school, reportGradStudentData)); } @@ -666,4 +665,4 @@ private byte[] mergeDocuments(List sources) { mergedDoc.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly()); return new ByteArrayInputStream(tempOutStream.toByteArray()).readAllBytes(); } -} \ No newline at end of file +} 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 d504bfb3..2bd1c6cd 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 @@ -1,10 +1,7 @@ package ca.bc.gov.educ.api.graduation.service; -import ca.bc.gov.educ.api.graduation.model.dto.DistrictTrax; -import ca.bc.gov.educ.api.graduation.model.dto.ExceptionMessage; -import ca.bc.gov.educ.api.graduation.model.dto.SchoolTrax; +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.TokenUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -12,28 +9,21 @@ public class SchoolService { EducGraduationApiConstants educGraduationApiConstants; RESTService restService; - TokenUtils tokenUtils; - @Autowired - public SchoolService(EducGraduationApiConstants educGraduationApiConstants, RESTService restService, TokenUtils tokenUtils) { + public SchoolService(EducGraduationApiConstants educGraduationApiConstants, RESTService restService) { this.educGraduationApiConstants = educGraduationApiConstants; this.restService = restService; - this.tokenUtils = tokenUtils; } - public SchoolTrax getTraxSchoolDetails(String mincode, ExceptionMessage message) { + public School getSchoolDetails(String mincode) { return this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),mincode), - SchoolTrax.class); + School.class); } - public SchoolTrax getTraxSchoolDetails(String mincode) { - return this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),mincode), - SchoolTrax.class); - } - - public DistrictTrax getTraxDistrictDetails(String districtCode) { + public District getDistrictDetails(String districtCode) { return this.restService.get(String.format(educGraduationApiConstants.getDistrictDetails(), districtCode), - DistrictTrax.class); + District.class); } } + diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index c4862069..1dc830d8 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -147,9 +147,9 @@ endpoint: commonschool-by-mincode: url: ${GRAD_TRAX_API}api/v1/trax/school/common/%s school-by-min-code: - url: ${GRAD_TRAX_API}api/v1/trax/school/%s + url: ${GRAD_TRAX_API}api/v2/trax/school-clob/%s district-by-min-code: - url: ${GRAD_TRAX_API}api/v1/trax/district/%s + url: ${GRAD_TRAX_API}api/v2/trax/district/%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 a2acf488..1a597d83 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 @@ -545,7 +545,7 @@ public void testGraduateStudent_withProjectedTypeGS() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -618,7 +618,7 @@ public void testGraduateStudent_withProjectedTypeGS_excep_check() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); data.setException(excep2); @@ -698,7 +698,7 @@ public void testGraduateStudent_withProjectedTypeGS_excep_check_2() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); Mockito.when(gradStatusService.getGradStatus(studentID, exception)).thenReturn(gradResponse); @@ -775,7 +775,7 @@ public void testGraduateStudent_withProjectedTypeGS_excep_check_3() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -857,7 +857,7 @@ public void testGraduateStudent_withProjectedTypeGS_excep() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); Mockito.when(gradStatusService.getGradStatus(studentID, exception)).thenReturn(gradResponse); @@ -922,7 +922,7 @@ public void testGraduateStudent_withProjectedTypeGS_programcompletionDate_notnul School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -994,7 +994,7 @@ public void testGraduateStudent_withProjectedTypeGS_Graduated() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1066,7 +1066,7 @@ public void testGraduateStudent_withProjectedTypeFMR_programCompletionDate_null( School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1143,7 +1143,7 @@ public void testGraduateStudent_withProjectedTypeFMR() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1223,7 +1223,7 @@ public void testGraduateStudent_withProjectedTypeFMR_excep1() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1302,7 +1302,7 @@ public void testGraduateStudent_withProjectedTypeFMR_excep3() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1383,7 +1383,7 @@ public void testGraduateStudent_withProjectedTypeFMR_excep2() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1456,7 +1456,7 @@ public void testGraduateStudent_withProjectedTypeFMR_programcompletionDate_notnu School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1528,7 +1528,7 @@ public void testGraduateStudent_withProjectedTypeFMR_programCompletionDate_notnu School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1600,7 +1600,7 @@ public void testGraduateStudent_withProjectedTypeFMR_Graduated() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1662,8 +1662,8 @@ public void testGraduateStudent_withProjectedTypeGS_withexception() { school.setMinCode("012345"); school.setSchoolName("XYZ"); school.setSchoolCategoryCode("01"); - school.setSchoolPhone("123456"); - school.setIndependentDesignation("2"); +// school.setSchoolPhone("123456"); + school.setSchoolId(UUID.randomUUID().toString()); graduationDataStatus.setSchool(school); GradSearchStudent gradStudent = new GradSearchStudent(); @@ -1773,7 +1773,7 @@ public void testGraduateStudent_withProjectedTypeFMR_withexception2() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); ReportData data = new ReportData(); data.setGradMessage("ABC"); @@ -1842,7 +1842,7 @@ public void testcreateReportNCert() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); List pList = new ArrayList<>(); ProgramCertificateTranscript pcr = new ProgramCertificateTranscript(); @@ -1923,7 +1923,7 @@ public void testcreateReportNCert2() { School schoolObj = new School(); schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); List pList = new ArrayList<>(); ProgramCertificateTranscript pcr = new ProgramCertificateTranscript(); @@ -1991,7 +1991,7 @@ public void testCreateAndStoreSchoolReports() { sList.add(gsr); - SchoolTrax sTrax = new SchoolTrax(); + School sTrax = new School(); sTrax.setAddress1("!23123"); sTrax.setMinCode("1231231231"); @@ -2021,8 +2021,9 @@ public void testCreateAndStoreSchoolReports() { when(this.restService.get(any(), any())).thenReturn(1); Mockito.when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); - Mockito.when(schoolService.getTraxSchoolDetails(mincode, exception)).thenReturn(sTrax); + Mockito.when(schoolService.getSchoolDetails(mincode)).thenReturn(sTrax); int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG"); + assertEquals(2,numberOfRecord); Mockito.when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(List.of()); @@ -2144,7 +2145,7 @@ public void testGetSchoolReports() { sList.add(gsr); - SchoolTrax sTrax = new SchoolTrax(); + School sTrax = new School(); sTrax.setAddress1("!23123"); sTrax.setMinCode("1231231231"); @@ -2174,7 +2175,7 @@ public void testGetSchoolReports() { when(this.restService.post(any(String.class), any(), any())).thenReturn(bytesSAR1); when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); - when(schoolService.getTraxSchoolDetails(mincode, exception)).thenReturn(sTrax); + when(schoolService.getSchoolDetails(mincode)).thenReturn(sTrax); byte[] result = graduationService.getSchoolReports(uniqueList,"GRADREG"); assertNotNull(result); @@ -2226,7 +2227,7 @@ public void testCreateAndStoreSchoolReports_TVR() { } sList.add(gsr); - SchoolTrax sTrax = new SchoolTrax(); + School sTrax = new School(); sTrax.setAddress1("!23123"); sTrax.setMinCode("1231231231"); @@ -2245,8 +2246,9 @@ public void testCreateAndStoreSchoolReports_TVR() { when(this.restService.get(any(), any())).thenReturn(1); Mockito.when(gradStatusService.getStudentListByMinCode(mincode)).thenReturn(sList); - Mockito.when(schoolService.getTraxSchoolDetails(mincode, exception)).thenReturn(sTrax); + Mockito.when(schoolService.getSchoolDetails(mincode)).thenReturn(sTrax); int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"TVRRUN"); + assertEquals(1,numberOfRecord); } @@ -2358,3 +2360,4 @@ private String readInputStream(InputStream is) throws Exception { return sb.toString(); } } + 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 317822c3..76df5f87 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 @@ -51,7 +51,6 @@ @ActiveProfiles("test") @IntegrationComponentScan @EnableIntegration -@SuppressWarnings({"unchecked","rawtypes"}) public class ReportServiceTest { @Autowired @@ -62,10 +61,10 @@ public class ReportServiceTest { @Autowired JsonTransformer jsonTransformer; - + @Autowired private ExceptionMessage exception; - + @Autowired GradValidation validation; @@ -78,30 +77,22 @@ public class ReportServiceTest { @MockBean WebClient webClient; - @Autowired - private EducGraduationApiConstants constants; - - @Before - public void setUp() { - openMocks(this); - } + @Autowired + private EducGraduationApiConstants constants; + + @Before + public void setUp() { + openMocks(this); + } @After - public void tearDown() { + public void tearDown() { - } + } @Test public void testGetStudentsForSchoolYearEndReport() { List gradStudentDataList = createStudentSchoolYearEndData("json/studentSchoolYearEndResponse.json"); -// ParameterizedTypeReference> reportGradStudentDataType = new ParameterizedTypeReference<>() { -// }; - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getSchoolYearEndStudents())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(reportGradStudentDataType)).thenReturn(Mono.just(gradStudentDataList)); when(this.restService.get(constants.getSchoolYearEndStudents(), List.class, "accessToken")).thenReturn(gradStudentDataList); @@ -112,16 +103,6 @@ public void testGetStudentsForSchoolYearEndReport() { @Test public void testGetStudentsForSchoolYearEndReportWithSchools() { List gradStudentDataList = createStudentSchoolYearEndData("json/studentSchoolYearEndResponse.json"); -// ParameterizedTypeReference> reportGradStudentDataType = new ParameterizedTypeReference<>() { -// }; -// -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(String.format(constants.getSchoolYearEndStudents()))).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(reportGradStudentDataType)).thenReturn(Mono.just(gradStudentDataList)); when(this.restService.post(constants.getSchoolYearEndStudents(), List.of("00502001"), List.class)).thenReturn(gradStudentDataList); @@ -135,12 +116,6 @@ public void testGetStudentsForSchoolYearEndNonGradReport() { ParameterizedTypeReference> reportGradStudentDataType = new ParameterizedTypeReference<>() { }; -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getStudentNonGradReportData())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(reportGradStudentDataType)).thenReturn(Mono.just(gradStudentDataList)); - when(this.restService.get(constants.getStudentNonGradReportData(), List.class)).thenReturn(gradStudentDataList); var result = reportService.getStudentsForSchoolNonGradYearEndReport(); @@ -150,14 +125,6 @@ public void testGetStudentsForSchoolYearEndNonGradReport() { @Test public void testGetStudentsForSchoolYearEndNonGradReportWithMincode() { List gradStudentDataList = createStudentSchoolYearEndData("json/studentSchoolYearEndResponse.json"); -// ParameterizedTypeReference> reportGradStudentDataType = new ParameterizedTypeReference<>() { -// }; - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getStudentNonGradReportDataMincode(), "02396738"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(reportGradStudentDataType)).thenReturn(Mono.just(gradStudentDataList)); when(this.restService.get(String.format(constants.getStudentNonGradReportDataMincode(), "02396738"), List.class)).thenReturn(gradStudentDataList); @@ -168,14 +135,6 @@ public void testGetStudentsForSchoolYearEndNonGradReportWithMincode() { @Test public void testGetStudentsForSchoolReport() { List gradStudentDataList = createStudentSchoolYearEndData("json/studentSchoolYearEndResponse.json"); - ParameterizedTypeReference> reportGradStudentDataType = new ParameterizedTypeReference<>() { - }; -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getSchoolStudents())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(reportGradStudentDataType)).thenReturn(Mono.just(gradStudentDataList)); when(this.restService.get(constants.getSchoolStudents(), List.class)).thenReturn(gradStudentDataList); @@ -195,7 +154,7 @@ public void testSaveStudentCertificateReport() { certificateList.add(pc); ReportData data = new ReportData(); data.setGradMessage("ABC"); - + GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -205,7 +164,7 @@ public void testSaveStudentCertificateReport() { gradAlgorithmGraduationStatus.setHonoursStanding("Y"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -227,11 +186,11 @@ public void testSaveStudentCertificateReport() { school.setPostal("V6T 1T2"); school.setProvCode("BC"); graduationDataStatus.setSchool(school); - + GradStudentCertificates rep = new GradStudentCertificates(); rep.setPen(pen); - byte[] bytesSAR = RandomUtils.nextBytes(20); - + byte[] bytesSAR = RandomUtils.nextBytes(20); + GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setStudentID(studentID); gradResponse.setPen("123090109"); @@ -250,12 +209,6 @@ public void testSaveStudentCertificateReport() { studentOptionalProgram.setOptionalProgramName("Advanced Placement"); studentOptionalProgram.setStudentID(studentID); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getStudentOptionalPrograms(), studentID))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(optionalProgramsResponseType)).thenReturn(Mono.just(List.of(studentOptionalProgram))); - when(this.restService.get(String.format(constants.getStudentOptionalPrograms(), studentID), List.class)).thenReturn(List.of(studentOptionalProgram)); @@ -263,40 +216,14 @@ public void testSaveStudentCertificateReport() { gP.setProgramCode("2018-EN"); gP.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); - - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertificateReport())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(bytesSAR)); - when(this.restService.get(constants.getCertificateReport(), byte[].class)).thenReturn(bytesSAR); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(String.format(constants.getUpdateGradStudentCertificate(),pen))).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GradStudentCertificates.class)).thenReturn(Mono.just(rep)); - when(this.restService.post(eq(String.format(constants.getUpdateGradStudentCertificate(),pen)), any(), eq(GradStudentCertificates.class))).thenReturn(rep); reportService.saveStudentCertificateReportJasper(gradResponse, graduationDataStatus, pc,false); - assertThat(exception.getExceptionName()).isNull(); + assertThat(exception.getExceptionName()).isNull(); } - + @Test public void testSaveStudentTranscriptReport() { String studentID = new UUID(1, 1).toString(); @@ -315,37 +242,13 @@ public void testSaveStudentTranscriptReport() { rep.setPen(pen); byte[] bytesSAR = RandomUtils.nextBytes(20); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscriptReport())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(bytesSAR)); + when(this.restService.get(String.format(constants.getSchoolDetails(), "09323027"), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getTranscriptReport()), any(), eq(byte[].class))).thenReturn(bytesSAR); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(String.format(constants.getUpdateGradStudentTranscript(),isGraduated))).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GradStudentReports.class)).thenReturn(Mono.just(rep)); - when(this.restService.post(eq(String.format(constants.getUpdateGradStudentTranscript(),isGraduated)), any(), eq(GradStudentReports.class))).thenReturn(rep); reportService.saveStudentTranscriptReportJasper(data, UUID.fromString(studentID),exception,isGraduated, false); @@ -374,7 +277,7 @@ public void testGetCertificateList_whenAPIisDown_throwsException() { School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); @@ -393,18 +296,13 @@ public void testGetCertificateList_whenAPIisDown_throwsException() { List list = new ArrayList(); list.add(spgm); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); + + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenThrow(new RuntimeException("Test - API is down")); var results = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); @@ -413,7 +311,7 @@ public void testGetCertificateList_whenAPIisDown_throwsException() { assertNotNull(exception); assertThat(exception.getExceptionName()).isEqualTo("GRAD-GRADUATION-REPORT-API IS DOWN"); } - + @Test public void testGetCertificateList() { String studentID = new UUID(1, 1).toString(); @@ -425,7 +323,7 @@ public void testGetCertificateList() { gradResponse.setSchoolOfRecord("06011033"); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); - + GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -433,11 +331,11 @@ public void testGetCertificateList() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -445,7 +343,7 @@ public void testGetCertificateList() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(null); - + StudentOptionalProgram spgm = new StudentOptionalProgram(); spgm.setPen("123090109"); spgm.setOptionalProgramCode("DD"); @@ -454,40 +352,26 @@ public void testGetCertificateList() { spgm.setStudentID(UUID.fromString(studentID)); List list = new ArrayList(); list.add(spgm); - + List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); pc.setCertificateTypeCode("E"); pc.setSchoolCategoryCode(" "); clist.add(pc); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertList())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(clist)); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); List listCC =reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); } - + @Test public void testGetCertificateList_PFProgram() { String studentID = new UUID(1, 1).toString(); @@ -499,7 +383,7 @@ public void testGetCertificateList_PFProgram() { gradResponse.setSchoolOfRecord("06011033"); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); - + GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -507,11 +391,11 @@ public void testGetCertificateList_PFProgram() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setGradMessage("Not Graduated"); graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); @@ -519,20 +403,12 @@ public void testGetCertificateList_PFProgram() { graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(null); graduationDataStatus.setDualDogwood(true); - + List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); pc.setCertificateTypeCode("E"); pc.setSchoolCategoryCode(" "); clist.add(pc); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertList())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(clist)); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); @@ -545,23 +421,16 @@ public void testGetCertificateList_PFProgram() { List list = new ArrayList(); list.add(spgm); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List listCC = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); } - + @Test public void testGetCertificateList_PFProgram_nodogwood() { String studentID = new UUID(1, 1).toString(); @@ -573,7 +442,7 @@ public void testGetCertificateList_PFProgram_nodogwood() { gradResponse.setSchoolOfRecord("06011033"); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); - + GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -581,11 +450,11 @@ public void testGetCertificateList_PFProgram_nodogwood() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -593,7 +462,7 @@ public void testGetCertificateList_PFProgram_nodogwood() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(null); - + StudentOptionalProgram spgm = new StudentOptionalProgram(); spgm.setPen("123090109"); spgm.setOptionalProgramCode("DD"); @@ -603,39 +472,24 @@ public void testGetCertificateList_PFProgram_nodogwood() { List list = new ArrayList(); list.add(spgm); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); pc.setCertificateTypeCode("E"); pc.setSchoolCategoryCode(" "); clist.add(pc); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertList())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(clist)); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); List listCC= reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); } - + @Test public void testGetCertificateList_emptyOptionalProgram() { UUID studentID = new UUID(1, 1); @@ -649,18 +503,11 @@ public void testGetCertificateList_emptyOptionalProgram() { gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); @@ -670,11 +517,11 @@ public void testGetCertificateList_emptyOptionalProgram() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -682,20 +529,12 @@ public void testGetCertificateList_emptyOptionalProgram() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(null); - + List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); pc.setCertificateTypeCode("E"); pc.setSchoolCategoryCode(" "); clist.add(pc); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertList())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(clist)); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); @@ -703,7 +542,7 @@ public void testGetCertificateList_emptyOptionalProgram() { List listCC = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); } - + @Test public void testGetCertificateList_FrenchImmersion() { String studentID = new UUID(1, 1).toString(); @@ -715,7 +554,7 @@ public void testGetCertificateList_FrenchImmersion() { gradResponse.setSchoolOfRecord("06011033"); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); - + GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -723,11 +562,11 @@ public void testGetCertificateList_FrenchImmersion() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -735,36 +574,21 @@ public void testGetCertificateList_FrenchImmersion() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(null); - + List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); pc.setCertificateTypeCode("E"); pc.setSchoolCategoryCode(" "); clist.add(pc); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertList())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(clist)); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); StudentOptionalProgram spgm = new StudentOptionalProgram(); spgm.setPen("123090109"); @@ -778,7 +602,7 @@ public void testGetCertificateList_FrenchImmersion() { List listCC = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); } - + @Test public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { String studentID = new UUID(1, 1).toString(); @@ -790,7 +614,7 @@ public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { gradResponse.setSchoolOfRecord("06011033"); gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); - + GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); gradAlgorithmGraduationStatus.setPen("123090109"); gradAlgorithmGraduationStatus.setProgram("2018-EN"); @@ -798,11 +622,11 @@ public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -810,7 +634,7 @@ public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(null); - + StudentOptionalProgram spgm = new StudentOptionalProgram(); spgm.setPen("123090109"); spgm.setOptionalProgramCode("FI"); @@ -820,40 +644,25 @@ public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { spgm.setOptionalProgramCompletionDate(null); List list = new ArrayList(); list.add(spgm); - + List clist= new ArrayList(); ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); pc.setCertificateTypeCode("E"); pc.setSchoolCategoryCode("02"); clist.add(pc); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getCertList())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(new ParameterizedTypeReference>(){})).thenReturn(Mono.just(clist)); when(this.restService.post(eq(constants.getCertList()), any(), eq(List.class))).thenReturn(clist); - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(comSchObj)); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(comSchObj); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List listCC = reportService.getCertificateList(gradResponse, graduationDataStatus, list,exception); assertThat(listCC).hasSize(1); } - + @Test public void testPrepareReportData() { String accessToken = "accessToken"; @@ -864,17 +673,17 @@ public void testPrepareReportData() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("1"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GradSearchStudent stuObj = new GradSearchStudent(); stuObj.setPen("123123123"); stuObj.setLegalFirstName("ABC"); stuObj.setLegalLastName("FDG"); stuObj.setSchoolOfRecord("12321321"); - + StudentCourse sc= new StudentCourse(); sc.setCourseCode("FDFE"); sc.setCourseName("DERQ WEW"); @@ -892,7 +701,7 @@ public void testPrepareReportData() { sList.add(sc); StudentCourses sCourses = new StudentCourses(); sCourses.setStudentCourseList(sList); - + StudentAssessment sA= new StudentAssessment(); sA.setAssessmentCode("FDFE"); sA.setAssessmentName("AASASA"); @@ -902,7 +711,7 @@ public void testPrepareReportData() { aList.add(sA); StudentAssessments sAssessments = new StudentAssessments(); sAssessments.setStudentAssessmentList(aList); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -910,45 +719,26 @@ public void testPrepareReportData() { graduationDataStatus.setGraduated(false); graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); + graduationDataStatus.setStudentAssessments(sAssessments); graduationDataStatus.setGradStudent(stuObj); GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode("2018-EN"); gP.setProgramName("2018 Graduation Program"); - + SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); + School schoolDetails = new School(); + schoolDetails.setMinCode("1123"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); @@ -958,13 +748,13 @@ public void testPrepareReportData() { gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); gradResponse.setUpdateDate(LocalDateTime.now()); - + List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); cDto.setCode("FI"); cDto.setName("French Immersion"); optionalProgram.add(cDto); - + ReportData dta = reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,exception); assertThat(dta).isNotNull(); } @@ -1074,19 +864,19 @@ private List getStudentAssessments() { public void testPrepareReportData_nullProgramData() { String accessToken = "accessToken"; GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = getGradAlgorithmGraduationStatus("2018-EN"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("1"); + schoolObj.setSchoolId(UUID.randomUUID().toString()); GradSearchStudent stuObj = getStudentObj(); StudentCourses sCourses = new StudentCourses(); sCourses.setStudentCourseList(getStudentCourses(4,4)); - + StudentAssessments sAssessments = new StudentAssessments(); sAssessments.setStudentAssessmentList(getStudentAssessments()); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -1100,46 +890,26 @@ public void testPrepareReportData_nullProgramData() { GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode("2018-EN"); gP.setProgramName("2018 Graduation Program"); - + SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); cDto.setCode("FI"); cDto.setName("French Immersion"); optionalProgram.add(cDto); - + GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); @@ -1148,7 +918,7 @@ public void testPrepareReportData_nullProgramData() { gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); gradResponse.setUpdateDate(LocalDateTime.now()); - + ReportData dta = reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,exception); assertThat(dta).isNotNull(); } @@ -1160,21 +930,21 @@ public void testPrepareReportData_exams_notnull() { testPrepareReportData_exams_notnull("1950",accessToken); testPrepareReportData_exams_notnull("2004-EN",accessToken); } - + public void testPrepareReportData_exams_notnull(String program,String accessToken) { GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = getGradAlgorithmGraduationStatus(program); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("1"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GradSearchStudent stuObj = getStudentObj(); StudentCourses sCourses = new StudentCourses(); sCourses.setStudentCourseList(getStudentCourses(2,4)); - + StudentExam se= new StudentExam(); se.setCourseCode("FDFE"); List eList= new ArrayList<>(); @@ -1184,7 +954,7 @@ public void testPrepareReportData_exams_notnull(String program,String accessToke StudentAssessments sAssessments = new StudentAssessments(); sAssessments.setStudentAssessmentList(getStudentAssessments()); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -1199,47 +969,26 @@ public void testPrepareReportData_exams_notnull(String program,String accessToke GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode(program); gP.setProgramName("2018 Graduation Program"); - + SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); + School schoolDetails = new School(); + schoolDetails.setMinCode("06011033"); + schoolDetails.setSchoolCategoryCode("02"); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("06011033"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); - + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); cDto.setCode("FI"); cDto.setName("French Immersion"); optionalProgram.add(cDto); - + GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram(program); @@ -1251,7 +1000,7 @@ public void testPrepareReportData_exams_notnull(String program,String accessToke ReportData dta = reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,exception); assertThat(dta).isNotNull(); } - + @Test public void testPrepareReportData_Desig_3() { String accessToken = "accessToken"; @@ -1262,17 +1011,17 @@ public void testPrepareReportData_Desig_3() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("3"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GradSearchStudent stuObj = new GradSearchStudent(); stuObj.setPen("123123123"); stuObj.setLegalFirstName("ABC"); stuObj.setLegalLastName("FDG"); stuObj.setSchoolOfRecord("12321321"); - + StudentCourse sc= new StudentCourse(); sc.setCourseCode("FDFE"); sc.setCourseName("FDFE FREE"); @@ -1289,7 +1038,7 @@ public void testPrepareReportData_Desig_3() { sList.add(sc); StudentCourses sCourses = new StudentCourses(); sCourses.setStudentCourseList(sList); - + StudentAssessment sA= new StudentAssessment(); sA.setAssessmentCode("FDFE"); sA.setAssessmentName("AASASA"); @@ -1299,7 +1048,7 @@ public void testPrepareReportData_Desig_3() { aList.add(sA); StudentAssessments sAssessments = new StudentAssessments(); sAssessments.setStudentAssessmentList(aList); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -1308,51 +1057,31 @@ public void testPrepareReportData_Desig_3() { graduationDataStatus.setSchool(schoolObj); graduationDataStatus.setStudentCourses(sCourses); graduationDataStatus.setStudentAssessments(sAssessments); graduationDataStatus.setGradStudent(stuObj); - + SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode("2018-EN"); gP.setProgramName("2018 Graduation Program"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); - + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); CodeDTO cDto = new CodeDTO(); cDto.setCode("FI"); cDto.setName("French Immersion"); optionalProgram.add(cDto); - + GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); @@ -1361,11 +1090,11 @@ public void testPrepareReportData_Desig_3() { gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); gradResponse.setUpdateDate(LocalDateTime.now()); - + ReportData dta = reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,exception); assertThat(dta).isNotNull(); } - + @Test public void testPrepareReportData_Desig_4() { String accessToken = "accessToken"; @@ -1376,17 +1105,17 @@ public void testPrepareReportData_Desig_4() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("4"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GradSearchStudent stuObj = new GradSearchStudent(); stuObj.setPen("123123123"); stuObj.setLegalFirstName("ABC"); stuObj.setLegalLastName("FDG"); stuObj.setSchoolOfRecord("12321321"); - + StudentCourse sc= new StudentCourse(); sc.setCourseCode("FDFE"); sc.setCourseName("FDFE FREE"); @@ -1404,7 +1133,7 @@ public void testPrepareReportData_Desig_4() { sList.add(sc); StudentCourses sCourses = new StudentCourses(); sCourses.setStudentCourseList(sList); - + StudentAssessment sA= new StudentAssessment(); sA.setAssessmentCode("FDFE"); sA.setAssessmentName("AASASA"); @@ -1414,7 +1143,7 @@ public void testPrepareReportData_Desig_4() { aList.add(sA); StudentAssessments sAssessments = new StudentAssessments(); sAssessments.setStudentAssessmentList(aList); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -1427,39 +1156,19 @@ public void testPrepareReportData_Desig_4() { GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode("2018-EN"); gP.setProgramName("2018 Graduation Program"); - + SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); List optionalProgram = new ArrayList(); @@ -1467,7 +1176,7 @@ public void testPrepareReportData_Desig_4() { cDto.setCode("FI"); cDto.setName("French Immersion"); optionalProgram.add(cDto); - + GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); @@ -1476,11 +1185,11 @@ public void testPrepareReportData_Desig_4() { gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); gradResponse.setUpdateDate(LocalDateTime.now()); - + ReportData dta = reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,exception); assertThat(dta).isNotNull(); } - + public void testPrepareReportData_Desig_2() { String accessToken = "accessToken"; @@ -1491,17 +1200,17 @@ public void testPrepareReportData_Desig_2() { gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); gradAlgorithmGraduationStatus.setStudentGrade("11"); gradAlgorithmGraduationStatus.setStudentStatus("A"); - + School schoolObj = new School(); schoolObj.setMinCode("09323027"); - schoolObj.setIndependentDesignation("2"); - + schoolObj.setSchoolId(UUID.randomUUID().toString()); + GradSearchStudent stuObj = new GradSearchStudent(); stuObj.setPen("123123123"); stuObj.setLegalFirstName("ABC"); stuObj.setLegalLastName("FDG"); stuObj.setSchoolOfRecord("12321321"); - + StudentCourse sc= new StudentCourse(); sc.setCourseCode("FDFE"); sc.setCredits(4); @@ -1512,7 +1221,7 @@ public void testPrepareReportData_Desig_2() { sList.add(sc); StudentCourses sCourses = new StudentCourses(); sCourses.setStudentCourseList(sList); - + StudentAssessment sA= new StudentAssessment(); sA.setAssessmentCode("FDFE"); sA.setAssessmentName("AASASA"); @@ -1522,7 +1231,7 @@ public void testPrepareReportData_Desig_2() { aList.add(sA); StudentAssessments sAssessments = new StudentAssessments(); sAssessments.setStudentAssessmentList(aList); - + GraduationData graduationDataStatus = new GraduationData(); graduationDataStatus.setDualDogwood(false); graduationDataStatus.setGradMessage("Not Graduated"); @@ -1535,12 +1244,6 @@ public void testPrepareReportData_Desig_2() { GraduationProgramCode gP = new GraduationProgramCode(); gP.setProgramCode("2018-EN"); gP.setProgramName("2018 Graduation Program"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gP)); when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradAlgorithmGraduationStatus.getProgram()), GraduationProgramCode.class)).thenReturn(gP); @@ -1550,7 +1253,7 @@ public void testPrepareReportData_Desig_2() { cDto.setCode("FI"); cDto.setName("French Immersion"); optionalProgram.add(cDto); - + GraduationStudentRecord gradResponse = new GraduationStudentRecord(); gradResponse.setPen("123090109"); gradResponse.setProgram("2018-EN"); @@ -1559,7 +1262,7 @@ public void testPrepareReportData_Desig_2() { gradResponse.setStudentGrade("11"); gradResponse.setStudentStatus("D"); gradResponse.setUpdateDate(LocalDateTime.now()); - + ReportData dta = reportService.prepareTranscriptData(graduationDataStatus,gradResponse,false,exception); assertThat(dta).isNotNull(); } @@ -1620,39 +1323,13 @@ public void testSaveStudentAchievementReport() throws Exception { rep.setPen(pen); byte[] bytesSAR = RandomUtils.nextBytes(20); ExceptionMessage exception = new ExceptionMessage(); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "06011033"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"06011033"), CommonSchool.class)).thenReturn(commSch); - - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getAchievementReport())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(bytesSAR)); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); + when(this.restService.get(String.format(constants.getSchoolDetails(), "06011033"), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getAchievementReport()), any(), eq(byte[].class))).thenReturn(bytesSAR); - -// -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(String.format(constants.getUpdateGradStudentReport(),isGraduated))).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GradStudentReports.class)).thenReturn(Mono.just(rep)); - when(this.restService.post(eq(String.format(constants.getUpdateGradStudentReport(),isGraduated)), any(), eq(GradStudentReports.class))).thenReturn(rep); reportService.saveStudentAchivementReportJasper(pen, data, UUID.fromString(studentID), exception, isGraduated); @@ -1668,12 +1345,6 @@ public void testStudentAchievementReport() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); List programRequirementCodes = new ArrayList<>(); @@ -1710,15 +1381,8 @@ public void testStudentAchievementReport() throws Exception { spc.setSpCase("A"); spc.setPassFlag("Y"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(spc)); - when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(spc); - ReportData data = reportService.prepareAchievementReportData(gradStatus,optionalProgram, exception); assertNotNull(data); assertNotNull(data.getStudentExams()); @@ -1729,9 +1393,9 @@ public void testStudentAchievementReport() throws Exception { @Test public void testGetTranscript() throws Exception { - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); GraduationProgramCode gradProgram = new GraduationProgramCode(); gradProgram.setProgramCode("1950"); @@ -1740,7 +1404,7 @@ public void testGetTranscript() throws Exception { ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); programCertificateTranscript.setGraduationProgramCode(gradProgram.getProgramCode()); - programCertificateTranscript.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); + programCertificateTranscript.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); programCertificateTranscript.setCertificateTypeCode("E"); GraduationData gradStatus = createGraduationData("json/gradstatus.json"); @@ -1756,24 +1420,8 @@ public void testGetTranscript() throws Exception { graduationStudentRecord.setStudentID(UUID.fromString(gradSearchStudent.getStudentID())); graduationStudentRecord.setUpdateDate(LocalDateTime.now()); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); - - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); + when(this.restService.get(String.format(constants.getSchoolDetails(), "09323027"), School.class)).thenReturn(schoolDetails); + when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); var result = reportService.getTranscript(graduationStudentRecord, gradStatus, new ExceptionMessage()); @@ -1783,9 +1431,9 @@ public void testGetTranscript() throws Exception { @Test public void testGetTranscriptException() throws Exception { - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); GraduationData gradStatus = createGraduationData("json/gradstatus.json"); assertNotNull(gradStatus); @@ -1800,13 +1448,7 @@ public void testGetTranscriptException() throws Exception { graduationStudentRecord.setStudentID(UUID.fromString(gradSearchStudent.getStudentID())); graduationStudentRecord.setUpdateDate(LocalDateTime.now()); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenThrow(new RuntimeException()); @@ -1829,12 +1471,6 @@ public void testReportDataByPen() throws Exception { final ParameterizedTypeReference> gradSearchStudentResponseType = new ParameterizedTypeReference<>() { }; -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getPenStudentApiByPenUrl(),pen))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(gradSearchStudentResponseType)).thenReturn(Mono.just(List.of(gradSearchStudent))); - when(this.restService.get(String.format(constants.getPenStudentApiByPenUrl(),pen), List.class)).thenReturn(List.of(gradSearchStudent)); StudentCareerProgram studentCareerProgram1 = new StudentCareerProgram(); @@ -1871,95 +1507,45 @@ public void testReportDataByPen() throws Exception { } } -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradProgram.getProgramCode()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradProgram.getProgramCode()), GraduationProgramCode.class)).thenReturn(gradProgram); - -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStudentRecord)); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); programCertificateTranscript.setGraduationProgramCode(gradProgram.getProgramCode()); - programCertificateTranscript.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); + programCertificateTranscript.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); programCertificateTranscript.setCertificateTypeCode("E"); ProgramCertificateReq req = new ProgramCertificateReq(); req.setProgramCode(gradProgram.getProgramCode()); - req.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); + req.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); - when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - - SchoolTrax schtrax = new SchoolTrax(); + School schtrax = new School(); schtrax.setMinCode("00502001"); schtrax.setSchoolName("ROBERT DDGELL"); schtrax.setAddress1("My Address"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolDetails(),schtrax.getMinCode()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SchoolTrax.class)).thenReturn(Mono.just(schtrax)); - - when(this.restService.get(String.format(constants.getSchoolDetails(),schtrax.getMinCode()), SchoolTrax.class)).thenReturn(schtrax); + when(this.restService.get(String.format(constants.getSchoolDetails(),schtrax.getMinCode()), School.class)).thenReturn(schtrax); - DistrictTrax disttrax = new DistrictTrax(); - disttrax.setDistrictNumber("005"); - disttrax.setDistrictName("My District"); - disttrax.setAddress1("My Address"); + District distInstitute = new District(); + distInstitute.setDistrictNumber("005"); + distInstitute.setDisplayName("My District"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getDistrictDetails(),schtrax.getMinCode()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(DistrictTrax.class)).thenReturn(Mono.just(disttrax)); - - when(this.restService.get(String.format(constants.getDistrictDetails(),schtrax.getMinCode()), DistrictTrax.class)).thenReturn(disttrax); + when(this.restService.get(String.format(constants.getDistrictDetails(),schtrax.getMinCode()), District.class)).thenReturn(distInstitute); List programRequirementCodes = new ArrayList<>(); @@ -1988,34 +1574,15 @@ public void testReportDataByPen() throws Exception { programRequirementCodes.add(programRequirementCode); -// ParameterizedTypeReference> programRequirementCodeResponseType = new ParameterizedTypeReference<>() { -// }; -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getProgramRequirementsEndpoint())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(programRequirementCodeResponseType)).thenReturn(Mono.just(programRequirementCodes)); - when(this.restService.get(constants.getProgramRequirementsEndpoint(), List.class)).thenReturn(programRequirementCodes); -// ParameterizedTypeReference> optionalProgramsResponseType = new ParameterizedTypeReference<>() { -// }; - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); studentOptionalProgram.setOptionalProgramCode("DD"); studentOptionalProgram.setOptionalProgramName("Advanced Placement"); studentOptionalProgram.setStudentID(graduationStudentRecord.getStudentID()); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(optionalProgramsResponseType)).thenReturn(Mono.just(List.of(studentOptionalProgram))); - when(this.restService.get(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()), List.class)).thenReturn(List.of(studentOptionalProgram)); - ReportData transcriptData = reportService.prepareTranscriptData(pen, true, exception); assertNotNull(transcriptData); assertNotNull(transcriptData.getStudent()); @@ -2221,71 +1788,33 @@ public void testTranscriptReportByPen() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); - -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStudentRecord)); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); - + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); programCertificateTranscript.setGraduationProgramCode(gradProgram.getProgramCode()); - programCertificateTranscript.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); + programCertificateTranscript.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); programCertificateTranscript.setCertificateTypeCode("E"); ProgramCertificateReq req = new ProgramCertificateReq(); req.setProgramCode(gradProgram.getProgramCode()); - req.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); + req.setSchoolCategoryCode(schoolDetails.getSchoolCategoryCode()); when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - SpecialCase sp = new SpecialCase(); sp.setSpCase("A"); sp.setLabel("AEG"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); - when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - List programRequirementCodes = new ArrayList<>(); ProgramRequirementCode programRequirementCode = new ProgramRequirementCode(); @@ -2312,32 +1841,13 @@ public void testTranscriptReportByPen() throws Exception { programRequirementCodes.add(programRequirementCode); -// ParameterizedTypeReference> programRequirementCodeResponseType = new ParameterizedTypeReference<>() { -// }; - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getProgramRequirementsEndpoint())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(programRequirementCodeResponseType)).thenReturn(Mono.just(programRequirementCodes)); - when(this.restService.get(constants.getProgramRequirementsEndpoint(), List.class)).thenReturn(programRequirementCodes); - -// ParameterizedTypeReference> optionalProgramsResponseType = new ParameterizedTypeReference<>() { -// }; - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); studentOptionalProgram.setOptionalProgramCode("FI"); studentOptionalProgram.setOptionalProgramName("Advanced Placement"); studentOptionalProgram.setStudentID(graduationStudentRecord.getStudentID()); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(optionalProgramsResponseType)).thenReturn(Mono.just(List.of(studentOptionalProgram))); - when(this.restService.get(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()), List.class)).thenReturn(List.of(studentOptionalProgram)); ReportData transcriptData = reportService.prepareTranscriptData(pen, true, exception); @@ -2347,18 +1857,8 @@ public void testTranscriptReportByPen() throws Exception { byte[] bytesSAR = RandomUtils.nextBytes(20); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscriptReport())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(byte[].class)).thenReturn(Mono.just(bytesSAR)); - when(this.restService.post(eq(constants.getTranscriptReport()), any(), eq(byte[].class))).thenReturn(bytesSAR); - byte[] result = graduationService.prepareTranscriptReport(pen, "Interim", "true"); assertNotNull(result); assertNotEquals(0, result.length); @@ -2371,18 +1871,8 @@ public void testTranscriptReportByPenEmpty() throws Exception { assertNotNull(gradStatus); String pen = gradStatus.getGradStudent().getPen(); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscriptReport())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(byte[].class)).thenThrow(new ServiceException("NO_CONTENT", 204)); - when(this.restService.post(eq(constants.getTranscriptReport()), any(), eq(byte[].class))).thenThrow(new ServiceException("NO_CONTENT", 204)); - byte[] result = graduationService.prepareTranscriptReport(pen, "Interim", "true"); assertNotNull(result); assertEquals(0, result.length); @@ -2394,18 +1884,8 @@ public void testTranscriptReportByPenException() throws Exception { GraduationData gradStatus = createGraduationData("json/gradstatus.json"); String pen = gradStatus.getGradStudent().getPen(); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscriptReport())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.onStatus(any(), any())).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(byte[].class)).thenThrow(new ServiceException("INTERNAL_SERVER_ERROR", 500)); - when(this.restService.post(eq(constants.getTranscriptReport()), any(), eq(byte[].class))).thenThrow(new ServiceException("INTERNAL_SERVER_ERROR", 500)); - graduationService.prepareTranscriptReport(pen, "Interim", "true"); } @@ -2430,36 +1910,14 @@ public void testReportDataByGraduationData() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); - -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStudentRecord)); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); - + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -2471,26 +1929,9 @@ public void testReportDataByGraduationData() throws Exception { sp.setSpCase("A"); sp.setLabel("AEG"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); - when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - List programRequirementCodes = new ArrayList<>(); ProgramRequirementCode programRequirementCode = new ProgramRequirementCode(); @@ -2517,35 +1958,15 @@ public void testReportDataByGraduationData() throws Exception { programRequirementCodes.add(programRequirementCode); -// ParameterizedTypeReference> programRequirementCodeResponseType = new ParameterizedTypeReference<>() { -// }; -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(constants.getProgramRequirementsEndpoint())).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(programRequirementCodeResponseType)).thenReturn(Mono.just(programRequirementCodes)); - when(this.restService.get(constants.getProgramRequirementsEndpoint(), List.class)).thenReturn(programRequirementCodes); - -// ParameterizedTypeReference> optionalProgramsResponseType = new ParameterizedTypeReference<>() { -// }; - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); studentOptionalProgram.setOptionalProgramCode("CP"); studentOptionalProgram.setOptionalProgramName("Advanced Placement"); studentOptionalProgram.setStudentID(graduationStudentRecord.getStudentID()); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(optionalProgramsResponseType)).thenReturn(Mono.just(List.of(studentOptionalProgram))); - when(this.restService.get(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()), List.class)).thenReturn(List.of(studentOptionalProgram)); - ReportData data = reportService.prepareTranscriptData(gradStatus, true, exception); assertNotNull(data); assertNotNull(data.getStudent()); @@ -2565,36 +1986,13 @@ public void testReportDataByGraduationData_GSRNULL() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); - - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),gradStatus.getGradStudent().getStudentID()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(null); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),gradStatus.getGradStudent().getStudentID()), GraduationStudentRecord.class)).thenReturn(null); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); - + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -2602,17 +2000,8 @@ public void testReportDataByGraduationData_GSRNULL() throws Exception { programCertificateTranscript.setSchoolCategoryCode("02"); programCertificateTranscript.setCertificateTypeCode("E"); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - ReportData data = reportService.prepareTranscriptData(gradStatus, true, exception); assertNotNull(data); assertNull(data.getStudent()); @@ -2640,27 +2029,9 @@ public void testGetGraduationStudentRecordAndGraduationData() throws Exception { gradSearchStudent.setPen(pen); gradSearchStudent.setStudentID(gradStatus.getGradStudent().getStudentID()); -// final ParameterizedTypeReference> gradSearchStudentResponseType = new ParameterizedTypeReference<>() { -// }; - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getPenStudentApiByPenUrl(),pen))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(gradSearchStudentResponseType)).thenReturn(Mono.just(List.of(gradSearchStudent))); - when(this.restService.get(String.format(constants.getPenStudentApiByPenUrl(),pen), List.class)).thenReturn(List.of(gradSearchStudent)); - - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(Mono.just(graduationStudentRecord)); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), GraduationStudentRecord.class)).thenReturn(graduationStudentRecord); - var result = reportService.getGraduationStudentRecordAndGraduationData(pen); assertNotNull(result); assertNotNull(result.getLeft()); @@ -2681,24 +2052,9 @@ public void testGetGraduationStudentRecordAndGraduationData_Exception() throws E final ParameterizedTypeReference> gradSearchStudentResponseType = new ParameterizedTypeReference<>() { }; -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getPenStudentApiByPenUrl(),pen))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(gradSearchStudentResponseType)).thenReturn(Mono.just(List.of(gradSearchStudent))); - when(this.restService.get(String.format(constants.getPenStudentApiByPenUrl(),pen), List.class)).thenReturn(List.of(gradSearchStudent)); - - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),studentID))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn((null)); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),studentID), GraduationStudentRecord.class)).thenReturn(null); - var result = reportService.getGraduationStudentRecordAndGraduationData(pen); assertNull(result); } @@ -2736,35 +2092,15 @@ public void testReportDataByGraduationData_EXCEPTION() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); - - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(Exception.class)).thenReturn(Mono.just(new Exception())); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()), Exception.class)).thenReturn(new Exception()); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); @@ -2773,17 +2109,8 @@ public void testReportDataByGraduationData_EXCEPTION() throws Exception { programCertificateTranscript.setSchoolCategoryCode("02"); programCertificateTranscript.setCertificateTypeCode("E"); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - ReportData data = reportService.prepareTranscriptData(gradStatus, true, exception); assertNotNull(data); assertNull(data.getStudent()); @@ -2837,26 +2164,13 @@ public void testPrepareCertificateData() throws Exception { studentOptionalProgram.setOptionalProgramName("Advanced Placement"); studentOptionalProgram.setStudentID(graduationStudentRecord.getStudentID()); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(optionalProgramsResponseType)).thenReturn(Mono.just(List.of(studentOptionalProgram))); - when(this.restService.get(String.format(constants.getStudentOptionalPrograms(), graduationStudentRecord.getStudentID()), List.class)).thenReturn(List.of(studentOptionalProgram)); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); @@ -2869,23 +2183,7 @@ public void testPrepareCertificateData() throws Exception { sp.setSpCase("A"); sp.setLabel("AEG"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSpecialCase(),"A"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(SpecialCase.class)).thenReturn(Mono.just(sp)); - when(this.restService.get(String.format(constants.getSpecialCase(),"A"), SpecialCase.class)).thenReturn(sp); - - -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); ReportData data = reportService.prepareCertificateData(gradStatus, exception); @@ -2907,36 +2205,15 @@ public void testPrepareCertificateData_GSRNULL() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); - -// -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),gradStatus.getGradStudent().getStudentID()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationStudentRecord.class)).thenReturn(null); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),gradStatus.getGradStudent().getStudentID()), GraduationStudentRecord.class)).thenReturn(null); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -2944,17 +2221,8 @@ public void testPrepareCertificateData_GSRNULL() throws Exception { programCertificateTranscript.setSchoolCategoryCode("02"); programCertificateTranscript.setCertificateTypeCode("E"); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - ReportData data = reportService.prepareCertificateData(gradStatus, exception); assertNotNull(data); assertNull(data.getStudent()); @@ -2995,36 +2263,15 @@ public void testPrepareCertificateData_EXCEPTION() throws Exception { gradProgram.setProgramCode("2018-EN"); gradProgram.setProgramName("2018 Graduation Program"); -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(GraduationProgramCode.class)).thenReturn(Mono.just(gradProgram)); - when(this.restService.get(String.format(constants.getProgramNameEndpoint(),gradStatus.getGradStudent().getProgram()), GraduationProgramCode.class)).thenReturn(gradProgram); - - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getReadGradStudentRecord(),graduationStudentRecord.getStudentID().toString()))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(Exception.class)).thenReturn(Mono.just(new Exception())); - when(this.restService.get(String.format(constants.getReadGradStudentRecord(),gradStatus.getGradStudent().getStudentID()), Exception.class)).thenReturn(new Exception()); - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(), "09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.just(commSch)); - - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); + School schoolDetails = new School(); + schoolDetails.setMinCode("09323027"); + schoolDetails.setSchoolCategoryCode("02"); + when(this.restService.get(String.format(constants.getSchoolDetails(),"09323027"), School.class)).thenReturn(schoolDetails); ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); programCertificateTranscript.setPcId(UUID.randomUUID()); @@ -3032,17 +2279,8 @@ public void testPrepareCertificateData_EXCEPTION() throws Exception { programCertificateTranscript.setSchoolCategoryCode("02"); programCertificateTranscript.setCertificateTypeCode("E"); -// when(this.webClient.post()).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.uri(constants.getTranscript())).thenReturn(this.requestBodyUriMock); -// when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); -// when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(ProgramCertificateTranscript.class)).thenReturn(Mono.just(programCertificateTranscript)); - when(this.restService.post(eq(constants.getTranscript()), any(), eq(ProgramCertificateTranscript.class))).thenReturn(programCertificateTranscript); - ReportData data = reportService.prepareCertificateData(gradStatus, exception); assertNotNull(data); assertNull(data.getStudent()); @@ -3136,23 +2374,16 @@ public void testRemoveDuplicatedAssessments() throws Exception { @Test public void testGetSchoolCategoryCode() { - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("09323027"); - commSch.setSchoolCategoryCode("02"); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(commSch); - var result = reportService.getSchoolCategoryCode(commSch.getSchlNo()); + School schoolDetails = new School(); + 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()); assertThat(result).isNotNull(); } @Test public void testGetSchoolCategoryCodeNull() { - -// when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"09323027"))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); -// when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); -// when(this.responseMock.bodyToMono(CommonSchool.class)).thenReturn(Mono.empty()); - when(this.restService.get(String.format(constants.getSchoolCategoryCode(),"09323027"), CommonSchool.class)).thenReturn(null); var result = reportService.getSchoolCategoryCode("09323027"); @@ -3200,3 +2431,4 @@ private String readInputStream(InputStream is) throws Exception { return sb.toString(); } } + 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 2c669b0a..447618da 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 @@ -52,7 +52,7 @@ public class SchooReportsServiceTest { @Autowired private SchoolReportsService schoolReportsService; - + @MockBean private ReportService reportService; @@ -67,7 +67,7 @@ public class SchooReportsServiceTest { @Autowired GradValidation validation; - + @MockBean WebClient webClient; @@ -146,12 +146,12 @@ public void testSchoolReports() { when(this.tokenUtils.getAccessToken(any())).thenReturn(Pair.of("accessToken", System.currentTimeMillis())); - SchoolTrax traxSchool = new SchoolTrax(); + ca.bc.gov.educ.api.graduation.model.dto.School traxSchool = new ca.bc.gov.educ.api.graduation.model.dto.School(); traxSchool.setMinCode("12345678"); traxSchool.setAddress1("1231"); when(this.restService.get(any(String.class), any(), any())).thenReturn(traxSchool); - when(this.schoolService.getTraxSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool); + when(this.schoolService.getSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool); mockTokenResponseObject(); @@ -161,13 +161,12 @@ public void testSchoolReports() { reportsCount = schoolReportsService.createAndStoreSchoolReports(DISTREP_SC, "accessToken"); assertTrue(reportsCount > 0); - DistrictTrax disttrax = new DistrictTrax(); + District disttrax = new District(); disttrax.setDistrictNumber("005"); - disttrax.setDistrictName("My District"); - disttrax.setAddress1("My Address"); + disttrax.setDisplayName("My District"); - when(this.schoolService.getTraxSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool); - when(this.schoolService.getTraxDistrictDetails(disttrax.getDistrictNumber())).thenReturn(disttrax); + when(this.schoolService.getSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool); + when(this.schoolService.getDistrictDetails(disttrax.getDistrictNumber())).thenReturn(disttrax); reportsCount = schoolReportsService.createAndStoreDistrictReports(DISTREP_YE_SD, "accessToken"); assertTrue(reportsCount > 0); @@ -273,3 +272,4 @@ private String mockTokenResponseObject() { return mockToken; } } + 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 9126489b..87ce7ba9 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 @@ -30,22 +30,22 @@ @SpringBootTest @ActiveProfiles("test") public class SchoolServiceTest { - - @Autowired - private SchoolService schoolService; - - @Autowired - GradValidation validation; - - @MockBean + + @Autowired + private SchoolService schoolService; + + @Autowired + GradValidation validation; + + @MockBean WebClient webClient; @Autowired private EducGraduationApiConstants constants; - @MockBean - RESTService restService; - + @MockBean + RESTService restService; + @Mock private WebClient.RequestHeadersSpec requestHeadersMock; @Mock @@ -58,39 +58,41 @@ public class SchoolServiceTest { private WebClient.ResponseSpec responseMock; @Mock private Mono monoResponse; - + @Before public void setUp() { openMocks(this); - } + } - @After + @After public void tearDown() { } - @Test - public void testGetSchoolDetails() { - String mincode = "213123131"; - String accessToken = "accessToken"; - SchoolTrax schtrax = new SchoolTrax(); - schtrax.setMinCode(mincode); - schtrax.setAddress1("1231"); - when(this.restService.get(any(String.class), any())).thenReturn(schtrax); - SchoolTrax res = schoolService.getTraxSchoolDetails(mincode, new ExceptionMessage()); - assertNotNull(res); - assertEquals(res.getMinCode(),mincode); - } + @Test + public void testGetSchoolDetails() { + String mincode = "213123131"; + String accessToken = "accessToken"; + School schtrax = new School(); + schtrax.setMinCode(mincode); + schtrax.setAddress1("1231"); + when(this.restService.get(any(String.class), any())).thenReturn(schtrax); + School res = schoolService.getSchoolDetails(mincode); + + assertNotNull(res); + assertEquals(res.getMinCode(),mincode); + } @Test public void testGetSchoolDetailsNoToken() { String mincode = "213123131"; - SchoolTrax schtrax = new SchoolTrax(); + School schtrax = new School(); schtrax.setMinCode(mincode); schtrax.setAddress1("1231"); mockTokenResponseObject(); when(this.restService.get(any(String.class), any())).thenReturn(schtrax); - SchoolTrax res = schoolService.getTraxSchoolDetails(mincode); + School res = schoolService.getSchoolDetails(mincode); + assertNotNull(res); assertEquals(res.getMinCode(),mincode); } @@ -98,12 +100,12 @@ public void testGetSchoolDetailsNoToken() { @Test public void testGetDistrictDetailsNoToken() { String mincode = "213"; - DistrictTrax schtrax = new DistrictTrax(); - schtrax.setDistrictNumber(mincode); - schtrax.setAddress1("1231"); + District schoolDistrict = new District(); + schoolDistrict.setDistrictNumber(mincode); mockTokenResponseObject(); - when(this.restService.get(any(String.class), any())).thenReturn(schtrax); - DistrictTrax res = schoolService.getTraxDistrictDetails(mincode); + when(this.restService.get(any(String.class), any())).thenReturn(schoolDistrict); + District res = schoolService.getDistrictDetails(mincode); + assertNotNull(res); assertEquals(res.getDistrictNumber(),mincode); } @@ -126,3 +128,4 @@ private String mockTokenResponseObject() { } } + diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index b599f683..279b20ad 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -99,9 +99,9 @@ endpoint: program_requirement_codes: url: https://educ-grad-program-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/program/programrequirementcode gradalgorithm-api: - gradalgorithm: https://grad-algorithm-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduatestudent?studentID=%s&gradProgram=%s - projectedgradalgorithm: https://grad-algorithm-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduatestudent?studentID=%s&gradProgram=%s&projected=%b - hypotheticalgradalgorithm: https://educ-grad-algorithm-api-e8a97a-dev.apps.silver.devops.gov.bc.ca/api/v1/graduatestudent?studentID=%s&gradProgram=%s&hypotheticalGradYear=%s + gradalgorithm: https://grad-algorithm-api-e8a97a-test.apps.silver.devops.gov.bc.ca/api/v1/graduatestudent?studentID=%s&gradProgram=%s + projectedgradalgorithm: https://grad-algorithm-api-e8a97a-test.apps.silver.devops.gov.bc.ca/api/v1/graduatestudent?studentID=%s&gradProgram=%s&projected=%b + hypotheticalgradalgorithm: https://educ-grad-algorithm-api-e8a97a-test.apps.silver.devops.gov.bc.ca/api/v1/graduatestudent?studentID=%s&gradProgram=%s&hypotheticalGradYear=%s grad-graduation-report-api: update-grad-student-report: url: https://educ-grad-graduation-report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentreport?isGraduated=%s @@ -145,9 +145,9 @@ endpoint: commonschool-by-mincode: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/common/%s school-by-min-code: - url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/%s + 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/v1/trax/district/%s + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/district/%s #Splunk LogHelper splunk: diff --git a/api/src/test/resources/json/gradstatus.json b/api/src/test/resources/json/gradstatus.json index d3c678a6..aacd16eb 100644 --- a/api/src/test/resources/json/gradstatus.json +++ b/api/src/test/resources/json/gradstatus.json @@ -627,27 +627,13 @@ "districtName": "SOUTHEAST KOOTENAY", "transcriptEligibility": "Y", "certificateEligibility": "Y", - "independentDesignation": "", - "mailerType": "1", "address1": "1410 BAKER STREET", "address2": "", "city": "CRANBROOK", "provCode": "BC", - "provinceName": "BRITISH COLUMBIA", "countryCode": "CN", - "countryName": "CANADA", "postal": "V1C1B2", - "independentAffiliation": "", - "openFlag": "Y", - "signatureDistrict": "", - "newMinCode": "09323027", - "schoolOrg": "S", - "appendTrans": "", - "ministryContact": "P", - "principalName": "MR IAN KENNEDY", - "schoolPhone": "2504265241", - "schoolFax": "2504266673", - "schoolEmail": "" + "openFlag": "Y" }, "studentCourses": { "studentCourseList": [ From 113c4d81171168796ad0fbf35dbe35e9c0f86779 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 28 Oct 2024 15:25:42 -0700 Subject: [PATCH 2/2] Fixed the unit test to improve coverage. Fixed the unit test to improve coverage. --- .../educ/api/graduation/service/SchooReportsServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 447618da..c4433420 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(traxSchool.getMinCode())).thenReturn(traxSchool); + when(this.schoolService.getSchoolDetails(any(String.class))).thenReturn(traxSchool); mockTokenResponseObject(); @@ -165,7 +165,7 @@ public void testSchoolReports() { disttrax.setDistrictNumber("005"); disttrax.setDisplayName("My District"); - when(this.schoolService.getSchoolDetails(traxSchool.getMinCode())).thenReturn(traxSchool); + when(this.schoolService.getSchoolDetails(any(String.class))).thenReturn(traxSchool); when(this.schoolService.getDistrictDetails(disttrax.getDistrictNumber())).thenReturn(disttrax); reportsCount = schoolReportsService.createAndStoreDistrictReports(DISTREP_YE_SD, "accessToken");