diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/StudentLoadType.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/StudentLoadType.java deleted file mode 100644 index 83161033..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/StudentLoadType.java +++ /dev/null @@ -1,5 +0,0 @@ -package ca.bc.gov.educ.api.dataconversion.constant; - -public enum StudentLoadType { - UNGRAD, GRAD_ONE, GRAD_TWO, NONE, NO_UTG -} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java index 50bc6516..6aef3af3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/ConvGradStudent.java @@ -1,8 +1,6 @@ package ca.bc.gov.educ.api.dataconversion.model; import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; -import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; -import ca.bc.gov.educ.api.dataconversion.model.tsw.School; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Builder; @@ -43,17 +41,6 @@ public class ConvGradStudent { // program codes for optional / career program private List programCodes; - // grad or non-grad - private StudentLoadType studentLoadType; - private StudentLoadType originalStudentLoadType; - private Date distributionDate; - private String transcriptSchoolCategoryCode; - private String certificateSchoolCategoryCode; - private School transcriptSchool; - private School certificateSchool; - // tsw - private TranscriptStudentDemog transcriptStudentDemog; - private List transcriptStudentCourses; // 1950 "AD" private boolean adult19Rule; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java deleted file mode 100644 index 8cd7b9af..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcess.java +++ /dev/null @@ -1,496 +0,0 @@ -package ca.bc.gov.educ.api.dataconversion.process; - -import ca.bc.gov.educ.api.dataconversion.model.ConvGradStudent; -import ca.bc.gov.educ.api.dataconversion.model.StudentCareerProgram; -import ca.bc.gov.educ.api.dataconversion.model.tsw.GradProgram; -import ca.bc.gov.educ.api.dataconversion.model.tsw.GradRequirement; -import ca.bc.gov.educ.api.dataconversion.model.tsw.GraduationData; -import ca.bc.gov.educ.api.dataconversion.model.tsw.School; -import ca.bc.gov.educ.api.dataconversion.model.tsw.*; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.*; -import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; -import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; -import ca.bc.gov.educ.api.dataconversion.util.Generated; -import ca.bc.gov.educ.api.dataconversion.util.RestUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.nio.charset.StandardCharsets; -import java.text.DecimalFormat; -import java.util.*; -import java.util.stream.Collectors; - -@Component -@Slf4j -public class ReportProcess { - - private static final String DOCUMENT_STATUS_COMPLETED = "COMPL"; - - @Autowired - RestUtils restUtils; - - @Autowired - EducGradDataConversionApiConstants constants; - - public ReportData prepareTranscriptData(GraduationData graduationDataStatus, GradAlgorithmGraduationStudentRecord gradResponse, ConvGradStudent convStudent, String accessToken) { - ReportData data = new ReportData(); - data.setSchool(getSchoolData(graduationDataStatus.getSchool())); - data.setStudent(getStudentData(graduationDataStatus.getGradStudent())); - data.setGradMessage(graduationDataStatus.getGradMessage()); - data.setGradProgram(getGradProgram(graduationDataStatus, accessToken)); - data.setGraduationData(getGraduationData(graduationDataStatus)); - data.setLogo(StringUtils.startsWith(data.getSchool().getMincode(), "098") ? "YU" : "BC"); - data.setTranscript(getTranscriptData(graduationDataStatus, gradResponse, convStudent, accessToken)); - data.setNonGradReasons(getNonGradReasons(graduationDataStatus.getGradStatus().getProgram(), graduationDataStatus.getNonGradReasons())); - return data; - } - - private List getNonGradReasons(String gradProgramCode, List nonGradReasons) { - List nList = new ArrayList<>(); - if(nonGradReasons != null && !nonGradReasons.isEmpty()) { - nonGradReasons.removeIf(a -> "506".equalsIgnoreCase(a.getRule()) && (StringUtils.isNotBlank(gradProgramCode) && gradProgramCode.contains("1950"))); - for (GradRequirement gR : nonGradReasons) { - NonGradReason obj = new NonGradReason(); - obj.setCode(gR.getRule()); - obj.setDescription(gR.getDescription()); - nList.add(obj); - } - } - return nList; - } - - private Transcript getTranscriptData(GraduationData graduationDataStatus, GradAlgorithmGraduationStudentRecord gradResponse, ConvGradStudent convStudent, String accessToken) { - Transcript transcriptData = new Transcript(); - transcriptData.setInterim("false"); - ProgramCertificateTranscript pcObj = restUtils.getTranscript(gradResponse.getProgram(), - convStudent.getTranscriptSchoolCategoryCode(), accessToken); - if (pcObj != null) { - Code code = new Code(); - code.setCode(pcObj.getTranscriptTypeCode()); - transcriptData.setTranscriptTypeCode(code); - } - transcriptData.setIssueDate(graduationDataStatus.getGradStatus().getLastUpdateDate()); - transcriptData.setResults(getTranscriptResults(graduationDataStatus, accessToken)); - return transcriptData; - } - - private void createCourseListForTranscript(List studentCourseList, GraduationData graduationDataStatus, List tList, String provincially) { - for (StudentCourse sc : studentCourseList) { - TranscriptResult result = new TranscriptResult(); - String equivOrChallenge = ""; - if (sc.getEquivOrChallenge() != null) { - equivOrChallenge = sc.getEquivOrChallenge(); - } - result.setCourse(setCourseObjForTranscript(sc, graduationDataStatus)); - result.setMark(setMarkObjForTranscript(sc, graduationDataStatus.getGradStatus().getProgram(), provincially)); - result.setRequirement(sc.getGradReqMet()); - result.setRequirementName(sc.getGradReqMetDetail()); - result.setUsedForGrad(sc.getCreditsUsedForGrad() != null ? sc.getCreditsUsedForGrad().toString() : ""); - result.setEquivalency(sc.getSpecialCase() != null? sc.getSpecialCase() : equivOrChallenge); - tList.add(result); - } - } - - private TranscriptCourse setCourseObjForTranscript(StudentCourse sc, GraduationData graduationDataStatus) { - TranscriptCourse crse = new TranscriptCourse(); - crse.setCode(sc.getCourseCode()); - crse.setCredits(getCredits(graduationDataStatus.getGradStatus().getProgram(), sc.getCourseCode(), sc.getCredits(), sc.isRestricted())); - crse.setLevel(sc.getCourseLevel()); - crse.setName(sc.getCourseName()); - - crse.setRelatedCourse(sc.getRelatedCourse()); - crse.setRelatedLevel(sc.getRelatedLevel()); - crse.setType(sc.getProvExamCourse().equals("Y") ? "1" : "2"); - crse.setSessionDate(sc.getSessionDate() != null ? sc.getSessionDate().replace("/", "") : ""); - return crse; - } - - private Mark setMarkObjForTranscript(StudentCourse sc, String program, String provincially) { - Mark mrk = new Mark(); - mrk.setExamPercent(getExamPercent(sc.getBestExamPercent(), program, sc.getCourseLevel(), sc.getSpecialCase(), sc.getSessionDate(), sc.getExamPercent())); - mrk.setFinalLetterGrade(sc.getCompletedCourseLetterGrade()); - mrk.setFinalPercent(getFinalPercent(getValue(sc.getCompletedCoursePercentage()), sc.getSessionDate(), provincially)); - mrk.setInterimLetterGrade(sc.getInterimLetterGrade()); - mrk.setInterimPercent(getValue(sc.getInterimPercent())); - mrk.setSchoolPercent(getSchoolPercent(sc.getBestSchoolPercent(), program, sc.getCourseLevel(), sc.getSessionDate(), sc.getSchoolPercent())); - return mrk; - } - - private String getExamPercent(Double bestExamPercent, String program, String courseLevel, String specialCase, String sDate, Double examPercent) { - String res = checkCutOffCourseDate(sDate, examPercent); - if (res == null) { - String bExam = getValue(bestExamPercent); - if (specialCase != null && specialCase.compareTo("A") == 0) { - return "AEG"; - } else if ((program.contains("2004") || program.contains("2018")) && !courseLevel.contains("12")) { - return ""; - } else { - return bExam; - } - } - return res; - } - - private String checkCutOffCourseDate(String sDate, Double value) { - String cutoffDate = "1991-11-01"; - String sessionDate = sDate + "/01"; - Date temp = EducGradDataConversionApiUtils.parseDate(sessionDate, EducGradDataConversionApiConstants.SECONDARY_DATE_FORMAT); - sessionDate = EducGradDataConversionApiUtils.formatDate(temp, EducGradDataConversionApiConstants.DEFAULT_DATE_FORMAT); - - int diff = EducGradDataConversionApiUtils.getDifferenceInMonths(sessionDate, cutoffDate); - - if (diff > 0) { - return getValue(value); - } else { - return null; - } - } - - private String getSchoolPercent(Double bestSchoolPercent, String program, String courseLevel, String sDate, Double schoolPercent) { - - String res = checkCutOffCourseDate(sDate, schoolPercent); - if (res == null) { - String sExam = getValue(bestSchoolPercent); - if ((program.contains("2004") || program.contains("2018")) && !courseLevel.contains("12")) { - return ""; - } else { - return sExam; - } - } - return res; - } - - private void createAssessmentListForTranscript(List studentAssessmentList, List tList, String accessToken) { - for (StudentAssessment sc : studentAssessmentList) { - TranscriptResult result = new TranscriptResult(); - TranscriptCourse crse = new TranscriptCourse(); - crse.setCode(sc.getAssessmentCode()); - crse.setLevel(""); - crse.setCredits("NA"); - crse.setName(sc.getAssessmentName()); - crse.setType("3"); - crse.setSessionDate(sc.getSessionDate() != null ? sc.getSessionDate().replace("/", "") : ""); - result.setCourse(crse); - - Mark mrk = new Mark(); - - mrk.setExamPercent(""); - mrk.setFinalLetterGrade(""); - mrk.setInterimLetterGrade(""); - mrk.setInterimPercent(""); - mrk.setSchoolPercent(""); - mrk.setFinalLetterGrade("NA"); - mrk.setFinalPercent(getAssessmentFinalPercentTranscript(sc, accessToken)); - result.setMark(mrk); - result.setRequirement(sc.getGradReqMet()); - result.setRequirementName(sc.getGradReqMetDetail()); - if (!tList.contains(result)) { - tList.add(result); - } - } - } - - private List getTranscriptResults(GraduationData graduationDataStatus, String accessToken) { - List tList = new ArrayList<>(); - String program = graduationDataStatus.getGradStatus().getProgram(); - List studentCourseList = graduationDataStatus.getStudentCourses().getStudentCourseList(); - if (!studentCourseList.isEmpty()) { - if (program.contains("1950") || program.contains("1986")) { - List provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).collect(Collectors.toList()); - if (!provinciallyExaminable.isEmpty()) { - sortOnCourseCode(provinciallyExaminable); - createCourseListForTranscript(provinciallyExaminable, graduationDataStatus, tList, "provincially"); - } - - List nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).collect(Collectors.toList()); - if (!nonExaminable.isEmpty()) { - sortOnCourseCode(nonExaminable); - createCourseListForTranscript(nonExaminable, graduationDataStatus, tList, "non-examinable"); - } - } else { - studentCourseList.sort(Comparator.comparing(StudentCourse::getCourseLevel, Comparator.nullsLast(String::compareTo)).thenComparing(StudentCourse::getCourseName)); - createCourseListForTranscript(studentCourseList, graduationDataStatus, tList, "regular"); - } - } - List studentAssessmentList = graduationDataStatus.getStudentAssessments().getStudentAssessmentList(); - if (studentAssessmentList == null) { - studentAssessmentList = new ArrayList<>(); - } - if (!studentAssessmentList.isEmpty()) { - studentAssessmentList.sort(Comparator.comparing(StudentAssessment::getAssessmentCode)); - } - - createAssessmentListForTranscript(studentAssessmentList, tList, accessToken); - return tList; - } - - private void sortOnCourseCode(List cList) { - cList.sort(Comparator.comparing(StudentCourse::getCourseCode)); - } - - private String getCredits(String program, String courseCode, Integer totalCredits, boolean isRestricted) { - if (((program.contains("2004") || program.contains("2018") || program.contains("2023")) && (courseCode.startsWith("X") || courseCode.startsWith("CP"))) || isRestricted) { - return String.format("(%s)", totalCredits); - } - return String.valueOf(totalCredits); - } - - private String getFinalPercent(String finalCompletedPercentage, String sDate, String provincially) { - String cutoffDate = "1994-09-01"; - String sessionDate = sDate + "/01"; - if (provincially.equalsIgnoreCase("provincially")) { - return finalCompletedPercentage; - } - Date temp = EducGradDataConversionApiUtils.parseDate(sessionDate, EducGradDataConversionApiConstants.SECONDARY_DATE_FORMAT); - sessionDate = EducGradDataConversionApiUtils.formatDate(temp, EducGradDataConversionApiConstants.DEFAULT_DATE_FORMAT); - - int diff = EducGradDataConversionApiUtils.getDifferenceInMonths(sessionDate, cutoffDate); - - if (diff >= 0) { - return "---"; - } else { - return finalCompletedPercentage; - } - } - - private String getAssessmentFinalPercentTranscript(StudentAssessment sA, String accessToken) { - String finalPercent = getValue(sA.getProficiencyScore()); - if ((sA.getAssessmentCode().equalsIgnoreCase("LTE10") || sA.getAssessmentCode().equalsIgnoreCase("LTP10")) && (sA.getSpecialCase() == null || StringUtils.isBlank(sA.getSpecialCase().trim())) && StringUtils.isNotBlank(finalPercent)) { - finalPercent = "RM"; - } - if (sA.getSpecialCase() != null && StringUtils.isNotBlank(sA.getSpecialCase().trim()) && !sA.getSpecialCase().equalsIgnoreCase("X") && !sA.getSpecialCase().equalsIgnoreCase("Q")) { - SpecialCase spC = this.restUtils.getSpecialCase(sA.getSpecialCase(), accessToken); - finalPercent = spC != null ? spC.getLabel() : ""; - } - return finalPercent; - } - - private String getValue(Double value) { - return value != null && value != 0.0 ? new DecimalFormat("#").format(value) : ""; - } - - private ca.bc.gov.educ.api.dataconversion.model.tsw.report.GraduationData getGraduationData( - GraduationData graduationDataStatus) { - ca.bc.gov.educ.api.dataconversion.model.tsw.report.GraduationData data = new ca.bc.gov.educ.api.dataconversion.model.tsw.report.GraduationData(); - data.setDogwoodFlag(graduationDataStatus.isDualDogwood()); - if (graduationDataStatus.isGraduated()) { - if (!graduationDataStatus.getGradStatus().getProgram().equalsIgnoreCase("SCCP")) { - if (graduationDataStatus.getGradStatus().getProgramCompletionDate() != null) { - if (graduationDataStatus.getGradStatus().getProgramCompletionDate().length() > 7) { - data.setGraduationDate(EducGradDataConversionApiUtils.formatIssueDateForReportJasper(graduationDataStatus.getGradStatus().getProgramCompletionDate())); - } else { - data.setGraduationDate(EducGradDataConversionApiUtils.formatIssueDateForReportJasper(EducGradDataConversionApiUtils.parsingNFormating(graduationDataStatus.getGradStatus().getProgramCompletionDate()))); - } - } - data.setHonorsFlag(StringUtils.equals(graduationDataStatus.getGradStatus().getHonoursStanding(), "Y")); - } else { - data.setGraduationDate(EducGradDataConversionApiUtils.formatIssueDateForReportJasper(EducGradDataConversionApiUtils.parsingNFormating(graduationDataStatus.getGradStatus().getProgramCompletionDate()))); - } - } - - if (graduationDataStatus.getOptionalGradStatus() != null) { - for (GradAlgorithmOptionalStudentProgram op : graduationDataStatus.getOptionalGradStatus()) { - switch (op.getOptionalProgramCode()) { - case "FR": - case "DD": - case "FI": - break; - case "CP": - setGraduationDataSpecialPrograms(data, op.getCpList()); - break; - default: // "AD", "BC", "BD" - data.getProgramCodes().add(op.getOptionalProgramCode()); - break; - } - } - } - - return data; - } - - @Generated - private void setGraduationDataSpecialPrograms(ca.bc.gov.educ.api.dataconversion.model.tsw.report.GraduationData data, List studentCareerPrograms) { - if (studentCareerPrograms != null) { - for (StudentCareerProgram cp : studentCareerPrograms) { - data.getProgramCodes().add(cp.getCareerProgramCode()); - } - } - } - - private ca.bc.gov.educ.api.dataconversion.model.tsw.report.GradProgram getGradProgram(GraduationData graduationDataStatus, String accessToken) { - ca.bc.gov.educ.api.dataconversion.model.tsw.report.GradProgram gPgm = new ca.bc.gov.educ.api.dataconversion.model.tsw.report.GradProgram(); - Code code = new Code(); - if (graduationDataStatus.getGradStatus().getProgram() != null) { - GradProgram gradProgram = this.restUtils.getGradProgram(graduationDataStatus.getGradStatus().getProgram(), accessToken); - if (gradProgram != null) { - code.setDescription(gradProgram.getProgramName()); - code.setName(gradProgram.getProgramName()); - } - } - code.setCode(graduationDataStatus.getGradStatus().getProgram()); - gPgm.setCode(code); - return gPgm; - } - - private Student getStudentData(GradSearchStudent gradStudent) { - Student std = new Student(); - std.setBirthdate(EducGradDataConversionApiUtils.parseDate(gradStudent.getDob())); - std.setGrade(gradStudent.getStudentGrade()); - std.setStudStatus(gradStudent.getStudentStatus()); - std.setFirstName(gradStudent.getLegalFirstName()); - std.setMiddleName(gradStudent.getLegalMiddleNames()); - std.setLastName(gradStudent.getLegalLastName()); - std.setGender(gradStudent.getGenderCode()); - std.setCitizenship(gradStudent.getStudentCitizenship()); - Pen pen = new Pen(); - pen.setPen(gradStudent.getPen()); - pen.setEntityID(gradStudent.getStudentID()); - std.setPen(pen); - return std; - } - - - private ca.bc.gov.educ.api.dataconversion.model.tsw.report.School getSchoolData(School school) { - ca.bc.gov.educ.api.dataconversion.model.tsw.report.School schObj = new ca.bc.gov.educ.api.dataconversion.model.tsw.report.School(); - Address addRess = new Address(); - addRess.setCity(school.getCity()); - addRess.setCode(school.getPostal()); - addRess.setCountry(school.getCountryCode()); - addRess.setRegion(school.getProvCode()); - addRess.setStreetLine1(school.getAddress1()); - addRess.setStreetLine2(school.getAddress2()); - schObj.setTypeIndicator(school.getIndependentDesignation()); - schObj.setAddress(addRess); - schObj.setMincode(school.getMinCode()); - schObj.setName(school.getSchoolName()); - schObj.setSignatureCode(school.getMinCode().substring(0, 3)); - schObj.setDistno(school.getMinCode().substring(0, 3)); - schObj.setSchlno(school.getMinCode()); - schObj.setStudents(new ArrayList<>()); - return schObj; - } - - public void saveStudentTranscriptReportJasper(ReportData sample, Date distributionDate, String accessToken, UUID studentID, boolean isGraduated, boolean reload) { - - String encodedPdfReportTranscript = generateStudentTranscriptReportJasper(sample, accessToken); - if(encodedPdfReportTranscript != null) { - GradStudentTranscripts requestObj = new GradStudentTranscripts(); - requestObj.setTranscript(encodedPdfReportTranscript); - requestObj.setStudentID(studentID); - requestObj.setTranscriptTypeCode(sample.getTranscript().getTranscriptTypeCode().getCode()); - requestObj.setDocumentStatusCode("IP"); - requestObj.setDistributionDate(distributionDate); - requestObj.setOverwrite(reload); - if (isGraduated) - requestObj.setDocumentStatusCode(DOCUMENT_STATUS_COMPLETED); - - this.restUtils.saveGradStudentTranscript(requestObj, isGraduated, accessToken); - } - } - - private String generateStudentTranscriptReportJasper(ReportData sample,String accessToken) { - ReportOptions options = new ReportOptions(); - options.setReportFile("transcript"); - options.setReportName("Transcript Report.pdf"); - ReportRequest reportParams = new ReportRequest(); - reportParams.setOptions(options); - reportParams.setData(sample); - byte[] bytesSAR = this.restUtils.getTranscriptReport(reportParams, accessToken); - if(bytesSAR != null && bytesSAR.length > 0) { - byte[] encoded = org.apache.commons.codec.binary.Base64.encodeBase64(bytesSAR); - return new String(encoded, StandardCharsets.US_ASCII); - } - return null; - } - - public List getCertificateList(GraduationData graduationDataStatus, String schoolCategoryCode, String accessToken) { - ProgramCertificateReq req = new ProgramCertificateReq(); - req.setProgramCode(graduationDataStatus.getGradStatus().getProgram()); - for (GradAlgorithmOptionalStudentProgram optionalPrograms : graduationDataStatus.getOptionalGradStatus()) { - if (optionalPrograms.getOptionalProgramCode().equals("FI") || optionalPrograms.getOptionalProgramCode().equals("DD") || optionalPrograms.getOptionalProgramCode().equals("FR")) { - req.setOptionalProgram(optionalPrograms.getOptionalProgramCode()); - break; - } - } - req.setSchoolCategoryCode(schoolCategoryCode); - return this.restUtils.getProgramCertificateTranscriptList(req, accessToken); - } - - public ReportData prepareCertificateData(GraduationData graduationDataStatus, ProgramCertificateTranscript certType, ConvGradStudent convStudent, String accessToken) { - ReportData data = new ReportData(); - if (convStudent.getCertificateSchool() != null) { - data.setSchool(getSchoolData(convStudent.getCertificateSchool())); - } else { - data.setSchool(getSchoolData(convStudent.getTranscriptSchool())); - } - data.setStudent(getStudentData(graduationDataStatus.getGradStudent())); - data.setGradProgram(getGradProgram(graduationDataStatus,accessToken)); - data.setGraduationData(getGraduationData(graduationDataStatus)); - data.setUpdateDate(EducGradDataConversionApiUtils.formatDate(new Date())); - data.setCertificate(getCertificateData(graduationDataStatus.getGradStatus(),certType)); - if(certType.getCertificateTypeCode().equalsIgnoreCase("E") || certType.getCertificateTypeCode().equalsIgnoreCase("A") || certType.getCertificateTypeCode().equalsIgnoreCase("EI") || certType.getCertificateTypeCode().equalsIgnoreCase("AI")) { - data.getStudent().setEnglishCert(certType.getCertificateTypeCode()); - } else if(certType.getCertificateTypeCode().equalsIgnoreCase("F") || certType.getCertificateTypeCode().equalsIgnoreCase("S") || certType.getCertificateTypeCode().equalsIgnoreCase("SCF")) { - data.getStudent().setFrenchCert(certType.getCertificateTypeCode()); - } - return data; - } - - @Generated - public void saveStudentCertificateReportJasper(GraduationData graduationDataStatus, ConvGradStudent convStudent, - String accessToken, ProgramCertificateTranscript certType, boolean reload) { - ReportData certData = prepareCertificateData(graduationDataStatus, certType, convStudent, accessToken); - String encodedPdfReportCertificate = generateStudentCertificateReportJasper(certData,accessToken); - GradStudentCertificates requestObj = new GradStudentCertificates(); - requestObj.setPen(graduationDataStatus.getGradStatus().getPen()); - requestObj.setStudentID(graduationDataStatus.getGradStatus().getStudentID()); - requestObj.setCertificate(encodedPdfReportCertificate); - requestObj.setGradCertificateTypeCode(certType.getCertificateTypeCode()); - requestObj.setDocumentStatusCode(DOCUMENT_STATUS_COMPLETED); - requestObj.setDistributionDate(convStudent.getDistributionDate()); - requestObj.setOverwrite(reload); - this.restUtils.saveGradStudentCertificate(requestObj, accessToken); - } - - private Certificate getCertificateData(GradAlgorithmGraduationStudentRecord gradResponse,ProgramCertificateTranscript certData) { - Certificate cert = new Certificate(); - Date issuedDate = null; - if (gradResponse.getProgramCompletionDate() != null) { - if (gradResponse.getProgramCompletionDate().length() > 7) { - issuedDate = EducGradDataConversionApiUtils.formatIssueDateForReportJasper(gradResponse.getProgramCompletionDate()); - } else { - issuedDate = EducGradDataConversionApiUtils.formatIssueDateForReportJasper(EducGradDataConversionApiUtils.parsingNFormating(gradResponse.getProgramCompletionDate())); - } - } - cert.setIssued(issuedDate); - - OrderType orTy = new OrderType(); - orTy.setName("Certificate"); - CertificateType certType = new CertificateType(); - PaperType pType = new PaperType(); - pType.setCode(certData.getCertificatePaperType()); - certType.setPaperType(pType); - certType.setReportName(certData.getCertificateTypeCode()); - orTy.setCertificateType(certType); - cert.setOrderType(orTy); - cert.setCertStyle("Original"); - return cert; - } - - @Generated - private String generateStudentCertificateReportJasper(ReportData sample, - String accessToken) { - ReportOptions options = new ReportOptions(); - options.setReportFile("certificate"); - options.setReportName("Certificate.pdf"); - ReportRequest reportParams = new ReportRequest(); - reportParams.setOptions(options); - reportParams.setData(sample); - byte[] bytesSAR = this.restUtils.getCertificateReport(reportParams, accessToken); - byte[] encoded = Base64.encodeBase64(bytesSAR); - return new String(encoded,StandardCharsets.US_ASCII); - } -} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java index c6308121..1fd8f1cb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcess.java @@ -4,26 +4,18 @@ import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; import ca.bc.gov.educ.api.dataconversion.model.StudentCourse; -import ca.bc.gov.educ.api.dataconversion.model.tsw.*; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportData; import ca.bc.gov.educ.api.dataconversion.service.student.StudentBaseService; import ca.bc.gov.educ.api.dataconversion.util.RestUtils; import ca.bc.gov.educ.api.dataconversion.util.*; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.tuple.Pair; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; import static ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants.DEFAULT_CREATED_BY; import static ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants.DEFAULT_UPDATED_BY; @@ -38,44 +30,20 @@ public class StudentProcess extends StudentBaseService { private final RestUtils restUtils; private final AssessmentProcess assessmentProcess; private final CourseProcess courseProcess; - private final ReportProcess reportProcess; - - /** - * The Program Rules map. - */ - private final Map> programRuleMap = new ConcurrentHashMap<>(); - - /** - * The Special Case map. - */ - private final Map specialCaseMap = new ConcurrentHashMap<>(); @Autowired public StudentProcess(RestUtils restUtils, AssessmentProcess assessmentProcess, - CourseProcess courseProcess, - ReportProcess reportProcess) { + CourseProcess courseProcess) { this.restUtils = restUtils; this.assessmentProcess = assessmentProcess; this.courseProcess = courseProcess; - this.reportProcess = reportProcess; - } - - public void clearMaps() { - programRuleMap.clear(); - specialCaseMap.clear(); } public ConvGradStudent convertStudent(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, boolean reload, boolean ongoingUpdate) throws Exception { long startTime = System.currentTimeMillis(); summary.setProcessedCount(summary.getProcessedCount() + 1L); - // School validation - validateSchool(convGradStudent, summary); - if (ConversionResultType.FAILURE == convGradStudent.getResult()) { // Grad Trax API is failed - return convGradStudent; - } - // PEN Student List students = getStudentsFromPEN(convGradStudent, summary); if (ConversionResultType.FAILURE == convGradStudent.getResult()) { // PEN Student API is failed @@ -98,18 +66,6 @@ public ConvGradStudent convertStudent(ConvGradStudent convGradStudent, Conversio return convGradStudent; } - private void validateSchool(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary) { - // School Category Code form School API - if (convGradStudent.getStudentLoadType() != StudentLoadType.UNGRAD && StringUtils.isBlank(convGradStudent.getTranscriptSchoolCategoryCode())) { - handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, "School does not exist in SPM School data : mincode [" + convGradStudent.getSchoolOfRecord() + "]"); - return; - } - // TRAX School validation - if (convGradStudent.getTranscriptSchool() == null) { - handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, "Invalid school of record " + convGradStudent.getSchoolOfRecord()); - } - } - private List getStudentsFromPEN(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary) { List students = null; try { @@ -122,80 +78,15 @@ private List getStudentsFromPEN(ConvGradStudent convGradStudent, Conver return students; } - /** - * - * @return true Valid - * false Bad data (programCompletionDate is null) - */ - private boolean validateProgramCompletionDate(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary) { - switch(convGradStudent.getStudentLoadType()) { - case GRAD_ONE -> { - if (!"SCCP".equalsIgnoreCase(convGradStudent.getGraduationRequirementYear()) && - convGradStudent.getProgramCompletionDate() == null) { - handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, "Bad data: grad_date is null for " + convGradStudent.getGraduationRequirementYear()); - return false; - } - if ("SCCP".equalsIgnoreCase(convGradStudent.getGraduationRequirementYear()) && - StringUtils.isBlank(convGradStudent.getSlpDate())) { - handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, "Bad data: slp_date is null for SCCP"); - return false; - } - } - case GRAD_TWO -> { - if (!"SCCP".equalsIgnoreCase(convGradStudent.getGraduationRequirementYear()) && - StringUtils.isBlank(convGradStudent.getSccDate())) { - handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, "Bad data for graduated - 2 programs: scc_date is null for " + convGradStudent.getGraduationRequirementYear()); - return false; - } - } - default -> { - return true; - } - } - return true; - } - private void process(ConvGradStudent convGradStudent, List students, ConversionStudentSummaryDTO summary, boolean reload, boolean ongoingUpdate) { - convGradStudent.setOriginalStudentLoadType(convGradStudent.getStudentLoadType()); - switch (convGradStudent.getStudentLoadType()) { - case UNGRAD -> { - log.debug("Process Non-Graduated Student for pen# : " + convGradStudent.getPen()); - processConversion(convGradStudent, students, summary, reload, ongoingUpdate); - } - case GRAD_ONE -> { - log.debug("Process Graduated Student - 1 Program for pen# : " + convGradStudent.getPen()); - processConversion(convGradStudent, students, summary, reload, ongoingUpdate); - } - case GRAD_TWO -> { - log.debug("Process Graduated Student - 2 Programs for pen# : " + convGradStudent.getPen()); - // phase 1 - String graduationRequirementYear = convGradStudent.getGraduationRequirementYear(); - convGradStudent.setGraduationRequirementYear("SCCP"); - convGradStudent.setStudentLoadType(StudentLoadType.GRAD_ONE); - processConversion(convGradStudent, students, summary, reload, ongoingUpdate); - // phase 2 - convGradStudent.setGraduationRequirementYear(graduationRequirementYear); - convGradStudent.setSccDate(null); - convGradStudent.setSlpDate(null); - if (convGradStudent.getProgramCompletionDate() != null) { - convGradStudent.setStudentLoadType(StudentLoadType.GRAD_ONE); - } else { - convGradStudent.setStudentLoadType(StudentLoadType.UNGRAD); - } - processConversion(convGradStudent, students, summary, false, ongoingUpdate); - } - default -> log.debug("skip process"); - } - } - - private void processConversion(ConvGradStudent convGradStudent, List students, ConversionStudentSummaryDTO summary, boolean reload, boolean ongoingUpdate) { + log.debug("Process Non-Graduated Student for pen# : " + convGradStudent.getPen()); students.forEach(st -> { if (reload) { restUtils.removeAllStudentRelatedData(UUID.fromString(st.getStudentID()), summary.getAccessToken()); } GraduationStudentRecord gradStudent = processStudent(convGradStudent, st, ongoingUpdate, summary); if (gradStudent != null) { - processDependencies(convGradStudent, gradStudent, st, summary, reload, ongoingUpdate); + processDependencies(convGradStudent, gradStudent, summary); } if (convGradStudent.getResult() == null) { @@ -216,11 +107,7 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, } if (gradStudent != null) { // update gradStudent.setPen(penStudent.getPen()); - if (convGradStudent.getStudentLoadType() == StudentLoadType.UNGRAD) { - convertStudentData(convGradStudent, penStudent, gradStudent, summary); - } else { - convertGraduatedStudentData(convGradStudent, penStudent, gradStudent, summary); - } + convertStudentData(convGradStudent, penStudent, gradStudent, summary); if (ConversionResultType.FAILURE != convGradStudent.getResult()) { gradStudent.setUpdateDate(null); gradStudent.setUpdateUser(null); @@ -237,11 +124,7 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, gradStudent = new GraduationStudentRecord(); gradStudent.setPen(penStudent.getPen()); gradStudent.setStudentID(studentID); - if (convGradStudent.getStudentLoadType() == StudentLoadType.UNGRAD) { - convertStudentData(convGradStudent, penStudent, gradStudent, summary); - } else { - convertGraduatedStudentData(convGradStudent, penStudent, gradStudent, summary); - } + convertStudentData(convGradStudent, penStudent, gradStudent, summary); if (ConversionResultType.FAILURE != convGradStudent.getResult()) { try { gradStudent = restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, ongoingUpdate, summary.getAccessToken()); @@ -262,79 +145,23 @@ private GraduationStudentRecord processStudent(ConvGradStudent convGradStudent, private void processDependencies(ConvGradStudent convGradStudent, GraduationStudentRecord gradStudent, - Student penStudent, - ConversionStudentSummaryDTO summary, - boolean reload, boolean ongoingUpdate) { + ConversionStudentSummaryDTO summary) { ConversionResultType result; // process dependencies gradStudent.setPen(convGradStudent.getPen()); - if (convGradStudent.getStudentLoadType() == StudentLoadType.UNGRAD) { - result = processOptionalPrograms(gradStudent, summary); - } else { - result = processOptionalProgramsForGraduatedStudent(convGradStudent, gradStudent, summary); - } + result = processOptionalPrograms(gradStudent, summary); if (ConversionResultType.FAILURE != result) { - result = processProgramCodes(gradStudent, convGradStudent.getProgramCodes(), convGradStudent.getStudentLoadType(), convGradStudent.getOriginalStudentLoadType(), summary); + result = processProgramCodes(gradStudent, convGradStudent.getProgramCodes(), summary); } - if (ConversionResultType.FAILURE != result && convGradStudent.getStudentLoadType() == StudentLoadType.UNGRAD) { + if (ConversionResultType.FAILURE != result) { result = processSccpFrenchCertificates(gradStudent, summary); } - if (convGradStudent.getStudentLoadType() != StudentLoadType.UNGRAD && !StringUtils.equalsIgnoreCase(gradStudent.getStudentStatus(), STUDENT_STATUS_MERGED)) { - // Building GraduationData CLOB data - GraduationData graduationData = buildGraduationData(convGradStudent, gradStudent, penStudent, summary); - try { - gradStudent.setStudentGradData(JsonUtil.getJsonStringFromObject(graduationData)); - } catch (JsonProcessingException jpe) { - log.error("Json Parsing Error for StudentGradData: " + jpe.getLocalizedMessage()); - } - try { - restUtils.saveStudentGradStatus(penStudent.getStudentID(), gradStudent, ongoingUpdate, summary.getAccessToken()); - } catch (Exception e) { - handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "updating a GraduationStudentRecord with clob data : " + e.getLocalizedMessage()); - } - if (convGradStudent.getDistributionDate() == null) { - Date distributionDate = null; - if (!"SCCP".equalsIgnoreCase(convGradStudent.getProgram())) { - distributionDate = DateConversionUtils.getLastDayOfMonth(convGradStudent.getProgramCompletionDate()); - } else { - distributionDate = DateConversionUtils.convertStringToDate(convGradStudent.getSccDate()); - } - convGradStudent.setDistributionDate(distributionDate); - } - processReports(graduationData, convGradStudent, summary, reload); - } convGradStudent.setResult(result); } - private void processReports(GraduationData graduationData, ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, boolean reload) { - if (convGradStudent.getTranscriptSchool() != null && "Y".equalsIgnoreCase(convGradStudent.getTranscriptSchool().getTranscriptEligibility())) { - fetchAccessToken(summary); - createAndStoreStudentTranscript(graduationData, convGradStudent, summary.getAccessToken(), reload); - } - if (convGradStudent.getCertificateSchool() != null && "Y".equalsIgnoreCase(convGradStudent.getCertificateSchool().getCertificateEligibility())) { - fetchAccessToken(summary); - createAndStoreStudentCertificates(graduationData, convGradStudent, summary.getAccessToken(), reload); - } - } - - private void createAndStoreStudentTranscript(GraduationData graduationData, ConvGradStudent convStudent, String accessToken, boolean reload) { - ReportData data = reportProcess.prepareTranscriptData(graduationData, graduationData.getGradStatus(), convStudent, accessToken); - reportProcess.saveStudentTranscriptReportJasper(data, convStudent.getDistributionDate(), accessToken, graduationData.getGradStatus().getStudentID(), graduationData.isGraduated(), reload); - } - - private void createAndStoreStudentCertificates(GraduationData graduationData, ConvGradStudent convStudent, String accessToken, boolean reload) { - List certificateList = reportProcess.getCertificateList(graduationData, - convStudent.getCertificateSchoolCategoryCode() != null? convStudent.getCertificateSchoolCategoryCode() : convStudent.getTranscriptSchoolCategoryCode(), accessToken); - int i = 0; - for (ProgramCertificateTranscript certType : certificateList) { - reportProcess.saveStudentCertificateReportJasper(graduationData, convStudent, accessToken, certType, i == 0 && reload); - i++; - } - } - private void convertStudentData(ConvGradStudent student, Student penStudent, GraduationStudentRecord gradStudent, ConversionStudentSummaryDTO summary) { if (determineProgram(student, summary)) { gradStudent.setProgram(student.getProgram()); @@ -381,465 +208,6 @@ private void convertStudentData(ConvGradStudent student, Student penStudent, Gra gradStudent.setUpdateUser(DEFAULT_UPDATED_BY); } - private void convertGraduatedStudentData(ConvGradStudent student, Student penStudent, GraduationStudentRecord gradStudent, ConversionStudentSummaryDTO summary) { - if (determineProgram(student, summary)) { - gradStudent.setProgram(student.getProgram()); - } else { - return; - } - - gradStudent.setGpa(student.getGpa()); - gradStudent.setHonoursStanding(student.getHonoursStanding()); - if ("SCCP".equalsIgnoreCase(gradStudent.getProgram())) { - if (!validateAndSetSlpDate(student, gradStudent, summary)) { - return; - } - } else { - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(student.getProgramCompletionDate())); - } - gradStudent.setSchoolAtGrad(StringUtils.isNotBlank(student.getSchoolAtGrad())? student.getSchoolAtGrad() : null); - gradStudent.setSchoolOfRecord(StringUtils.isNotBlank(student.getSchoolOfRecord())? student.getSchoolOfRecord() : null); - gradStudent.setStudentGrade(student.getStudentGrade()); - gradStudent.setStudentStatus(getGradStudentStatus(student.getStudentStatus(), student.getArchiveFlag())); - - handleAdultStartRule(student, penStudent, gradStudent); - - // flags - gradStudent.setRecalculateGradStatus(null); - gradStudent.setRecalculateProjectedGrad(null); - - // Mappings with Student_Master - gradStudent.setConsumerEducationRequirementMet(student.getConsumerEducationRequirementMet()); - gradStudent.setStudentCitizenship(StringUtils.isBlank(student.getStudentCitizenship())? "U" : student.getStudentCitizenship()); - - // extra - gradStudent.setCreateUser(DEFAULT_CREATED_BY); - gradStudent.setUpdateUser(DEFAULT_UPDATED_BY); - } - - private GraduationData buildGraduationData(ConvGradStudent student, GraduationStudentRecord gradStudent, Student penStudent, ConversionStudentSummaryDTO summary) { - GraduationData graduationData = new GraduationData(); - - TranscriptStudentDemog transcriptStudentDemog = student.getTranscriptStudentDemog(); - - // gradStatus - GradAlgorithmGraduationStudentRecord gradStatus = new GradAlgorithmGraduationStudentRecord(); - gradStatus.setStudentID(gradStudent.getStudentID()); - gradStatus.setPen(student.getPen()); - gradStatus.setProgram(gradStudent.getProgram()); - gradStatus.setProgramCompletionDate(gradStudent.getProgramCompletionDate()); - gradStatus.setGpa(gradStudent.getGpa()); - gradStatus.setSchoolOfRecord(gradStudent.getSchoolOfRecord()); - gradStatus.setStudentGrade(gradStudent.getStudentGrade()); - gradStatus.setStudentStatus(gradStudent.getStudentStatus()); - gradStatus.setSchoolAtGrad(gradStudent.getSchoolAtGrad()); - gradStatus.setHonoursStanding(gradStudent.getHonoursStanding()); - gradStatus.setRecalculateGradStatus(gradStudent.getRecalculateGradStatus()); - gradStatus.setLastUpdateDate(DateConversionUtils.convertStringToDate(transcriptStudentDemog.getUpdateDate().toString())); - graduationData.setGradStatus(gradStatus); - - // school - graduationData.setSchool(student.getTranscriptSchool()); - - // graduated Student - GradSearchStudent gradSearchStudent = populateGraduateStudentInfo(gradStudent, penStudent, student.getTranscriptSchool()); - graduationData.setGradStudent(gradSearchStudent); - - // TSW_TRAN_CRSE - List transcriptStudentCourses = student.getTranscriptStudentCourses(); - - // studentCourses - List studentCourseList = - buildStudentCourses(transcriptStudentCourses.stream().filter(c -> !c.getReportType().equals("3")).collect(Collectors.toList()), - gradStudent.getProgram(), student.getStudentGrade(), summary.getAccessToken()); - StudentCourses studentCourses = new StudentCourses(); - studentCourses.setStudentCourseList(studentCourseList); - graduationData.setStudentCourses(studentCourses); - - // studentAssessments - List studentAssessmentList = buildStudentAssessments(transcriptStudentCourses.stream().filter(c -> c.getReportType().equals("3")).collect(Collectors.toList()), gradStudent.getProgram(), summary.getAccessToken()); - StudentAssessments studentAssessments = new StudentAssessments(); - studentAssessments.setStudentAssessmentList(studentAssessmentList); - graduationData.setStudentAssessments(studentAssessments); - - // optionalGradStatus - List optionalGradStatus = buildOptionalGradStatus(student, gradStudent, studentCourseList, studentAssessmentList, summary); - graduationData.setOptionalGradStatus(optionalGradStatus); - - // requirements met - List requirementsMet = buildRequirementsMet(gradSearchStudent.getProgram(), transcriptStudentCourses, summary); - graduationData.setRequirementsMet(requirementsMet); - - // gradMessage - String gradMessage = transcriptStudentDemog.getGradMessage(); - if ("1950".equalsIgnoreCase(gradSearchStudent.getProgram()) - && isProgramFrancophone(gradMessage)) { - gradMessage = StringUtils.remove(gradMessage, TSW_PF_GRAD_MSG).trim(); - } - graduationData.setGradMessage(gradMessage); - - // dualDogwood - graduationData.setDualDogwood(gradStudent.isDualDogwood()); - - // gradProgram - graduationData.setGradProgram(retrieveGradProgram(gradStudent.getProgram(), summary.getAccessToken())); - - // graduated - graduationData.setGraduated(true); - - return graduationData; - } - - private GradSearchStudent populateGraduateStudentInfo(GraduationStudentRecord gradStudent, - Student penStudent, - School school) { - GradSearchStudent gradSearchStudent = GradSearchStudent.builder() - .studentID(penStudent.getStudentID()) - .pen(penStudent.getPen()) - .legalFirstName(penStudent.getLegalFirstName()) - .legalMiddleNames(penStudent.getLegalMiddleNames()) - .legalLastName(penStudent.getLegalLastName()) - .dob(penStudent.getDob()) - .sexCode(penStudent.getSexCode()) - .genderCode(penStudent.getGenderCode()) - .usualFirstName(penStudent.getUsualFirstName()) - .usualMiddleNames(penStudent.getUsualMiddleNames()) - .usualLastName(penStudent.getUsualLastName()) - .email(penStudent.getEmail()) - .emailVerified(penStudent.getEmailVerified()) - .deceasedDate(penStudent.getDeceasedDate()) - .postalCode(penStudent.getPostalCode()) - .mincode(penStudent.getMincode()) - .localID(penStudent.getLocalID()) - .gradeCode(penStudent.getGradeCode()) - .gradeYear(penStudent.getGradeYear()) - .demogCode(penStudent.getDemogCode()) - .statusCode(penStudent.getStatusCode()) - .memo(penStudent.getMemo()) - .trueStudentID(penStudent.getTrueStudentID()) - .build(); - - gradSearchStudent.setProgram(gradStudent.getProgram()); - gradSearchStudent.setStudentGrade(gradStudent.getStudentGrade()); - gradSearchStudent.setStudentStatus(gradStudent.getStudentStatus()); - gradSearchStudent.setSchoolOfRecord(school.getMinCode()); - gradSearchStudent.setSchoolOfRecordName(school.getSchoolName()); - gradSearchStudent.setSchoolOfRecordindependentAffiliation(school.getIndependentAffiliation()); - - return gradSearchStudent; - } - - private List buildStudentCourses(List tswStudentCourse, String graduationProgramCode, String studentGrade, String accessToken) { - List studentCourses = new ArrayList<>(); - for (TranscriptStudentCourse tswCourse : tswStudentCourse) { - ca.bc.gov.educ.api.dataconversion.model.tsw.StudentCourse studentCourse = populateStudentCourse(tswCourse, graduationProgramCode, studentGrade, accessToken); - studentCourses.add(studentCourse); - } - - return studentCourses; - } - - private List buildStudentAssessments(List tswStudentCourse, String graduationProgramCode, String accessToken) { - List studentAssessments = new ArrayList<>(); - for (TranscriptStudentCourse tswCourse : tswStudentCourse) { - ca.bc.gov.educ.api.dataconversion.model.tsw.StudentAssessment studentAssessment = populateStudentAssessment(tswCourse, graduationProgramCode, accessToken); - studentAssessments.add(studentAssessment); - } - - return studentAssessments; - } - - private ca.bc.gov.educ.api.dataconversion.model.tsw.StudentCourse populateStudentCourse(TranscriptStudentCourse tswCourse, String graduationProgramCode, String studentGrade, String accessToken) { - Integer credits = EducGradDataConversionApiUtils.getNumberOfCredits(tswCourse.getNumberOfCredits()); - Integer creditsUsedForGrad = EducGradDataConversionApiUtils.getNumberOfCredits(tswCourse.getUsedForGrad()); - boolean isAdultOrSccp = isAdultOrSccp(graduationProgramCode, studentGrade); - - ca.bc.gov.educ.api.dataconversion.model.tsw.StudentCourse result = ca.bc.gov.educ.api.dataconversion.model.tsw.StudentCourse.builder() - .pen(tswCourse.getStudNo()) - .courseCode(tswCourse.getCourseCode()) - .courseLevel(tswCourse.getCourseLevel()) - .courseName(tswCourse.getCourseName()) - .originalCredits(credits) - .credits(credits) - .creditsUsedForGrad(isAdultOrSccp? null : creditsUsedForGrad) - .sessionDate(tswCourse.getCourseSession()) - .completedCoursePercentage(EducGradDataConversionApiUtils.getPercentage(tswCourse.getFinalPercentage())) - .completedCourseLetterGrade(tswCourse.getFinalLG() != null? tswCourse.getFinalLG().trim() : null) - .schoolPercent(EducGradDataConversionApiUtils.getPercentage(tswCourse.getSchoolPercentage())) - .bestSchoolPercent(EducGradDataConversionApiUtils.getPercentage(tswCourse.getSchoolPercentage())) - .examPercent(EducGradDataConversionApiUtils.getPercentage(tswCourse.getExamPercentage())) - .bestExamPercent(EducGradDataConversionApiUtils.getPercentage(tswCourse.getExamPercentage())) - .hasRelatedCourse("N") - .metLitNumRequirement(tswCourse.getMetLitNumReqt()) - .relatedCourse(StringUtils.isNotBlank(tswCourse.getRelatedCourse())? tswCourse.getRelatedCourse().trim() : null) - .relatedLevel(StringUtils.isNotBlank(tswCourse.getRelatedCourseLevel())? tswCourse.getRelatedCourseLevel().trim() : null) - .hasRelatedCourse(StringUtils.isNotBlank(tswCourse.getRelatedCourse())? "Y" : "N") - //.genericCourseType("") // tsw course name is used - //.relatedCourseName("")// tsw course name is used - .specialCase(StringUtils.isNotBlank(tswCourse.getSpecialCase())? tswCourse.getSpecialCase().trim() : null) - .provExamCourse(StringUtils.equals(tswCourse.getReportType(), "1")? "Y" : "N") - .isUsed(isAdultOrSccp? true : creditsUsedForGrad != null && creditsUsedForGrad.intValue() != 0) - .isProjected(false) - .isRestricted(false) - .isDuplicate(false) - .isFailed(false) - .isNotCompleted(false) - .isLessCreditCourse(false) - .isValidationCourse(false) - .isGrade10Course(false) - .isCareerPrep(false) - .isLocallyDeveloped(false) - .isNotEligibleForElective(false) - .isBoardAuthorityAuthorized(false) - .isIndependentDirectedStudies(false) - .isCutOffCourse(false) - .build(); - - ProgramRequirement rule = getProgramRequirement(graduationProgramCode, tswCourse.getFoundationReq(), accessToken); - if (rule != null) { - // old trax requirement code is used instead of new requirement code, rule.getProgramRequirementCode().getProReqCode() - result.setGradReqMet(tswCourse.getFoundationReq()); - result.setGradReqMetDetail(StringUtils.isNotBlank(tswCourse.getFoundationReq())? - tswCourse.getFoundationReq().trim() + " - " + rule.getProgramRequirementCode().getLabel() : rule.getProgramRequirementCode().getLabel()); - } - - // Final Percentage - SpecialCase sc = handleSpecialCase(tswCourse.getFinalPercentage(), accessToken); - if (sc != null) { - result.setSpecialCase(sc.getSpCase()); - } - return result; - } - - private ca.bc.gov.educ.api.dataconversion.model.tsw.StudentAssessment populateStudentAssessment(TranscriptStudentCourse tswCourse, String graduationProgramCode, String accessToken) { - Double proficiencyScore; - if ("LTE10".equalsIgnoreCase(tswCourse.getCourseCode()) || "LTP10".equalsIgnoreCase(tswCourse.getCourseCode())) { - proficiencyScore = getProficiencyScoreFromTrax(tswCourse.getStudNo(), tswCourse.getCourseCode(), tswCourse.getCourseSession(), accessToken); - } else { - proficiencyScore = EducGradDataConversionApiUtils.getPercentage(tswCourse.getFinalPercentage()); - } - ca.bc.gov.educ.api.dataconversion.model.tsw.StudentAssessment result = ca.bc.gov.educ.api.dataconversion.model.tsw.StudentAssessment.builder() - .pen(tswCourse.getStudNo()) - .assessmentCode(tswCourse.getCourseCode()) - .assessmentName(tswCourse.getCourseName()) - .sessionDate(tswCourse.getCourseSession()) - .proficiencyScore(proficiencyScore) - .specialCase(StringUtils.isNotBlank(tswCourse.getSpecialCase())? tswCourse.getSpecialCase().trim() : null) - .isUsed(StringUtils.isNotBlank(tswCourse.getFoundationReq())) - .isProjected(false) - .isDuplicate(false) - .isFailed(false) - .isNotCompleted(false) - .build(); - - ProgramRequirement rule = getProgramRequirement(graduationProgramCode, tswCourse.getFoundationReq(), accessToken); - if (rule != null) { - // old trax requirement code is used instead of new requirement code, rule.getProgramRequirementCode().getProReqCode() - result.setGradReqMet(tswCourse.getFoundationReq()); - result.setGradReqMetDetail(StringUtils.isNotBlank(tswCourse.getFoundationReq())? - tswCourse.getFoundationReq().trim() + " - " + rule.getProgramRequirementCode().getLabel() : rule.getProgramRequirementCode().getLabel()); - } - - // Final Percentage - SpecialCase sc = handleSpecialCase(tswCourse.getFinalPercentage(), accessToken); - if (sc != null) { - result.setSpecialCase(sc.getSpCase()); - } - return result; - } - - private Double getProficiencyScoreFromTrax(String pen, String assessmentCode, String sessionDate, String accessToken) { - Double proficiencyScore = null; - List studentAssessments = restUtils.getStudentAssessmentsByPenAndAssessmentCode(pen, assessmentCode, accessToken); - for (StudentAssessment sA : studentAssessments) { - if (StringUtils.equalsIgnoreCase(sA.getSessionDate(), sessionDate)) { - proficiencyScore = sA.getProficiencyScore(); - break; - } - } - return proficiencyScore; - } - - // SpecialCase - private SpecialCase handleSpecialCase(String percentage, String accessToken) { - if (StringUtils.isNotBlank(percentage) - && !NumberUtils.isCreatable(percentage.trim()) - && !StringUtils.equals(percentage.trim(), "---")) { - return lookupSpecialCase(percentage.trim(), accessToken); - } - return null; - } - - private ProgramRequirement getProgramRequirement(String graduationProgramCode, String foundationReq, String accessToken) { - if (StringUtils.isBlank(graduationProgramCode) || StringUtils.isBlank(foundationReq)) { - return null; - } - return lookupProgramRule(graduationProgramCode, foundationReq, accessToken); - } - - private List buildOptionalGradStatus(ConvGradStudent student, GraduationStudentRecord gradStudent, - List studentCourseList, - List studentAssessmentList, - ConversionStudentSummaryDTO summary) { - List results = new ArrayList<>(); - List list = null; - try { - list = restUtils.getStudentOptionalPrograms(gradStudent.getStudentID().toString(), summary.getAccessToken()); - } catch (Exception e) { - handleException(student, summary, student.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "getting StudentOptionalPrograms : " + e.getLocalizedMessage()); - } - if (list != null && !list.isEmpty()) { - List careerProgramList = buildStudentCareerProgramList(student, gradStudent.getStudentID(), summary); - for (StudentOptionalProgram obj : list) { - GradAlgorithmOptionalStudentProgram result = populateOptionStudentProgramStatus(obj, studentCourseList, studentAssessmentList, careerProgramList, summary); - results.add(result); - } - } - return results; - } - - private GradAlgorithmOptionalStudentProgram populateOptionStudentProgramStatus(StudentOptionalProgram object, - List studentCourseList, - List studentAssessmentList, - List careerProgramList, ConversionStudentSummaryDTO summary) { - GradAlgorithmOptionalStudentProgram result = new GradAlgorithmOptionalStudentProgram(); - result.setOptionalProgramID(object.getOptionalProgramID()); - result.setOptionalProgramCode(object.getOptionalProgramCode()); - result.setOptionalProgramName(object.getOptionalProgramName()); - result.setOptionalProgramCompletionDate(object.getOptionalProgramCompletionDate()); - result.setStudentID(object.getStudentID()); - result.setOptionalGraduated(true); - - // Optional Program Requirements Met - GradRequirement gradRequirement = createOptionalProgramRequirementMet(object.getOptionalProgramCode()); - result.setOptionalRequirementsMet(gradRequirement != null? Arrays.asList(gradRequirement) : new ArrayList<>()); - result.setOptionalNonGradReasons(new ArrayList<>()); - - // Career Programs - result.setCpList(careerProgramList); - - // Student Courses - StudentCourses studentCourses = new StudentCourses(); - studentCourses.setStudentCourseList(studentCourseList); - result.setOptionalStudentCourses(studentCourses); - - // Student Assessments - StudentAssessments studentAssessments = new StudentAssessments(); - studentAssessments.setStudentAssessmentList(studentAssessmentList); - result.setOptionalStudentAssessments(studentAssessments); - - // Clob - try { - object.setStudentOptionalProgramData(new ObjectMapper().writeValueAsString(result)); - } catch (JsonProcessingException e) { - log.error("Json Parsing Error for StudentOptionalProgramData: " + e.getLocalizedMessage()); - } - - updateStudentOptionalProgram(object, summary.getAccessToken()); - return result; - } - - private GradRequirement createOptionalProgramRequirementMet(String optionalProgramCode) { - if (StringUtils.isBlank(optionalProgramCode)) { - return null; - } - GradRequirement gradRequirement = new GradRequirement(); - gradRequirement.setProjected(false); - switch (optionalProgramCode) { - case "AD" -> { // 951 - gradRequirement.setRule("951"); - gradRequirement.setDescription("A school must report the student as participating in the Advanced Placement program"); - } - case "BC" -> { // - gradRequirement.setRule("952"); - gradRequirement.setDescription("The school must report the student as participating in the International Baccalaureate program as a Certificate candidate"); - } - case "BD" -> { - gradRequirement.setRule("953"); - gradRequirement.setDescription("The school must report the student as participating in the International Baccalaureate program as a Diploma candidate"); - } - case "CP" -> { - gradRequirement.setRule("954"); - gradRequirement.setDescription("The school must report the student as participating in a Career Program"); - } - default -> gradRequirement = null; - } - return gradRequirement; - } - - private void updateStudentOptionalProgram(StudentOptionalProgram object, String accessToken) { - StudentOptionalProgramRequestDTO requestDTO = new StudentOptionalProgramRequestDTO(); - BeanUtils.copyProperties(object, requestDTO); - restUtils.saveStudentOptionalProgram(requestDTO, accessToken); - } - - private List buildStudentCareerProgramList(ConvGradStudent student, UUID studentID, ConversionStudentSummaryDTO summary) { - List results = null; - try { - results = restUtils.getStudentCareerPrograms(studentID.toString(), summary.getAccessToken()); - } catch (Exception e) { - handleException(student, summary, student.getPen(), ConversionResultType.FAILURE, GRAD_STUDENT_API_ERROR_MSG + "getting StudentCareerPrograms : " + e.getLocalizedMessage()); - } - if (results != null) { - return results; - } - return new ArrayList<>(); - } - - private List buildRequirementsMet(String programCode, List tswStudentCourses, ConversionStudentSummaryDTO summary) { - Set requirements = new HashSet<>(); - for (TranscriptStudentCourse tswCourse : tswStudentCourses) { - if (StringUtils.isNotBlank(tswCourse.getFoundationReq())) { - GradRequirement gradRequirement = populateRequirement(programCode, tswCourse.getFoundationReq(), summary); - if (gradRequirement != null) { - requirements.add(gradRequirement); - } - } - } - return new ArrayList<>(requirements); - } - - private GradRequirement populateRequirement(String programCode, String traxReqNumber, ConversionStudentSummaryDTO summary) { - GradRuleDetails rule = null; - List rules = retrieveProgramRulesByTraxReqNumber(traxReqNumber, summary.getAccessToken()); - for (GradRuleDetails ruleDetail : rules) { - if (StringUtils.equals(ruleDetail.getProgramCode(), programCode)) { - rule = ruleDetail; - break; - } - } - if (rule != null) { - GradRequirement result = new GradRequirement(); - result.setRule(rule.getRuleCode()); - result.setDescription(rule.getRequirementName()); - result.setProjected(false); - return result; - } else { - return null; - } - - } - - private GraduationProgramCode retrieveGradProgram(String programCode, String accessToken) { - GraduationProgramCode program = null; - try { - program = restUtils.getGradProgramCode(programCode, accessToken); - } catch (Exception e) { - log.error("Program API is failed to get Grad Programs! : " + e.getLocalizedMessage()); - } - return program; - } - - private List retrieveProgramRulesByTraxReqNumber(String traxReqNumber, String accessToken) { - List rules = new ArrayList<>(); - try { - rules = restUtils.getGradProgramRulesByTraxReqNumber(traxReqNumber, accessToken); - } catch (Exception e) { - log.error("Program API is failed to get Program Rules! : " + e.getLocalizedMessage()); - } - return rules; - } - private ConversionResultType processOptionalPrograms(GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { if (StringUtils.isBlank(student.getProgram())) { return ConversionResultType.SUCCESS; @@ -847,31 +215,12 @@ private ConversionResultType processOptionalPrograms(GraduationStudentRecord stu // Dual Dogwood for yyyy-PF if (student.getProgram().endsWith("-PF")) { - return createStudentOptionalProgram("DD", student, StudentLoadType.UNGRAD, summary); + return createStudentOptionalProgram("DD", student, summary); } // French Immersion for 2018-EN, 2004-EN, 1996-EN, 1986-EN if (hasAnyFrenchImmersionCourse(student.getProgram(), student.getPen(), summary.getAccessToken())) { - return createStudentOptionalProgram("FI", student, StudentLoadType.UNGRAD, summary); - } - - return ConversionResultType.SUCCESS; - } - - private ConversionResultType processOptionalProgramsForGraduatedStudent(ConvGradStudent convGradStudent, GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { - if (StringUtils.isBlank(student.getProgram())) { - return ConversionResultType.SUCCESS; - } - - // Dual Dogwood for yyyy-PF - if (student.getProgram().endsWith("-PF") && StringUtils.equalsIgnoreCase(convGradStudent.getEnglishCert(), "E")) { - student.setDualDogwood(true); - return createStudentOptionalProgram("DD", student, StudentLoadType.GRAD_ONE, summary); - } - - // French Immersion for yyyy-EN to check if their Graduation Message contains "Student has successfully completed the French Immersion program" - if (student.getProgram().endsWith("-EN") && isFrenchImmersion(convGradStudent.getTranscriptStudentDemog().getGradMessage())) { - return createStudentOptionalProgram("FI", student, StudentLoadType.GRAD_ONE, summary); + return createStudentOptionalProgram("FI", student, summary); } return ConversionResultType.SUCCESS; @@ -899,12 +248,12 @@ public boolean hasAnyFrenchImmersionCourse(String program, String pen, String ac return frenchImmersion; } - private ConversionResultType processProgramCodes(GraduationStudentRecord student, List programCodes, StudentLoadType studentLoadType, StudentLoadType originalStudentLoadType, ConversionStudentSummaryDTO summary) { + private ConversionResultType processProgramCodes(GraduationStudentRecord student, List programCodes, ConversionStudentSummaryDTO summary) { ConversionResultType resultType = ConversionResultType.SUCCESS; Boolean isCareerProgramCreated = Boolean.FALSE; if (StringUtils.isNotBlank(student.getProgram()) && !programCodes.isEmpty()) { for (String programCode : programCodes) { - Pair res = handleProgramCode(programCode, student, studentLoadType, originalStudentLoadType, summary); + Pair res = handleProgramCode(programCode, student, summary); if (Boolean.TRUE.equals(res.getRight())) { isCareerProgramCreated = Boolean.TRUE; } @@ -914,20 +263,17 @@ private ConversionResultType processProgramCodes(GraduationStudentRecord student } } if (Boolean.TRUE.equals(isCareerProgramCreated)) { - resultType = createStudentOptionalProgram("CP", student, studentLoadType, summary); + resultType = createStudentOptionalProgram("CP", student, summary); } } return resultType; } - private Pair handleProgramCode(String programCode, GraduationStudentRecord student, StudentLoadType studentLoadType, StudentLoadType originalStudentLoadType, ConversionStudentSummaryDTO summary) { + private Pair handleProgramCode(String programCode, GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { ConversionResultType resultType; boolean isCareerProgramCreated = false; - if (isStudentSCCPForTwoPrograms(student.getProgram(), originalStudentLoadType)) { - return Pair.of(ConversionResultType.SUCCESS, isCareerProgramCreated); - } if (isOptionalProgramCode(programCode)) { - resultType = createStudentOptionalProgram(programCode, student, studentLoadType, summary); + resultType = createStudentOptionalProgram(programCode, student, summary); } else { resultType = createStudentCareerProgram(programCode, student, summary); if (ConversionResultType.SUCCESS == resultType) { @@ -937,28 +283,23 @@ private Pair handleProgramCode(String programCode return Pair.of(resultType, isCareerProgramCreated); } - // GRAD2-2013: skip optional programs for SCCP during 1st pass - private boolean isStudentSCCPForTwoPrograms(String graduationProgramCode, StudentLoadType originalStudentLoadType) { - return "SCCP".equalsIgnoreCase(graduationProgramCode) && originalStudentLoadType == StudentLoadType.GRAD_TWO; - } - private ConversionResultType processSccpFrenchCertificates(GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { if (StringUtils.equals(student.getProgram(), "SCCP") && ( StringUtils.isNotBlank(student.getSchoolOfRecord()) && student.getSchoolOfRecord().startsWith("093") ) ) { - return createStudentOptionalProgram("FR", student, StudentLoadType.UNGRAD, summary); + return createStudentOptionalProgram("FR", student, summary); } return ConversionResultType.SUCCESS; } - private ConversionResultType createStudentOptionalProgram(String optionalProgramCode, GraduationStudentRecord student, StudentLoadType studentLoadType, ConversionStudentSummaryDTO summary) { + private ConversionResultType createStudentOptionalProgram(String optionalProgramCode, GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { StudentOptionalProgramRequestDTO object = new StudentOptionalProgramRequestDTO(); object.setPen(student.getPen()); object.setStudentID(student.getStudentID()); object.setMainProgramCode(student.getProgram()); object.setOptionalProgramCode(optionalProgramCode); - object.setOptionalProgramCompletionDate(studentLoadType == StudentLoadType.UNGRAD? null : student.getProgramCompletionDate()); + object.setOptionalProgramCompletionDate(null); try { restUtils.saveStudentOptionalProgram(object, summary.getAccessToken()); @@ -1270,42 +611,33 @@ public void triggerGraduationBatchRun(EventType eventType, UUID studentID, Strin } } - public ProgramRequirement lookupProgramRule(String graduationProgramCode, String foundationReq, String accessToken) { - programRuleMap.computeIfAbsent(graduationProgramCode, k -> restUtils.getGradProgramRules(graduationProgramCode, accessToken)); - - List rules = programRuleMap.get(graduationProgramCode); - return rules.stream() - .filter(pr -> StringUtils.equals(pr.getProgramRequirementCode().getTraxReqNumber(), foundationReq)) - .findAny() - .orElse(null); - } - - public SpecialCase lookupSpecialCase(String specialCaseLabel, String accessToken) { - if (!specialCaseMap.containsKey(specialCaseLabel)) { - List results = restUtils.getAllSpecialCases(accessToken); - results.forEach(r -> specialCaseMap.put(r.getLabel(), r)); - } - - return specialCaseMap.get(specialCaseLabel); - } - - private boolean isAdultOrSccp(String graduationProgram, String grade) { - return "SCCP".equalsIgnoreCase(graduationProgram) || ("1950".equalsIgnoreCase(graduationProgram) && "AD".equalsIgnoreCase(grade)); - } - private void handleAdultStartRule(ConvGradStudent student, Student penStudent, GraduationStudentRecord gradStudent) { if ("1950".equalsIgnoreCase(gradStudent.getProgram())) { Date dob = EducGradDataConversionApiUtils.parseDate(penStudent.getDob()); - Date adultStartDate; - if ("AD".equalsIgnoreCase(gradStudent.getStudentGrade())) { - adultStartDate = DateUtils.addYears(dob, student.isAdult19Rule() ? 19 : 18); - } else { - adultStartDate = DateUtils.addYears(dob, 18); - } + Date adultStartDate = DateUtils.addYears(dob, 18); gradStudent.setAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd } } + /** + * + * @return true Valid + * false Bad data (programCompletionDate is null) + */ + private boolean validateProgramCompletionDate(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary) { + if ("SCCP".equalsIgnoreCase(convGradStudent.getGraduationRequirementYear()) && + StringUtils.isBlank(convGradStudent.getSlpDate())) { + handleException(convGradStudent, summary, convGradStudent.getPen(), ConversionResultType.FAILURE, "Bad data: slp_date is null for SCCP"); + return false; + } + return true; + } + + /** + * + * @return true Valid + * false Bad data (slp_date format is not right) + */ private boolean validateAndSetSlpDate(ConvGradStudent student, GraduationStudentRecord gradStudent, ConversionStudentSummaryDTO summary) { if (StringUtils.isNotBlank(student.getSlpDate()) && StringUtils.length(student.getSlpDate().trim()) != 8) { handleException(student, summary, student.getPen(), ConversionResultType.FAILURE, "Bad data : slp_date format is not yyyyMMdd"); @@ -1317,11 +649,4 @@ private boolean validateAndSetSlpDate(ConvGradStudent student, GraduationStudent } } - private void fetchAccessToken(ConversionStudentSummaryDTO summaryDTO) { - ResponseObj res = restUtils.getTokenResponseObject(); - if (res != null) { - summaryDTO.setAccessToken(res.getAccess_token()); - log.debug("Setting the new access token in summaryDTO."); - } - } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java index 7b04d1f1..cbdc1288 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/processor/StudentPartitionProcessor.java @@ -1,7 +1,6 @@ package ca.bc.gov.educ.api.dataconversion.processor; import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; -import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; import ca.bc.gov.educ.api.dataconversion.model.ConvGradStudent; import ca.bc.gov.educ.api.dataconversion.model.ConversionAlert; import ca.bc.gov.educ.api.dataconversion.model.ConversionStudentSummaryDTO; @@ -42,14 +41,7 @@ public ConvGradStudent process(String pen) throws Exception { responseStudent = students.get(0); if (responseStudent.getResult() != null && responseStudent.getResult().equals(ConversionResultType.FAILURE)) { - String reason = ""; - if (responseStudent.getStudentLoadType() == StudentLoadType.NONE) { - reason = "ERROR-Bad data: student is not in [ungrad, grad_one, grad_two]"; - } else if (responseStudent.getStudentLoadType() == StudentLoadType.NO_UTG) { - reason = "ERROR-Bad data: [graduated - two programs] UTG data is not found"; - } else { - reason = "ERROR-Bad data: unknown error from TRAX"; - } + String reason = "ERROR-Bad data: unknown error from TRAX"; summaryDTO.setErroredCount(summaryDTO.getErroredCount() + 1L); restUtils.saveTraxStudentNo(new TraxStudentNo(pen, "F", reason), summaryDTO.getAccessToken()); return null; @@ -65,7 +57,7 @@ public ConvGradStudent process(String pen) throws Exception { error.setReason("Unexpected Exception is occurred: " + e.getLocalizedMessage()); summaryDTO.getErrors().add(error); - LOGGER.error("unknown exception: " + e.getLocalizedMessage()); + LOGGER.error("unknown exception: {}", e.getLocalizedMessage()); if (responseStudent == null) { responseStudent = ConvGradStudent.builder().pen(pen).result(ConversionResultType.FAILURE).build(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java index d2ce815c..12eec0c1 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentBaseService.java @@ -1,7 +1,6 @@ package ca.bc.gov.educ.api.dataconversion.service.student; import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; -import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; import ca.bc.gov.educ.api.dataconversion.model.ConvGradStudent; import ca.bc.gov.educ.api.dataconversion.model.ConversionAlert; import ca.bc.gov.educ.api.dataconversion.model.ConversionStudentSummaryDTO; @@ -20,10 +19,6 @@ public class StudentBaseService { public static final String STUDENT_STATUS_MERGED = "MER"; public static final String STUDENT_STATUS_TERMINATED = "TER"; - // GRAD Messages - public static final String TSW_PF_GRAD_MSG = "Student has successfully completed the Programme Francophone."; - public static final String TSW_FI_GRAD_MSG = "Student has successfully completed the French Immersion program."; - // Optional Program Codes private static final List OPTIONAL_PROGRAM_CODES = Arrays.asList("AD", "BC", "BD"); private static final List OPTIONAL_PROGRAM_CODES_FOR_RECREATION = Arrays.asList("AD", "BC", "BD", "CP"); @@ -56,12 +51,10 @@ protected String getGradStudentStatus(String traxStudentStatus, String traxArchi } protected boolean determineProgram(ConvGradStudent student, ConversionStudentSummaryDTO summary) { - String gradProgram = student.getStudentLoadType() == StudentLoadType.UNGRAD? - getGradProgram(student.getGraduationRequirementYear(), student.getSchoolOfRecord(), student.getFrenchDogwood()) : - getGradProgramForGraduatedStudent(student.getGraduationRequirementYear(), student.getTranscriptStudentDemog().getGradMessage()); + String gradProgram = getGradProgram(student.getGraduationRequirementYear(), student.getSchoolOfRecord(), student.getFrenchDogwood()); if (StringUtils.isNotBlank(gradProgram)) { student.setProgram(gradProgram); - updateProgramCountsInSummary(summary, gradProgram, student.getStudentLoadType() != StudentLoadType.UNGRAD); + updateProgramCountsInSummary(summary, gradProgram, false); return true; } else { // error @@ -114,19 +107,6 @@ protected String getGradProgram(String graduationRequirementYear, String schoolO return gradProgram; } - protected String getGradProgramForGraduatedStudent(String graduationRequirementYear, String gradMessage) { - String gradProgram = null; - switch (graduationRequirementYear) { - case "2018" -> gradProgram = isProgramFrancophone(gradMessage) ? "2018-PF" : "2018-EN"; - case "2004" -> gradProgram = isProgramFrancophone(gradMessage) ? "2004-PF" : "2004-EN"; - case "1996", "1995" -> gradProgram = isProgramFrancophone(gradMessage) ? "1996-PF" : "1996-EN"; - case "1986" -> gradProgram = isProgramFrancophone(gradMessage) ? "1986-PF" : "1986-EN"; - case "1950" -> gradProgram = "1950"; - case "SCCP" -> gradProgram = "SCCP"; - } - return gradProgram; - } - protected void populateNewBatchFlags(StudentGradDTO currentStudent) { if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(currentStudent.getStudentStatus())) { // Transcript @@ -145,15 +125,6 @@ private void updateProgramCountsInSummary(ConversionStudentSummaryDTO summary, S } } - public boolean isFrenchImmersion(String gradMessage) { - return StringUtils.contains(gradMessage, TSW_FI_GRAD_MSG); - } - - // initial load - public boolean isProgramFrancophone(String gradMessage) { - return StringUtils.contains(gradMessage, TSW_PF_GRAD_MSG); - } - public boolean isOptionalProgramCode(String code) { return OPTIONAL_PROGRAM_CODES.contains(code); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java index 97d3a817..28e9c623 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/EducGradDataConversionApiConstants.java @@ -65,24 +65,12 @@ public class EducGradDataConversionApiConstants { @Value("${endpoint.pen-student-api.by-pen.url}") private String penStudentApiByPenUrl; - @Value("${endpoint.grad-program-api.programs.url}") - private String gradProgramUrl; - @Value("${endpoint.grad-program-api.special-program.url}") private String gradOptionalProgramUrl; @Value("${endpoint.grad-program-api.optional-program-by-id.url}") private String gradOptionalProgramByIDUrl; - @Value("${endpoint.grad-program-api.career-program.url}") - private String gradCareerProgramUrl; - - @Value("${endpoint.grad-program-api.program-rules.url}") - private String gradProgramRulesUrl; - - @Value("${endpoint.grad-program-api.program-rules-by-trax.url}") - private String gradProgramRulesByTraxReqNumberUrl; - @Value("${endpoint.grad-student-api.add-new-pen.url}") private String addNewPenFromGradStudentApiUrl; @@ -116,9 +104,6 @@ public class EducGradDataConversionApiConstants { @Value("${endpoint.grad-assessment-api.assessment-requirement.url}") private String addAssessmentRequirementApiUrl; - @Value("${endpoint.grad-assessment-api.student-assessments.by-pen-and-assessment-code.url}") - private String studentAssessmentsByPenAndAssessmentCodeApiUrl; - @Value("${endpoint.grad-assessment-api.student-assessments.by-pen.url}") private String studentAssessmentsByPenApiUrl; @@ -170,30 +155,6 @@ public class EducGradDataConversionApiConstants { @Value("${endpoint.grad-trax-api.student.save-trax-student-no.url}") private String saveTraxStudentNoUrl; - //Sree - @Value("${endpoint.grad-graduation-report-api.get-transcript}") - private String transcript; - @Value("${endpoint.educ-school-api.url}") - private String schoolCategoryCode; - @Value("${endpoint.grad-student-graduation-api.get-special-cases.url}") - private String specialCase; - @Value("${endpoint.grad-program-api.program_name_by_program_code.url}") - private String programNameEndpoint; - @Value("${endpoint.grad-graduation-report-api.update-grad-student-transcript.url}") - private String updateGradStudentTranscript; - @Value("${endpoint.report-api.transcript_report}") - private String transcriptReport; - @Value("${endpoint.grad-graduation-report-api.get-cert-list}") - private String certList; - @Value("${endpoint.report-api.certificate_report}") - private String certificateReport; - @Value("${endpoint.grad-graduation-report-api.update-grad-student-certificate.url}") - private String updateGradStudentCertificate; - @Value("${endpoint.grad-graduation-report-api.update-grad-student-report.url}") - private String updateGradStudentReport; - @Value("${endpoint.report-api.achievement_report}") - private String achievementReport; - // Incremental Grad Update @Value("${grad.update.enabled}") private boolean gradUpdateEnabled; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java index dd5fb3c5..c3e5f840 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/util/RestUtils.java @@ -1,18 +1,13 @@ package ca.bc.gov.educ.api.dataconversion.util; -import ca.bc.gov.educ.api.dataconversion.exception.ServiceException; import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; import ca.bc.gov.educ.api.dataconversion.model.StudentCourse; -import ca.bc.gov.educ.api.dataconversion.model.tsw.*; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportRequest; import io.github.resilience4j.retry.annotation.Retry; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.util.LinkedMultiValueMap; @@ -64,8 +59,8 @@ private ResponseObj getTokenResponseObj() { .bodyToMono(ResponseObj.class).block(); } - public ResponseObj rtGetTokenFallBack(HttpServerErrorException exception){ - log.error("{} NOT REACHABLE after many attempts: {}", constants.getTokenUrl(), exception); + public ResponseObj rtGetTokenFallback(HttpServerErrorException exception){ + log.error("{} NOT REACHABLE after many attempts: {}", constants.getTokenUrl(), exception.getLocalizedMessage()); return null; } @@ -101,17 +96,6 @@ public OptionalProgram getOptionalProgramByID(UUID optionalProgramID, String acc .retrieve().bodyToMono(OptionalProgram.class).block(); } - - public CareerProgram getCareerProgram(String careerProgramCode, String accessToken) { - return this.webClient.get() - .uri(constants.getGradCareerProgramUrl(), uri -> uri.path("/{careerProgramCode}").build(careerProgramCode)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(CareerProgram.class).block(); - } - public Student addNewPen(Student student, String accessToken) { return webClient.post() .uri(constants.getAddNewPenFromGradStudentApiUrl()) @@ -134,18 +118,6 @@ public AssessmentRequirement addAssessmentRequirement(AssessmentRequirement asse .retrieve().bodyToMono(AssessmentRequirement.class).block(); } - public List getStudentAssessmentsByPenAndAssessmentCode(String pen, String assessmentCode, String accessToken) { - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - return this.webClient.get() - .uri(String.format(constants.getStudentAssessmentsByPenAndAssessmentCodeApiUrl(), assessmentCode, pen)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(responseType).block(); - } - public List getStudentAssessmentsByPen(String pen, String accessToken) { final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; @@ -374,154 +346,6 @@ public TraxStudentNo saveTraxStudentNo(TraxStudentNo traxStudentNo, String acces .retrieve().bodyToMono(TraxStudentNo.class).block(); } - public GraduationProgramCode getGradProgramCode(String programCode, String accessToken) { - return this.webClient.get() - .uri(constants.getGradProgramUrl(), uri -> uri.path("/{programCode}").build(programCode)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(GraduationProgramCode.class).block(); - } - - public List getGradProgramRulesByTraxReqNumber(String traxReqNumber, String accessToken) { - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - return this.webClient.get() - .uri(constants.getGradProgramRulesByTraxReqNumberUrl(), uri -> uri.path("/{traxReqNumber}").build(traxReqNumber)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(responseType).block(); - } - - public List getGradProgramRules(String gradProgramCode, String accessToken) { - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - return this.webClient.get() - .uri(constants.getGradProgramRulesUrl(), - uri -> uri.queryParam("programCode", gradProgramCode) - .build()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(responseType).block(); - } - - public List getAllSpecialCases(String accessToken) { - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - return this.webClient.get() - .uri(constants.getSpecialCase()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }) - .retrieve().bodyToMono(responseType).block(); - } - - public SpecialCase getSpecialCase(String specialCode, String accessToken) { - return this.webClient.get() - .uri(constants.getSpecialCase(), uri -> uri.path("/{specialCode}").build(specialCode)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).retrieve().bodyToMono(SpecialCase.class).block(); - } - - public ProgramCertificateTranscript getTranscript(String gradProgram, String schoolCategoryCode, String accessToken) { - ProgramCertificateReq req = new ProgramCertificateReq(); - req.setProgramCode(gradProgram); - req.setSchoolCategoryCode(schoolCategoryCode); - return webClient.post().uri(constants.getTranscript()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(req)).retrieve().bodyToMono(ProgramCertificateTranscript.class).block(); - } - - public String getSchoolCategoryCode(String mincode, String accessToken) { - CommonSchool commonSchoolObj = webClient.get() - .uri(constants.getSchoolCategoryCode(), uri -> uri.path("/{mincode}").build(mincode)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).retrieve().bodyToMono(CommonSchool.class).block(); - if (commonSchoolObj != null) { - return commonSchoolObj.getSchoolCategoryCode(); - } - return null; - } - - public GradProgram getGradProgram(String gradProgram, String accessToken) { - return webClient.get().uri(String.format(constants.getProgramNameEndpoint(), gradProgram)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).retrieve().bodyToMono(GradProgram.class).block(); - } - - @Retry(name = "rt-transcript") - public void saveGradStudentTranscript(GradStudentTranscripts requestObj, boolean isGraduated, String accessToken) { - webClient.post().uri(String.format(constants.getUpdateGradStudentTranscript(), isGraduated)) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(requestObj)).retrieve().bodyToMono(GradStudentTranscripts.class).block(); - } - - public byte[] getTranscriptReport(ReportRequest reportParams, String accessToken) { - try { - return webClient.post().uri(constants.getTranscriptReport()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(reportParams)) - .retrieve() - .onStatus(HttpStatusCode::is5xxServerError, - response -> response.bodyToMono(String.class).thenReturn(new ServiceException("INTERNAL_SERVER_ERROR", response.statusCode().value()))) - .onStatus( - HttpStatus.NO_CONTENT::equals, - response -> response.bodyToMono(String.class).thenReturn(new ServiceException("NO_CONTENT", response.statusCode().value())) - ) - .bodyToMono(byte[].class).block(); - } catch (ServiceException ex) { - if(HttpStatus.NO_CONTENT.value() == ex.getStatusCode()) { - return new byte[0]; - } else { - throw ex; - } - } - } - - public List getProgramCertificateTranscriptList(ProgramCertificateReq req, String accessToken) { - return webClient.post().uri(constants.getCertList()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(req)).retrieve().bodyToMono(new ParameterizedTypeReference>() { - }).block(); - } - - @Retry(name = "rt-certificate") - public void saveGradStudentCertificate(GradStudentCertificates requestObj, String accessToken) { - webClient.post().uri(constants.getUpdateGradStudentCertificate()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(requestObj)).retrieve().bodyToMono(GradStudentCertificates.class).block(); - } - - public byte[] getCertificateReport(ReportRequest reportParams, String accessToken) { - return webClient.post().uri(constants.getCertificateReport()) - .headers(h -> { - h.setBearerAuth(accessToken); - h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); - }).body(BodyInserters.fromValue(reportParams)).retrieve().bodyToMono(byte[].class).block(); - } - // Read GraduationStudentRecord - GET /student/studentid/{id}/algorithm @Retry(name = "rt-getStudentGradStatus", fallbackMethod = "rtGetStudentGradStatusFallback") public GraduationStudentRecord getStudentGradStatus(String studentID, String accessToken) { @@ -624,17 +448,17 @@ public void removeStudentCareerProgram(String careerProgramCode, UUID studentID, } public ConvGradStudent rtGetStudentGradStatusFallback(HttpServerErrorException exception){ - log.error("STUDENT GRAD STATUS NOT Retrievable after many attempts: {}", exception); + log.error("STUDENT GRAD STATUS NOT Retrievable after many attempts: {}", exception.getLocalizedMessage()); return null; } public ConvGradStudent rtSaveStudentGradStatusFallback(HttpServerErrorException exception){ - log.error("STUDENT GRAD STATUS NOT Saved after many attempts: {}", exception); + log.error("STUDENT GRAD STATUS NOT Saved after many attempts: {}", exception.getLocalizedMessage()); return null; } public ConvGradStudent rtUpdateStudentGradStatusFallback(HttpServerErrorException exception){ - log.error("STUDENT GRAD STATUS NOT Updated after many attempts: {}", exception); + log.error("STUDENT GRAD STATUS NOT Updated after many attempts: {}", exception.getLocalizedMessage()); return null; } } diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 56869e1a..2d03219e 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -16,7 +16,7 @@ spring: driver-class-name: oracle.jdbc.driver.OracleDriver jpa: show-sql: ${SHOW_SQL_LOGS} - database-platform: org.hibernate.dialect.Oracle12cDialect + database-platform: org.hibernate.dialect.OracleDialect hibernate: ddl-auto: none mvc: @@ -114,20 +114,6 @@ resilience4j.retry: - org.springframework.web.client.HttpServerErrorException ignoreExceptions: - java.lang.NullPointerException - rt-transcript: - maxAttempts: ${MAX_RETRY_ATTEMPTS} - waitDuration: 5s - retryExceptions: - - org.springframework.web.client.HttpServerErrorException - ignoreExceptions: - - java.lang.NullPointerException - rt-certificate: - maxAttempts: ${MAX_RETRY_ATTEMPTS} - waitDuration: 5s - retryExceptions: - - org.springframework.web.client.HttpServerErrorException - ignoreExceptions: - - java.lang.NullPointerException rt-getStudentGradStatus: maxAttempts: ${MAX_RETRY_ATTEMPTS} waitDuration: 5s @@ -212,16 +198,6 @@ endpoint: url: ${GRAD_PROGRAM_API}api/v1/program/optionalprograms optional-program-by-id: url: ${GRAD_PROGRAM_API}api/v1/program/optionalprograms/id - career-program: - url: ${GRAD_PROGRAM_API}api/v1/program/careerprogram - programs: - url: ${GRAD_PROGRAM_API}api/v1/program/programs - program-rules: - url: ${GRAD_PROGRAM_API}api/v1/program/programrules - program-rules-by-trax: - url: ${GRAD_PROGRAM_API}api/v1/program/programrules/by-trax - program_name_by_program_code: - url: ${GRAD_PROGRAM_API}api/v1/program/programs/%s grad-student-api: add-new-pen: url: ${GRAD_STUDENT_API}api/v1/student @@ -240,8 +216,6 @@ endpoint: student-assessments: by-pen: url: ${GRAD_ASSESSMENT_API}api/v1/assessment/pen/%s - by-pen-and-assessment-code: - url: ${GRAD_ASSESSMENT_API}api/v1/assessment/%s/pen/%s grad-trax-api: student: get-student-no-list-by-page: @@ -259,24 +233,6 @@ endpoint: url: ${GRAD_TRAX_API}api/v1/trax/common/course-restrictions get-course-requirements: url: ${GRAD_TRAX_API}api/v1/trax/common/course-requirements - grad-graduation-report-api: - get-transcript: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/programtranscripts - update-grad-student-transcript: - url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studenttranscript?isGraduated=%s - get-cert-list: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/programcertificates - update-grad-student-certificate: - url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studentcertificate - update-grad-student-report: - url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/schoolreport - educ-school-api: - url: ${EDUC_SCHOOL_API}api/v1/schools - grad-student-graduation-api: - get-special-cases: - url: ${GRAD_STUDENT_GRADUATION_API}api/v1/studentgraduation/lgSc/specialcase - report-api: - transcript_report: ${GRAD_REPORT_API}api/v1/reports/transcriptreport - certificate_report: ${GRAD_REPORT_API}api/v1/reports/certificate - achievement_report: ${GRAD_REPORT_API}api/v1/reports/achievementreport #Incremental Grad Update grad: diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/DataConversionProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/DataConversionProcessTest.java index 73e2d291..f3fb7def 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/DataConversionProcessTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/DataConversionProcessTest.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.api.dataconversion.process; -import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; import ca.bc.gov.educ.api.dataconversion.messaging.NatsConnection; import ca.bc.gov.educ.api.dataconversion.messaging.jetstream.Subscriber; import ca.bc.gov.educ.api.dataconversion.model.*; @@ -67,7 +66,6 @@ public void testLoadInitialRawGradStudentData() { .studentStatus("A") .archiveFlag("A") .graduationRequirementYear("2020") - .studentLoadType(StudentLoadType.UNGRAD) .build(); List results = new ArrayList<>(); results.add(obj); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcessTest.java deleted file mode 100644 index 6d7709a1..00000000 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/ReportProcessTest.java +++ /dev/null @@ -1,1273 +0,0 @@ -package ca.bc.gov.educ.api.dataconversion.process; - -import ca.bc.gov.educ.api.dataconversion.messaging.NatsConnection; -import ca.bc.gov.educ.api.dataconversion.messaging.jetstream.Subscriber; -import ca.bc.gov.educ.api.dataconversion.model.ConvGradStudent; -import ca.bc.gov.educ.api.dataconversion.model.tsw.*; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.Code; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportData; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.Transcript; -import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; -import ca.bc.gov.educ.api.dataconversion.util.RestUtils; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.RandomUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.web.reactive.function.client.WebClient; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.sql.Date; -import java.util.*; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.openMocks; - -@RunWith(SpringRunner.class) -@SpringBootTest -@ActiveProfiles("test") -@SuppressWarnings({"unchecked","rawtypes"}) -public class ReportProcessTest { - - @Autowired - private ReportProcess reportProcess; - - @Autowired - private ExceptionMessage exception; - - @MockBean - RestUtils restUtils; - - @MockBean - WebClient webClient; - - // NATS - @MockBean - private NatsConnection natsConnection; - @MockBean - private Subscriber subscriber; - - @Autowired - private EducGradDataConversionApiConstants constants; - - @Before - public void setUp() { - openMocks(this); - } - - @After - public void tearDown() { - - } - - @Test - public void testSaveStudentTranscriptReport() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - String pen="212321123"; - boolean isGraduated= false; - ReportData data = new ReportData(); - data.setGradMessage("ABC"); - Transcript transcript = new Transcript(); - Code code= new Code(); - code.setCode("BC1996-PUB"); - transcript.setTranscriptTypeCode(code); - data.setTranscript(transcript); - ExceptionMessage exception = new ExceptionMessage(); - Date distributionDate = new Date(System.currentTimeMillis()); - - byte[] bytesSAR = RandomUtils.nextBytes(20); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - when(this.restUtils.getTranscriptReport(any(), eq(accessToken))).thenReturn(bytesSAR); - - reportProcess.saveStudentTranscriptReportJasper(data, distributionDate, accessToken, UUID.fromString(studentID),isGraduated,false); - assertThat(exception.getExceptionName()).isNull(); - } - - @Test - public void testGetCertificateList() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("DD Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(null); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123090109"); - spgm.setOptionalProgramCode("BD"); - spgm.setOptionalProgramName("International Bacculaurette Diploma"); - spgm.setOptionalGraduated(true); - spgm.setStudentID(UUID.fromString(studentID)); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - 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.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(comSchObj.getSchoolCategoryCode()); - when(this.restUtils.getProgramCertificateTranscriptList(any(), eq(accessToken))).thenReturn(clist); - - List listCC = reportProcess.getCertificateList(graduationDataStatus, comSchObj.getSchoolCategoryCode(), accessToken); - assertThat(listCC).hasSize(1); - } - - @Test - public void testGetCertificateList_PFProgram() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-PF"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setGradMessage("DD Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - 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.restUtils.getProgramCertificateTranscriptList(any(), eq(accessToken))).thenReturn(clist); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123090109"); - spgm.setOptionalProgramCode("BD"); - spgm.setOptionalProgramName("International Bacculaurette Diploma"); - spgm.setStudentID(UUID.fromString(studentID)); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(comSchObj.getSchoolCategoryCode()); - - List listCC = reportProcess.getCertificateList(graduationDataStatus, comSchObj.getSchoolCategoryCode(), accessToken); - assertThat(listCC).hasSize(1); - } - - @Test - public void testGetCertificateList_PFProgram_nodogwood() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-PF"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(null); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123090109"); - spgm.setOptionalProgramCode("BD"); - spgm.setOptionalProgramName("International Bacculaurette Diploma"); - spgm.setStudentID(UUID.fromString(studentID)); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(comSchObj.getSchoolCategoryCode()); - - List clist= new ArrayList(); - ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); - pc.setCertificateTypeCode("E"); - pc.setSchoolCategoryCode(" "); - clist.add(pc); - - when(this.restUtils.getProgramCertificateTranscriptList(any(), eq(accessToken))).thenReturn(clist); - - List listCC= reportProcess.getCertificateList(graduationDataStatus, comSchObj.getSchoolCategoryCode(), accessToken); - assertThat(listCC).hasSize(1); - } - - @Test - public void testGetCertificateList_emptyOptionalProgram() { - UUID studentID = new UUID(1, 1); - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setStudentID(studentID); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(comSchObj.getSchoolCategoryCode()); - - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(null); - - List clist= new ArrayList(); - ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); - pc.setCertificateTypeCode("E"); - pc.setSchoolCategoryCode(" "); - clist.add(pc); - - when(this.restUtils.getProgramCertificateTranscriptList(any(), eq(accessToken))).thenReturn(clist); - - List optionalGradStatus = new ArrayList<>(); - graduationDataStatus.setOptionalGradStatus(optionalGradStatus); - - List listCC = reportProcess.getCertificateList(graduationDataStatus, comSchObj.getSchoolCategoryCode(), accessToken); - assertThat(listCC).hasSize(1); - } - - @Test - public void testGetCertificateList_FrenchImmersion() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(null); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123090109"); - spgm.setOptionalProgramCode("BD"); - spgm.setOptionalProgramName("International Bacculaurette Diploma"); - spgm.setStudentID(UUID.fromString(studentID)); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - List clist= new ArrayList(); - ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); - pc.setCertificateTypeCode("E"); - pc.setSchoolCategoryCode(" "); - clist.add(pc); - - when(this.restUtils.getProgramCertificateTranscriptList(any(), eq(accessToken))).thenReturn(clist); - - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(comSchObj.getSchoolCategoryCode()); - - List listCC = reportProcess.getCertificateList(graduationDataStatus, comSchObj.getSchoolCategoryCode(), accessToken); - assertThat(listCC).hasSize(1); - } - - @Test - public void testGetCertificateList_FrenchImmersion_nullProgramCompletionDate() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(null); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123090109"); - spgm.setOptionalProgramCode("FI"); - spgm.setOptionalProgramName("French Immersion"); - spgm.setStudentID(UUID.fromString(studentID)); - spgm.setOptionalProgramCompletionDate(null); - List list = new ArrayList(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - List clist= new ArrayList(); - ProgramCertificateTranscript pc = new ProgramCertificateTranscript(); - pc.setCertificateTypeCode("E"); - pc.setSchoolCategoryCode("02"); - clist.add(pc); - - when(this.restUtils.getProgramCertificateTranscriptList(any(), eq(accessToken))).thenReturn(clist); - - CommonSchool comSchObj = new CommonSchool(); - comSchObj.setDistNo("123"); - comSchObj.setSchlNo("1123"); - comSchObj.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(comSchObj.getSchoolCategoryCode()); - - List listCC = reportProcess.getCertificateList(graduationDataStatus, comSchObj.getSchoolCategoryCode(), accessToken); - assertThat(listCC).hasSize(1); - } - - @Test - public void testPrepareReportData() { - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("1"); - - 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"); - sc.setCreditsUsedForGrad(4); - sc.setCredits(4); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("1990/12"); - sc.setEquivOrChallenge("E"); - sc.setProvExamCourse("Y"); - sc.setSpecialCase("A"); - sc.setCourseLevel("11"); - sc.setBestExamPercent(60.8D); - sc.setBestSchoolPercent(90.3D); - List sList= new ArrayList<>(); - sList.add(sc); - StudentCourses sCourses = new StudentCourses(); - sCourses.setStudentCourseList(sList); - - StudentAssessment sA= new StudentAssessment(); - sA.setAssessmentCode("FDFE"); - sA.setAssessmentName("AASASA"); - sA.setSessionDate("2020/12"); - sA.setSpecialCase("A"); - List aList= new ArrayList<>(); - aList.add(sA); - StudentAssessments sAssessments = new StudentAssessments(); - sAssessments.setStudentAssessmentList(aList); - - GraduationProgramCode gpCode = new GraduationProgramCode(); - gpCode.setProgramCode("2018-EN"); - gpCode.setProgramName("2018 Graduation Program"); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); - graduationDataStatus.setGradStudent(stuObj); - graduationDataStatus.setGradProgram(gpCode); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123123123"); - spgm.setOptionalProgramCode("FI"); - spgm.setOptionalProgramName("French Immersion"); - spgm.setStudentID(UUID.randomUUID()); - spgm.setOptionalProgramCompletionDate("2020-09-01"); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - GradProgram gP = new GradProgram(); - gP.setProgramCode("2018-EN"); - gP.setProgramName("2018 Graduation Program"); - - SpecialCase sp = new SpecialCase(); - sp.setSpCase("A"); - sp.setLabel("AEG"); - - when(this.restUtils.getSpecialCase("A", accessToken)).thenReturn(sp); - when(this.restUtils.getGradProgram(gradAlgorithmGraduationStatus.getProgram(), accessToken)).thenReturn(gP); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - - ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); - programCertificateTranscript.setPcId(UUID.randomUUID()); - programCertificateTranscript.setGraduationProgramCode(gP.getProgramCode()); - programCertificateTranscript.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); - programCertificateTranscript.setCertificateTypeCode("E"); - - when(this.restUtils.getTranscript(gP.getProgramCode(), commSch.getSchoolCategoryCode(), accessToken)).thenReturn(programCertificateTranscript); - - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - gradResponse.setLastUpdateDate(new Date(System.currentTimeMillis())); - - ConvGradStudent student = ConvGradStudent.builder().pen("123090109").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(schoolObj) - .certificateSchool(schoolObj) - .transcriptSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .certificateSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData dta = reportProcess.prepareTranscriptData(graduationDataStatus, gradResponse, student, accessToken); - assertThat(dta).isNotNull(); - } - - @Test - public void testPrepareReportData_nullProgramData() { - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = getGradAlgorithmGraduationStatus("2018-EN"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("1"); - - 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("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); - graduationDataStatus.setGradStudent(stuObj); - - GradProgram gP = new GradProgram(); - gP.setProgramCode("2018-EN"); - gP.setProgramName("2018 Graduation Program"); - - GraduationProgramCode gpCode = new GraduationProgramCode(); - gpCode.setProgramCode("2018-EN"); - gpCode.setProgramName("2018 Graduation Program"); - - graduationDataStatus.setGradProgram(gpCode); - - SpecialCase sp = new SpecialCase(); - sp.setSpCase("A"); - sp.setLabel("AEG"); - - when(this.restUtils.getSpecialCase("A", accessToken)).thenReturn(sp); - when(this.restUtils.getGradProgram(gradAlgorithmGraduationStatus.getProgram(), accessToken)).thenReturn(gP); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - gradResponse.setLastUpdateDate(new Date(System.currentTimeMillis())); - - ConvGradStudent student = ConvGradStudent.builder().pen("123090109").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(schoolObj) - .certificateSchool(schoolObj) - .transcriptSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .certificateSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData dta = reportProcess.prepareTranscriptData(graduationDataStatus,gradResponse, student, accessToken); - assertThat(dta).isNotNull(); - } - - @Test - public void testPrepareReportData_exams_notnull() { - String accessToken = "accessToken"; - testPrepareReportData_exams_notnull("1996-EN",accessToken); - 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("1231123"); - schoolObj.setIndependentDesignation("1"); - - GradSearchStudent stuObj = getStudentObj(); - - StudentCourses sCourses = new StudentCourses(); - sCourses.setStudentCourseList(getStudentCourses(2,4)); - - StudentExam se= new StudentExam(); - se.setCourseCode("FDFE"); - List eList= new ArrayList<>(); - eList.add(se); - StudentExams eCourses = new StudentExams(); - eCourses.setStudentExamList(eList); - - StudentAssessments sAssessments = new StudentAssessments(); - sAssessments.setStudentAssessmentList(getStudentAssessments()); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); - graduationDataStatus.setStudentExams(eCourses); - graduationDataStatus.setGradStudent(stuObj); - - GradProgram gP = new GradProgram(); - gP.setProgramCode(program); - gP.setProgramName("2018 Graduation Program"); - - GraduationProgramCode gpCode = new GraduationProgramCode(); - gpCode.setProgramCode("2018-EN"); - gpCode.setProgramName("2018 Graduation Program"); - - graduationDataStatus.setGradProgram(gpCode); - - SpecialCase sp = new SpecialCase(); - sp.setSpCase("A"); - sp.setLabel("AEG"); - - when(this.restUtils.getSpecialCase("A", accessToken)).thenReturn(sp); - when(this.restUtils.getGradProgram(gradAlgorithmGraduationStatus.getProgram(), accessToken)).thenReturn(gP); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("06011033"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram(program); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setHonoursStanding("Y"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - gradResponse.setLastUpdateDate(new Date(System.currentTimeMillis())); - - ConvGradStudent student = ConvGradStudent.builder().pen("123090109").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(schoolObj) - .certificateSchool(schoolObj) - .transcriptSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .certificateSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData dta = reportProcess.prepareTranscriptData(graduationDataStatus,gradResponse,student,accessToken); - assertThat(dta).isNotNull(); - } - - @Test - public void testPrepareReportData_Desig_3() { - String accessToken = "accessToken"; - UUID studentID = UUID.randomUUID(); - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("3"); - - 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"); - sc.setCreditsUsedForGrad(4); - sc.setCredits(4); - sc.setProvExamCourse("Y"); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setEquivOrChallenge("E"); - sc.setCourseLevel("11"); - sc.setBestExamPercent(60.8D); - sc.setBestSchoolPercent(90.3D); - List sList= new ArrayList<>(); - sList.add(sc); - StudentCourses sCourses = new StudentCourses(); - sCourses.setStudentCourseList(sList); - - StudentAssessment sA= new StudentAssessment(); - sA.setAssessmentCode("FDFE"); - sA.setAssessmentName("AASASA"); - sA.setSessionDate("2020/12"); - sA.setSpecialCase("A"); - List aList= new ArrayList<>(); - aList.add(sA); - StudentAssessments sAssessments = new StudentAssessments(); - sAssessments.setStudentAssessmentList(aList); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); - graduationDataStatus.setGradStudent(stuObj); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123123123"); - spgm.setOptionalProgramCode("BD"); - spgm.setOptionalProgramName("International Bacculaurette Diploma"); - spgm.setStudentID(studentID); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - GradProgram gP = new GradProgram(); - gP.setProgramCode("2018-EN"); - gP.setProgramName("2018 Graduation Program"); - - GraduationProgramCode gpCode = new GraduationProgramCode(); - gpCode.setProgramCode("2018-EN"); - gpCode.setProgramName("2018 Graduation Program"); - - graduationDataStatus.setGradProgram(gpCode); - - SpecialCase sp = new SpecialCase(); - sp.setSpCase("A"); - sp.setLabel("AEG"); - - when(this.restUtils.getSpecialCase("A", accessToken)).thenReturn(sp); - when(this.restUtils.getGradProgram(gradAlgorithmGraduationStatus.getProgram(), accessToken)).thenReturn(gP); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - gradResponse.setLastUpdateDate(new Date(System.currentTimeMillis())); - - ConvGradStudent student = ConvGradStudent.builder().pen("123090109").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(schoolObj) - .certificateSchool(schoolObj) - .transcriptSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .certificateSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData dta = reportProcess.prepareTranscriptData(graduationDataStatus,gradResponse,student, accessToken); - assertThat(dta).isNotNull(); - } - - @Test - public void testPrepareReportData_Desig_4() { - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("4"); - - 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"); - sc.setCreditsUsedForGrad(2); - sc.setCredits(4); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setEquivOrChallenge("E"); - sc.setSpecialCase("A"); - sc.setProvExamCourse("N"); - sc.setCourseLevel("11"); - sc.setBestExamPercent(60.8D); - sc.setBestSchoolPercent(90.3D); - List sList= new ArrayList<>(); - sList.add(sc); - StudentCourses sCourses = new StudentCourses(); - sCourses.setStudentCourseList(sList); - - StudentAssessment sA= new StudentAssessment(); - sA.setAssessmentCode("FDFE"); - sA.setAssessmentName("AASASA"); - sA.setSessionDate("2020/12"); - sA.setSpecialCase("A"); - List aList= new ArrayList<>(); - aList.add(sA); - StudentAssessments sAssessments = new StudentAssessments(); - sAssessments.setStudentAssessmentList(aList); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("EN Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); - graduationDataStatus.setGradStudent(stuObj); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123123123"); - spgm.setOptionalProgramCode("CP"); - spgm.setOptionalProgramName("Career Program"); - spgm.setStudentID(UUID.randomUUID()); - List list = new ArrayList<>(); - list.add(spgm); - - graduationDataStatus.setOptionalGradStatus(list); - - GradProgram gP = new GradProgram(); - gP.setProgramCode("2018-EN"); - gP.setProgramName("2018 Graduation Program"); - - GraduationProgramCode gpCode = new GraduationProgramCode(); - gpCode.setProgramCode("2018-EN"); - gpCode.setProgramName("2018 Graduation Program"); - - graduationDataStatus.setGradProgram(gpCode); - - SpecialCase sp = new SpecialCase(); - sp.setSpCase("A"); - sp.setLabel("AEG"); - - when(this.restUtils.getSpecialCase("A", accessToken)).thenReturn(sp); - when(this.restUtils.getGradProgram(gradAlgorithmGraduationStatus.getProgram(), accessToken)).thenReturn(gP); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("06011033", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - gradResponse.setLastUpdateDate(new Date(System.currentTimeMillis())); - - ConvGradStudent student = ConvGradStudent.builder().pen("123090109").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(schoolObj) - .certificateSchool(schoolObj) - .transcriptSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .certificateSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData dta = reportProcess.prepareTranscriptData(graduationDataStatus,gradResponse,student,accessToken); - assertThat(dta).isNotNull(); - } - - - public void testPrepareReportData_Desig_2() { - String accessToken = "accessToken"; - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram("2018-EN"); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - - School schoolObj = new School(); - schoolObj.setMinCode("1231123"); - schoolObj.setIndependentDesignation("2"); - - 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); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setEquivOrChallenge("E"); - List sList= new ArrayList<>(); - sList.add(sc); - StudentCourses sCourses = new StudentCourses(); - sCourses.setStudentCourseList(sList); - - StudentAssessment sA= new StudentAssessment(); - sA.setAssessmentCode("FDFE"); - sA.setAssessmentName("AASASA"); - sA.setSessionDate("2020/12"); - sA.setSpecialCase("A"); - List aList= new ArrayList<>(); - aList.add(sA); - StudentAssessments sAssessments = new StudentAssessments(); - sAssessments.setStudentAssessmentList(aList); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("DD Graduated"); - graduationDataStatus.setGradStatus(gradAlgorithmGraduationStatus); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(schoolObj); - graduationDataStatus.setStudentCourses(sCourses); - graduationDataStatus.setStudentAssessments(sAssessments); - graduationDataStatus.setGradStudent(stuObj); - - GradAlgorithmOptionalStudentProgram spgm = new GradAlgorithmOptionalStudentProgram(); - spgm.setPen("123123123"); - spgm.setOptionalProgramCode("FI"); - spgm.setOptionalProgramName("French Immersion"); - spgm.setStudentID(UUID.randomUUID()); - List list = new ArrayList<>(); - list.add(spgm); - - GradProgram gP = new GradProgram(); - gP.setProgramCode("2018-EN"); - gP.setProgramName("2018 Graduation Program"); - - when(this.restUtils.getGradProgram(gradAlgorithmGraduationStatus.getProgram(), accessToken)).thenReturn(gP); - - GradAlgorithmGraduationStudentRecord gradResponse = new GradAlgorithmGraduationStudentRecord(); - gradResponse.setPen("123090109"); - gradResponse.setProgram("2018-EN"); - gradResponse.setProgramCompletionDate(null); - gradResponse.setSchoolOfRecord("06011033"); - gradResponse.setStudentGrade("11"); - gradResponse.setStudentStatus("D"); - gradResponse.setLastUpdateDate(new Date(System.currentTimeMillis())); - - ConvGradStudent student = ConvGradStudent.builder().pen("123090109").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(schoolObj) - .certificateSchool(schoolObj) -// .schoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData dta = reportProcess.prepareTranscriptData(graduationDataStatus,gradResponse,student,accessToken); - assertThat(dta).isNotNull(); - } - - - private GradAlgorithmGraduationStudentRecord getGradAlgorithmGraduationStatus(String program) { - GradAlgorithmGraduationStudentRecord gradAlgorithmGraduationStatus = new GradAlgorithmGraduationStudentRecord(); - gradAlgorithmGraduationStatus.setPen("123090109"); - gradAlgorithmGraduationStatus.setProgram(program); - gradAlgorithmGraduationStatus.setProgramCompletionDate(null); - gradAlgorithmGraduationStatus.setSchoolOfRecord("06011033"); - gradAlgorithmGraduationStatus.setStudentGrade("11"); - gradAlgorithmGraduationStatus.setStudentStatus("A"); - return gradAlgorithmGraduationStatus; - } - - private GradSearchStudent getStudentObj () { - GradSearchStudent stuObj = new GradSearchStudent(); - stuObj.setPen("123123123"); - stuObj.setLegalFirstName("ABC"); - stuObj.setLegalLastName("FDG"); - stuObj.setSchoolOfRecord("12321321"); - return stuObj; - } - - private List getStudentCourses(int totalCredits,int originalCredits) { - StudentCourse sc= new StudentCourse(); - sc.setCourseCode("FDFE FE"); - sc.setCourseName("FEREE FREE"); - sc.setCourseLevel("11"); - sc.setCredits(totalCredits); - sc.setOriginalCredits(originalCredits); - sc.setCreditsUsedForGrad(2); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setFineArtsAppliedSkills("B"); - sc.setEquivOrChallenge("E"); - sc.setSpecialCase("F"); - sc.setRestricted(true); - sc.setProvExamCourse("N"); - sc.setBestExamPercent(50.0D); - sc.setBestSchoolPercent(50.0D); - List sList= new ArrayList<>(); - sList.add(sc); - sc= new StudentCourse(); - sc.setCourseCode("CPUY"); - sc.setCourseName("CP FEREE FREE"); - sc.setCourseLevel("12A"); - sc.setCredits(totalCredits); - sc.setOriginalCredits(originalCredits); - sc.setCreditsUsedForGrad(2); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setFineArtsAppliedSkills("B"); - sc.setEquivOrChallenge("E"); - sc.setSpecialCase("F"); - sc.setProvExamCourse("Y"); - sc.setRestricted(true); - sList.add(sc); - sc= new StudentCourse(); - sc.setCourseCode("CPUY FR"); - sc.setCourseName("CP FEREE FREE"); - sc.setCourseLevel("12A"); - sc.setCredits(totalCredits); - sc.setSessionDate("1990/11"); - sc.setOriginalCredits(originalCredits); - sc.setCreditsUsedForGrad(2); - sc.setBestSchoolPercent(89D); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setFineArtsAppliedSkills("B"); - sc.setEquivOrChallenge("E"); - sc.setSpecialCase("F"); - sc.setProvExamCourse("Y"); - sc.setRestricted(true); - sList.add(sc); - sc= new StudentCourse(); - sc.setCourseCode("CPUY ZS"); - sc.setCourseName("CP FEREE FREE"); - sc.setCourseLevel("12C"); - sc.setCredits(totalCredits); - sc.setOriginalCredits(originalCredits); - sc.setCreditsUsedForGrad(2); - sc.setBestSchoolPercent(89D); - sc.setCustomizedCourseName("SREE"); - sc.setSessionDate("2020/12"); - sc.setFineArtsAppliedSkills("B"); - sc.setEquivOrChallenge("E"); - sc.setSpecialCase("F"); - sc.setProvExamCourse("Y"); - sc.setRestricted(true); - sList.add(sc); - return sList; - } - - private List getStudentAssessments() { - StudentAssessment sA= new StudentAssessment(); - sA.setAssessmentCode("FDFE"); - sA.setAssessmentName("AASASA"); - sA.setSessionDate("2020/12"); - sA.setSpecialCase("A"); - List aList= new ArrayList<>(); - aList.add(sA); - return aList; - } - - @Test - public void testReportDataByPen() throws Exception { - GraduationData gradStatus = createGraduationData("json/gradstatus.json"); - assertNotNull(gradStatus); - String pen = gradStatus.getGradStudent().getPen(); - GradSearchStudent gradSearchStudent = new GradSearchStudent(); - gradSearchStudent.setPen(pen); - gradSearchStudent.setStudentID(gradStatus.getGradStudent().getStudentID()); - - GradAlgorithmGraduationStudentRecord graduationStudentRecord = new GradAlgorithmGraduationStudentRecord(); - graduationStudentRecord.setPen(pen); - graduationStudentRecord.setProgramCompletionDate("2003/01"); - graduationStudentRecord.setStudentID(UUID.fromString(gradSearchStudent.getStudentID())); - graduationStudentRecord.setLastUpdateDate(new Date(System.currentTimeMillis())); - - String accessToken = "accessToken"; - - String studentGradData = readFile("json/gradstatus.json"); - assertNotNull(studentGradData); - graduationStudentRecord.setStudentGradData(new ObjectMapper().writeValueAsString(gradStatus)); - - GradProgram gradProgram = new GradProgram(); - gradProgram.setProgramCode("2018-EN"); - gradProgram.setProgramName("2018 Graduation Program"); - - when(this.restUtils.getGradProgram(gradStatus.getGradStudent().getProgram(), accessToken)).thenReturn(gradProgram); - - School school = new School(); - school.setMinCode("1231123"); - school.setSchoolName("Test School"); - - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.restUtils.getSchoolCategoryCode("00502001", accessToken)).thenReturn(commSch.getSchoolCategoryCode()); - - ProgramCertificateTranscript programCertificateTranscript = new ProgramCertificateTranscript(); - programCertificateTranscript.setPcId(UUID.randomUUID()); - programCertificateTranscript.setGraduationProgramCode(gradProgram.getProgramCode()); - programCertificateTranscript.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); - programCertificateTranscript.setCertificateTypeCode("E"); - - ProgramCertificateReq req = new ProgramCertificateReq(); - req.setProgramCode(gradProgram.getProgramCode()); - req.setSchoolCategoryCode(commSch.getSchoolCategoryCode()); - - SpecialCase sp = new SpecialCase(); - sp.setSpCase("A"); - sp.setLabel("AEG"); - - when(this.restUtils.getSpecialCase("A", accessToken)).thenReturn(sp); - when(this.restUtils.getTranscript(gradProgram.getProgramCode(), commSch.getSchoolCategoryCode(), accessToken)).thenReturn(programCertificateTranscript); - - GraduationData graduationDataStatus = new GraduationData(); - graduationDataStatus.setDualDogwood(false); - graduationDataStatus.setGradMessage("Not Graduated"); - graduationDataStatus.setGradStatus(gradStatus.getGradStatus()); - graduationDataStatus.setGraduated(true); - graduationDataStatus.setSchool(school); - graduationDataStatus.setStudentCourses(gradStatus.getStudentCourses()); - graduationDataStatus.setStudentAssessments(gradStatus.getStudentAssessments()); - graduationDataStatus.setGradStudent(gradSearchStudent); - - GraduationProgramCode gpCode = new GraduationProgramCode(); - gpCode.setProgramCode("2018-EN"); - gpCode.setProgramName("2018 Graduation Program"); - - graduationDataStatus.setGradProgram(gpCode); - - ConvGradStudent student = ConvGradStudent.builder().pen("129382610").program("2018-EN") - .studentStatus("A").schoolOfRecord("06011033").graduationRequirementYear("2018") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .certificateSchoolCategoryCode(commSch.getSchoolCategoryCode()) - .programCodes(Arrays.asList("DD")).build(); - - ReportData transcriptData = reportProcess.prepareTranscriptData(graduationDataStatus, graduationStudentRecord, student, "accessToken"); - assertNotNull(transcriptData); - assertNotNull(transcriptData.getStudent()); - assertNotNull(transcriptData.getTranscript()); - - ReportData certificateData = reportProcess.prepareCertificateData(graduationDataStatus, programCertificateTranscript, student, "accessToken"); - assertNotNull(certificateData); - assertNotNull(certificateData.getStudent()); - assertNotNull(certificateData.getCertificate()); - - } - - protected GraduationData createGraduationData(String jsonPath) throws Exception { - File file = new File(Objects.requireNonNull(ReportProcessTest.class.getClassLoader().getResource(jsonPath)).getFile()); - return new ObjectMapper().readValue(file, GraduationData.class); - - } - - protected String readFile(String jsonPath) throws Exception { - ClassLoader classLoader = getClass().getClassLoader(); - InputStream inputStream = classLoader.getResourceAsStream(jsonPath); - return readInputStream(inputStream); - } - - private String readInputStream(InputStream is) throws Exception { - StringBuffer sb = new StringBuffer(); - InputStreamReader streamReader = new InputStreamReader(is, StandardCharsets.UTF_8); - BufferedReader reader = new BufferedReader(streamReader); - String line; - while ((line = reader.readLine()) != null) { - sb.append(line); - } - return sb.toString(); - } - -} diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java index 35352859..9001eaf6 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/process/StudentProcessTest.java @@ -1,16 +1,11 @@ package ca.bc.gov.educ.api.dataconversion.process; -import ca.bc.gov.educ.api.dataconversion.constant.ConversionResultType; import ca.bc.gov.educ.api.dataconversion.constant.EventType; -import ca.bc.gov.educ.api.dataconversion.constant.StudentLoadType; import ca.bc.gov.educ.api.dataconversion.messaging.NatsConnection; import ca.bc.gov.educ.api.dataconversion.messaging.jetstream.Subscriber; import ca.bc.gov.educ.api.dataconversion.model.*; import ca.bc.gov.educ.api.dataconversion.model.tsw.School; -import ca.bc.gov.educ.api.dataconversion.model.tsw.SpecialCase; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportData; import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; -import ca.bc.gov.educ.api.dataconversion.service.student.StudentBaseService; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; import ca.bc.gov.educ.api.dataconversion.util.RestUtils; @@ -50,9 +45,6 @@ public class StudentProcessTest { @MockBean AssessmentProcess assessmentProcess; - @MockBean - ReportProcess reportProcess; - @MockBean RestUtils restUtils; @@ -78,46 +70,6 @@ public void tearDown() { } - @Test - public void convertStudent_forSchoolValidation_whenGivenSchool_doesNotExist_thenReturnFailure() throws Exception { - String pen = "111222333"; - String mincode = "222333"; - - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .studentLoadType(StudentLoadType.UNGRAD) - .programCodes(new ArrayList<>()).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("SCCP"); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Invalid school of record"); - } - - @Test - public void convertGraduatedStudent_forSchoolValidation_whenGivenSPMSchool_doesNotExist_thenReturnFailure() throws Exception { - String pen = "111222333"; - String mincode = "222333"; - - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") - .studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .studentLoadType(StudentLoadType.GRAD_ONE) - .programCodes(new ArrayList<>()).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("SCCP"); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("School does not exist in SPM School data"); - } - @Test public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_thenReturnFailure() throws Exception { String pen = "111222333"; @@ -131,8 +83,6 @@ public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_the ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .transcriptSchool(school) - .studentLoadType(StudentLoadType.UNGRAD) .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -158,8 +108,6 @@ public void convertStudent_forPenStudentValidation_whenPENAPI_isDown_thenReturnF ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") .studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .transcriptSchool(school) - .studentLoadType(StudentLoadType.UNGRAD) .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -197,13 +145,10 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("SCCP") .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("SCCP") - .transcriptSchool(school) - .studentLoadType(StudentLoadType.UNGRAD) .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -239,14 +184,11 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1950") .studentGrade("AD").archiveFlag("A").studentStatus("A") .schoolOfRecord(mincode).graduationRequirementYear("1950") - .transcriptSchool(school) - .studentLoadType(StudentLoadType.UNGRAD) .programCodes(new ArrayList<>()).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -307,7 +249,6 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(null); when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); @@ -315,7 +256,6 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-EN") .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("2018") - .transcriptSchool(school).studentLoadType(StudentLoadType.UNGRAD) .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); @@ -381,2813 +321,114 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR studentCareerProgram.setStudentID(studentID); studentCareerProgram.setCareerProgramCode("XC"); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgram("2018-EN", "FI", "123")).thenReturn(specialProgram); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("2018") - .transcriptSchool(school).studentLoadType(StudentLoadType.UNGRAD) - .programCodes(Arrays.asList("XC")).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("2018"); - assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); - - } - - @Test - public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1986-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("MER"); - - OptionalProgram specialProgram = new OptionalProgram(); - specialProgram.setOptionalProgramID(UUID.randomUUID()); - specialProgram.setGraduationProgramCode("1986-EN"); - specialProgram.setOptProgramCode("FI"); - specialProgram.setOptionalProgramName("French Immersion"); - - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); - studentOptionalProgram.setId(UUID.randomUUID()); - studentOptionalProgram.setStudentID(studentID); - studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); - studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); - studentOptionalProgram.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .studentStatus("M").schoolOfRecord(mincode).graduationRequirementYear("1986").studentLoadType(StudentLoadType.UNGRAD) - .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); - assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); - - } - - @Test - public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1996-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - - OptionalProgram specialProgram = new OptionalProgram(); - specialProgram.setOptionalProgramID(UUID.randomUUID()); - specialProgram.setGraduationProgramCode("1996-EN"); - specialProgram.setOptProgramCode("FI"); - specialProgram.setOptionalProgramName("French Immersion"); - - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); - studentOptionalProgram.setId(UUID.randomUUID()); - studentOptionalProgram.setStudentID(studentID); - studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); - studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); - studentOptionalProgram.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "11", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgram("1996-EN", "FI", "123")).thenReturn(specialProgram); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1996-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1996").studentLoadType(StudentLoadType.UNGRAD) - .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1996"); - assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); - - } - - @Test - public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1986-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - - OptionalProgram specialProgram = new OptionalProgram(); - specialProgram.setOptionalProgramID(UUID.randomUUID()); - specialProgram.setGraduationProgramCode("1986-EN"); - specialProgram.setOptProgramCode("FI"); - specialProgram.setOptionalProgramName("French Immersion"); - - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); - studentOptionalProgram.setId(UUID.randomUUID()); - studentOptionalProgram.setStudentID(studentID); - studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); - studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); - studentOptionalProgram.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1986").studentLoadType(StudentLoadType.UNGRAD) - .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); - assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); - - } - - @Test - public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1986-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("ARC"); - - OptionalProgram specialProgram = new OptionalProgram(); - specialProgram.setOptionalProgramID(UUID.randomUUID()); - specialProgram.setGraduationProgramCode("1986-EN"); - specialProgram.setOptProgramCode("FI"); - specialProgram.setOptionalProgramName("French Immersion"); - - StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); - studentOptionalProgram.setId(UUID.randomUUID()); - studentOptionalProgram.setStudentID(studentID); - studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); - studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); - studentOptionalProgram.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .archiveFlag("I").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1986").studentLoadType(StudentLoadType.UNGRAD) - .transcriptSchool(school).programCodes(Arrays.asList("XC")).build(); - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); - assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_whenGiven1950Data_withoutProgramCompletionDate_thenReturnFailure() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1950"); - gradStudent.setStudentGrade("AD"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("N"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1950") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("0") - .englishCert("E") - .frenchCert("F") - .studentGrade("AD") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1950") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .build(); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Bad data: grad_date is null for"); - } - - @Test - public void convertGraduatedStudent_whenGiven1950DataFor2Programs_withoutSccDate_thenReturnFailure() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1950"); - gradStudent.setStudentGrade("AD"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("N"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1950") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_TWO) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("0") - .sccDate(null) - .englishCert("E") - .frenchCert("F") - .studentGrade("AD") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1950") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .build(); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Bad data for graduated - 2 programs"); - } - - - @Test - public void convertGraduatedStudent_whenGivenSCCPData_withoutSlpDate_thenReturnFailure() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("SCCP"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("N"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("SCCP") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("SCCP") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .build(); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Bad data: slp_date is null for SCCP"); - } - - @Test - public void convertGraduatedStudent_whenGraduationStudentRecordIsRetrievedAndGradStudentAPIisDown_thenThrowsExceptionWithFailure() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("SCCP"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("N"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenThrow(new RuntimeException("GRAD Student API is down!")); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("SCCP") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("20200118") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("SCCP") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .build(); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Grad Student API is failed for"); - } - - @Test - public void convertGraduatedStudent_whenGraduationStudentRecordIsCreatedAndGradStudentAPIisDown_thenThrowsExceptionWithFailure() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("SCCP"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("N"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("SCCP"); - tranStudentDemog.setUpdateDate(20220601L); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("SCCP") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("20200118") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("SCCP") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .transcriptStudentDemog(tranStudentDemog) - .build(); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Grad Student API is failed for"); - } - - @Test - public void convertGraduatedStudent_whenGraduationStudentRecordIsUpdatedAndGradStudentAPIisDown_thenThrowsExceptionWithFailure() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("SCCP"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("N"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("SCCP"); - tranStudentDemog.setUpdateDate(20220601L); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenThrow(new RuntimeException("Grad Student API is down!")); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("SCCP") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("20200118") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("SCCP") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .transcriptStudentDemog(tranStudentDemog) - .build(); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getResult()).isEqualTo(ConversionResultType.FAILURE); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Grad Student API is failed for"); - } - - @Test - public void convertGraduatedStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1986-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("Y"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - OptionalProgram optionalProgram1 = new OptionalProgram(); - optionalProgram1.setOptionalProgramID(UUID.randomUUID()); - optionalProgram1.setGraduationProgramCode("1986-EN"); - optionalProgram1.setOptProgramCode("FI"); - optionalProgram1.setOptionalProgramName("French Immersion"); - - StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); - studentOptionalProgram1.setId(UUID.randomUUID()); - studentOptionalProgram1.setStudentID(studentID); - studentOptionalProgram1.setOptionalProgramID(optionalProgram1.getOptionalProgramID()); - studentOptionalProgram1.setOptionalProgramName(optionalProgram1.getOptionalProgramName()); - studentOptionalProgram1.setPen(pen); - - OptionalProgram optionalProgram2 = new OptionalProgram(); - optionalProgram2.setOptionalProgramID(UUID.randomUUID()); - optionalProgram2.setGraduationProgramCode("1986-EN"); - optionalProgram2.setOptProgramCode("CP"); - optionalProgram2.setOptionalProgramName("Career Program"); - - StudentOptionalProgram studentOptionalProgram2 = new StudentOptionalProgram(); - studentOptionalProgram2.setId(UUID.randomUUID()); - studentOptionalProgram2.setStudentID(studentID); - studentOptionalProgram2.setOptionalProgramID(optionalProgram2.getOptionalProgramID()); - studentOptionalProgram2.setOptionalProgramName(optionalProgram2.getOptionalProgramName()); - studentOptionalProgram2.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram1.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(optionalProgram1.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("1986"); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setSpecialCase("E"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse3 = new TranscriptStudentCourse(); - tswCourse3.setStudNo(pen); - tswCourse3.setReportType("2"); - tswCourse3.setCourseCode("TestCourse2"); - tswCourse3.setCourseName("Test Course2 Name"); - tswCourse3.setCourseLevel("12"); - tswCourse3.setFinalPercentage("XMT"); - tswCourse3.setFinalLG("A"); - tswCourse3.setCourseSession("202206"); - tswCourse3.setNumberOfCredits("4"); - tswCourse3.setUsedForGrad("4"); - tswCourse3.setFoundationReq("11"); - tswCourse3.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("1986-EN"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("1986-EN"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("1986-EN"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("1986-EN"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("1986-EN"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("1986-EN"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); - when(this.restUtils.getStudentCareerPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentCareerProgram)); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgramByID(optionalProgram1.getOptionalProgramID(), "123")).thenReturn(optionalProgram1); - when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(optionalProgram1); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - when(this.restUtils.getGradProgramRules("1986-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("0") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1986") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(Arrays.asList("XC")).build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswCourse3, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); - assertThat(result.getProgram()).isEqualTo(optionalProgram1.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaureateDiplomaProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("2004-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("Y"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - OptionalProgram optionalProgram1 = new OptionalProgram(); - optionalProgram1.setOptionalProgramID(UUID.randomUUID()); - optionalProgram1.setGraduationProgramCode("2004-EN"); - optionalProgram1.setOptProgramCode("BD"); - optionalProgram1.setOptionalProgramName("International Baccalaureate Diploma Program "); - - StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); - studentOptionalProgram1.setId(UUID.randomUUID()); - studentOptionalProgram1.setStudentID(studentID); - studentOptionalProgram1.setOptionalProgramID(optionalProgram1.getOptionalProgramID()); - studentOptionalProgram1.setOptionalProgramName(optionalProgram1.getOptionalProgramName()); - studentOptionalProgram1.setOptionalProgramCode("BD"); - studentOptionalProgram1.setPen(pen); - - OptionalProgram optionalProgram2 = new OptionalProgram(); - optionalProgram2.setOptionalProgramID(UUID.randomUUID()); - optionalProgram2.setGraduationProgramCode("2004-EN"); - optionalProgram2.setOptProgramCode("CP"); - optionalProgram2.setOptionalProgramName("Career Program"); - - StudentOptionalProgram studentOptionalProgram2 = new StudentOptionalProgram(); - studentOptionalProgram2.setId(UUID.randomUUID()); - studentOptionalProgram2.setStudentID(studentID); - studentOptionalProgram2.setOptionalProgramID(optionalProgram2.getOptionalProgramID()); - studentOptionalProgram2.setOptionalProgramName(optionalProgram2.getOptionalProgramName()); - studentOptionalProgram2.setOptionalProgramCode("CP"); - studentOptionalProgram2.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram1.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(optionalProgram1.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("2004"); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setSpecialCase("E"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse3 = new TranscriptStudentCourse(); - tswCourse3.setStudNo(pen); - tswCourse3.setReportType("2"); - tswCourse3.setCourseCode("TestCourse2"); - tswCourse3.setCourseName("Test Course2 Name"); - tswCourse3.setCourseLevel("12"); - tswCourse3.setFinalPercentage("XMT"); - tswCourse3.setFinalLG("A"); - tswCourse3.setCourseSession("202206"); - tswCourse3.setNumberOfCredits("4"); - tswCourse3.setUsedForGrad("4"); - tswCourse3.setFoundationReq("11"); - tswCourse3.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("2004-EN"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("2004-EN"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("2004-EN"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("2004-EN"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("2004-EN"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("2004-EN"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); - when(this.restUtils.getStudentCareerPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentCareerProgram)); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgramByID(optionalProgram1.getOptionalProgramID(), "123")).thenReturn(optionalProgram1); - when(this.restUtils.getOptionalProgram("2004-EN", "FI", "123")).thenReturn(optionalProgram1); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - when(this.restUtils.getGradProgramRules("2004-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2004-EN") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("0") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("2004") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(Arrays.asList("XC", "BD")).build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswCourse3, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("2004"); - assertThat(result.getProgram()).isEqualTo(optionalProgram1.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_whenGiven2004Data_withInternationalBaccalaureateCertificateProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("2004-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("Y"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - OptionalProgram optionalProgram1 = new OptionalProgram(); - optionalProgram1.setOptionalProgramID(UUID.randomUUID()); - optionalProgram1.setGraduationProgramCode("2004-EN"); - optionalProgram1.setOptProgramCode("BC"); - optionalProgram1.setOptionalProgramName("International Baccalaureate Certificate Program "); - - StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); - studentOptionalProgram1.setId(UUID.randomUUID()); - studentOptionalProgram1.setStudentID(studentID); - studentOptionalProgram1.setOptionalProgramID(optionalProgram1.getOptionalProgramID()); - studentOptionalProgram1.setOptionalProgramName(optionalProgram1.getOptionalProgramName()); - studentOptionalProgram1.setOptionalProgramCode("BC"); - studentOptionalProgram1.setPen(pen); - - OptionalProgram optionalProgram2 = new OptionalProgram(); - optionalProgram2.setOptionalProgramID(UUID.randomUUID()); - optionalProgram2.setGraduationProgramCode("2004-EN"); - optionalProgram2.setOptProgramCode("CP"); - optionalProgram2.setOptionalProgramName("Career Program"); - - StudentOptionalProgram studentOptionalProgram2 = new StudentOptionalProgram(); - studentOptionalProgram2.setId(UUID.randomUUID()); - studentOptionalProgram2.setStudentID(studentID); - studentOptionalProgram2.setOptionalProgramID(optionalProgram2.getOptionalProgramID()); - studentOptionalProgram2.setOptionalProgramName(optionalProgram2.getOptionalProgramName()); - studentOptionalProgram2.setOptionalProgramCode("CP"); - studentOptionalProgram2.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram1.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(optionalProgram1.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("2004"); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setSpecialCase("E"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse3 = new TranscriptStudentCourse(); - tswCourse3.setStudNo(pen); - tswCourse3.setReportType("2"); - tswCourse3.setCourseCode("TestCourse2"); - tswCourse3.setCourseName("Test Course2 Name"); - tswCourse3.setCourseLevel("12"); - tswCourse3.setFinalPercentage("XMT"); - tswCourse3.setFinalLG("A"); - tswCourse3.setCourseSession("202206"); - tswCourse3.setNumberOfCredits("4"); - tswCourse3.setUsedForGrad("4"); - tswCourse3.setFoundationReq("11"); - tswCourse3.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("2004-EN"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("2004-EN"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("2004-EN"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("2004-EN"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("2004-EN"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("2004-EN"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); - when(this.restUtils.getStudentCareerPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentCareerProgram)); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgramByID(optionalProgram1.getOptionalProgramID(), "123")).thenReturn(optionalProgram1); - when(this.restUtils.getOptionalProgram("2004-EN", "FI", "123")).thenReturn(optionalProgram1); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - when(this.restUtils.getGradProgramRules("2004-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2004-EN") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("0") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("2004") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(Arrays.asList("XC", "BC")).build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswCourse3, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("2004"); - assertThat(result.getProgram()).isEqualTo(optionalProgram1.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_whenGiven2018Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("2018-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("Y"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - OptionalProgram optionalProgram1 = new OptionalProgram(); - optionalProgram1.setOptionalProgramID(UUID.randomUUID()); - optionalProgram1.setGraduationProgramCode("2018-EN"); - optionalProgram1.setOptProgramCode("FI"); - optionalProgram1.setOptionalProgramName("French Immersion"); - - StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); - studentOptionalProgram1.setId(UUID.randomUUID()); - studentOptionalProgram1.setStudentID(studentID); - studentOptionalProgram1.setOptionalProgramID(optionalProgram1.getOptionalProgramID()); - studentOptionalProgram1.setOptionalProgramName(optionalProgram1.getOptionalProgramName()); - studentOptionalProgram1.setOptionalProgramCode("FI"); - studentOptionalProgram1.setPen(pen); - - OptionalProgram optionalProgram2 = new OptionalProgram(); - optionalProgram2.setOptionalProgramID(UUID.randomUUID()); - optionalProgram2.setGraduationProgramCode("2018-EN"); - optionalProgram2.setOptProgramCode("CP"); - optionalProgram2.setOptionalProgramName("Career Program"); - - StudentOptionalProgram studentOptionalProgram2 = new StudentOptionalProgram(); - studentOptionalProgram2.setId(UUID.randomUUID()); - studentOptionalProgram2.setStudentID(studentID); - studentOptionalProgram2.setOptionalProgramID(optionalProgram2.getOptionalProgramID()); - studentOptionalProgram2.setOptionalProgramName(optionalProgram2.getOptionalProgramName()); - studentOptionalProgram2.setOptionalProgramCode("CP"); - studentOptionalProgram2.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram1.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(optionalProgram1.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("2018"); - tranStudentDemog.setUpdateDate(20220601L); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_FI_GRAD_MSG); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("2018-EN"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("2018-EN"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("2018-EN"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("2018-EN"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("2018-EN"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("2018-EN"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); - when(this.restUtils.getStudentCareerPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentCareerProgram)); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgramByID(optionalProgram1.getOptionalProgramID(), "123")).thenReturn(optionalProgram1); - when(this.restUtils.getOptionalProgram("2018-EN", "FI", "123")).thenReturn(optionalProgram1); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-EN") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate("0") - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("2018") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(Arrays.asList("XC")).build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("2018"); - assertThat(result.getProgram()).isEqualTo(optionalProgram1.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_whenGiven1996Data_withAdvancedPlacementProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1996-EN"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("Y"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - OptionalProgram optionalProgram1 = new OptionalProgram(); - optionalProgram1.setOptionalProgramID(UUID.randomUUID()); - optionalProgram1.setGraduationProgramCode("1996-EN"); - optionalProgram1.setOptProgramCode("AD"); - optionalProgram1.setOptionalProgramName("Advanced Placement"); - - StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); - studentOptionalProgram1.setId(UUID.randomUUID()); - studentOptionalProgram1.setStudentID(studentID); - studentOptionalProgram1.setOptionalProgramID(optionalProgram1.getOptionalProgramID()); - studentOptionalProgram1.setOptionalProgramName(optionalProgram1.getOptionalProgramName()); - studentOptionalProgram1.setOptionalProgramCode("AD"); - studentOptionalProgram1.setPen(pen); - - OptionalProgram optionalProgram2 = new OptionalProgram(); - optionalProgram2.setOptionalProgramID(UUID.randomUUID()); - optionalProgram2.setGraduationProgramCode("1996-EN"); - optionalProgram2.setOptProgramCode("CP"); - optionalProgram2.setOptionalProgramName("Career Program"); - - StudentOptionalProgram studentOptionalProgram2 = new StudentOptionalProgram(); - studentOptionalProgram2.setId(UUID.randomUUID()); - studentOptionalProgram2.setStudentID(studentID); - studentOptionalProgram2.setOptionalProgramID(optionalProgram2.getOptionalProgramID()); - studentOptionalProgram2.setOptionalProgramName(optionalProgram2.getOptionalProgramName()); - studentOptionalProgram2.setOptionalProgramCode("CP"); - studentOptionalProgram2.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram1.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(optionalProgram1.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("1996"); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("1996-EN"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("1996-EN"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("1996-EN"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("1996-EN"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("1996-EN"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("1996-EN"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); - when(this.restUtils.getStudentCareerPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentCareerProgram)); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgramByID(optionalProgram1.getOptionalProgramID(), "123")).thenReturn(optionalProgram1); - when(this.restUtils.getOptionalProgram("1996-EN", "FI", "123")).thenReturn(optionalProgram1); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - when(this.restUtils.getGradProgramRules("1996-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1996-EN") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .englishCert("E") - .frenchCert("F") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1996") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(Arrays.asList("XC","AD")).build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1996"); - assertThat(result.getProgram()).isEqualTo(optionalProgram1.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_whenGiven2018PFData_witDualDogwoodProgram_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "093333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("2018-PF"); - gradStudent.setStudentGrade("12"); - gradStudent.setStudentStatus("CUR"); - gradStudent.setHonoursStanding("Y"); - gradStudent.setSchoolAtGrad(mincode); - gradStudent.setSchoolOfRecord(mincode); - gradStudent.setProgramCompletionDate(EducGradDataConversionApiUtils.formatDate(new Date(System.currentTimeMillis() - 600000L))); - gradStudent.setStudentCitizenship("C"); - - OptionalProgram optionalProgram1 = new OptionalProgram(); - optionalProgram1.setOptionalProgramID(UUID.randomUUID()); - optionalProgram1.setGraduationProgramCode("2018-PF"); - optionalProgram1.setOptProgramCode("DD"); - optionalProgram1.setOptionalProgramName("Dual Dogwood"); - - StudentOptionalProgram studentOptionalProgram1 = new StudentOptionalProgram(); - studentOptionalProgram1.setId(UUID.randomUUID()); - studentOptionalProgram1.setStudentID(studentID); - studentOptionalProgram1.setOptionalProgramID(optionalProgram1.getOptionalProgramID()); - studentOptionalProgram1.setOptionalProgramName(optionalProgram1.getOptionalProgramName()); - studentOptionalProgram1.setOptionalProgramCode("DD"); - studentOptionalProgram1.setPen(pen); - - OptionalProgram optionalProgram2 = new OptionalProgram(); - optionalProgram2.setOptionalProgramID(UUID.randomUUID()); - optionalProgram2.setGraduationProgramCode("2018-PF"); - optionalProgram2.setOptProgramCode("CP"); - optionalProgram2.setOptionalProgramName("Career Program"); - - StudentOptionalProgram studentOptionalProgram2 = new StudentOptionalProgram(); - studentOptionalProgram2.setId(UUID.randomUUID()); - studentOptionalProgram2.setStudentID(studentID); - studentOptionalProgram2.setOptionalProgramID(optionalProgram2.getOptionalProgramID()); - studentOptionalProgram2.setOptionalProgramName(optionalProgram2.getOptionalProgramName()); - studentOptionalProgram2.setOptionalProgramCode("CP"); - studentOptionalProgram2.setPen(pen); - - StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); - specialProgramReq.setId(studentOptionalProgram1.getId()); - specialProgramReq.setStudentID(studentID); - specialProgramReq.setMainProgramCode(gradStudent.getProgram()); - specialProgramReq.setOptionalProgramCode(optionalProgram1.getOptProgramCode()); - specialProgramReq.setPen(pen); - - CareerProgram careerProgram = new CareerProgram(); - careerProgram.setCode("XC"); - careerProgram.setDescription("XC Test"); - careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); - careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); - - StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); - studentCareerProgram.setId(UUID.randomUUID()); - studentCareerProgram.setStudentID(studentID); - studentCareerProgram.setCareerProgramCode("XC"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("12"); - tranStudentDemog.setGradReqtYear("2018"); - tranStudentDemog.setUpdateDate(20220601L); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("2018-PF"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("2018-PF"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("2018-PF"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("2018-PF"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("2018-PF"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("2018-PF"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getCareerProgram("XC", "123")).thenReturn(careerProgram); - when(this.restUtils.getStudentOptionalPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentOptionalProgram1, studentOptionalProgram2)); - when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram1); - when(this.restUtils.getStudentCareerPrograms(studentID.toString(), "123")).thenReturn(Arrays.asList(studentCareerProgram)); - when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getOptionalProgramByID(optionalProgram1.getOptionalProgramID(), "123")).thenReturn(optionalProgram1); - when(this.restUtils.getOptionalProgram("2018-PF", "DD", "123")).thenReturn(optionalProgram1); - when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); - when(this.restUtils.getGradProgramRules("2018-PF", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-PF") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .englishCert("E") - .frenchCert("S") - .studentGrade("12") - .studentStatus("A").schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("2018") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(Arrays.asList("XC")).build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - - when(this.reportProcess.prepareTranscriptData(any(), any(), any(), eq(summary.getAccessToken()))).thenReturn(new ReportData()); - - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("2018"); - assertThat(result.getProgram()).isEqualTo(optionalProgram1.getGraduationProgramCode()); - - } - - @Test - public void convertGraduatedStudent_forAdult1950_thenReturnSuccess() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - penStudent.setDob("2000-06-30"); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1950"); - gradStudent.setStudentGrade("AD"); - gradStudent.setStudentStatus("CUR"); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("AD"); - tranStudentDemog.setGradReqtYear("1950"); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("1950"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("1950"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("1950"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("1950"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("1950"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("1950"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("1950") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .englishCert("E") - .frenchCert("F") - .studentStatus("A") - .studentGrade("AD") - .schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1950") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(new ArrayList<>()) - .build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); - - ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); - summary.setAccessToken("123"); - var result = studentProcess.convertStudent(student, summary, false, false); - - assertThat(result).isNotNull(); - assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1950"); - - } - - @Test - public void convertGraduatedStudent_forAdult1950_whenAssessmentIsLTE10AndProficiencyScoreIsGreaterThanZero_thenReturnSuccess_withRMIndicator() throws Exception { - // ID - UUID studentID = UUID.randomUUID(); - String pen = "111222333"; - String mincode = "222333"; - - Student penStudent = new Student(); - penStudent.setStudentID(studentID.toString()); - penStudent.setPen(pen); - penStudent.setDob("2000-06-30"); - - GraduationStudentRecord gradStudent = new GraduationStudentRecord(); - gradStudent.setStudentID(studentID); - gradStudent.setPen(pen); - gradStudent.setProgram("1950"); - gradStudent.setStudentGrade("AD"); - gradStudent.setStudentStatus("CUR"); - - StudentAssessment studentAssessment = new StudentAssessment(); - studentAssessment.setPen(pen); - studentAssessment.setAssessmentCode("LTE10"); - studentAssessment.setAssessmentName("Literacy English 10"); - studentAssessment.setSessionDate("202206"); - studentAssessment.setProficiencyScore(Double.valueOf("2.0")); - - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("AD"); - tranStudentDemog.setGradReqtYear("1950"); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment1 = new TranscriptStudentCourse(); - tswAssessment1.setStudNo(pen); - tswAssessment1.setReportType("3"); - tswAssessment1.setCourseCode("TestAssmt"); - tswAssessment1.setCourseName("Test Assessment Name"); - tswAssessment1.setCourseLevel("12"); - tswAssessment1.setFinalPercentage("XMT"); - tswAssessment1.setCourseSession("202206"); - tswAssessment1.setFoundationReq("15"); - tswAssessment1.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - TranscriptStudentCourse tswAssessment2 = new TranscriptStudentCourse(); - tswAssessment2.setStudNo(pen); - tswAssessment2.setReportType("3"); - tswAssessment2.setCourseCode("LTE10"); - tswAssessment2.setCourseName("Literacy English 10"); - tswAssessment2.setCourseLevel("10"); - tswAssessment2.setFinalPercentage("RM"); - tswAssessment2.setCourseSession("202206"); - tswAssessment2.setFoundationReq("15"); - tswAssessment2.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); - - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("1950"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("1950"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("1950"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("1950"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("1950"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("1950"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); + when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); + when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); + when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - when(this.restUtils.getStudentAssessmentsByPenAndAssessmentCode(pen, "LTE10", "123")).thenReturn(Arrays.asList(studentAssessment)); - - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("1950") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .englishCert("E") - .frenchCert("F") - .studentStatus("A") - .studentGrade("AD") - .schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1950") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(new ArrayList<>()) - .build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment1, tswAssessment2)); + when(this.restUtils.getOptionalProgram("2018-EN", "FI", "123")).thenReturn(specialProgram); + ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("2018-EN") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("2018") + .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1950"); + assertThat(result.getGraduationRequirementYear()).isEqualTo("2018"); + assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); } @Test - public void convertGraduatedStudent_for1950NotInAD_thenReturnSuccess() throws Exception { + public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + School school = new School(); + school.setMinCode(mincode); + school.setSchoolName("Test School"); + Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); penStudent.setPen(pen); - penStudent.setDob("2000-06-30"); GraduationStudentRecord gradStudent = new GraduationStudentRecord(); gradStudent.setStudentID(studentID); gradStudent.setPen(pen); - gradStudent.setProgram("1950"); - gradStudent.setStudentGrade("AN"); - gradStudent.setStudentStatus("CUR"); + gradStudent.setProgram("1986-EN"); + gradStudent.setStudentGrade("12"); + gradStudent.setStudentStatus("MER"); - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("AN"); - tranStudentDemog.setGradReqtYear("1950"); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); + OptionalProgram specialProgram = new OptionalProgram(); + specialProgram.setOptionalProgramID(UUID.randomUUID()); + specialProgram.setGraduationProgramCode("1986-EN"); + specialProgram.setOptProgramCode("FI"); + specialProgram.setOptionalProgramName("French Immersion"); - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("1950"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("1950"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("1950"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("1950"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("1950"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("1950"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); + studentOptionalProgram.setId(UUID.randomUUID()); + studentOptionalProgram.setStudentID(studentID); + studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); + studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); + studentOptionalProgram.setPen(pen); + + StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); + specialProgramReq.setId(studentOptionalProgram.getId()); + specialProgramReq.setStudentID(studentID); + specialProgramReq.setMainProgramCode(gradStudent.getProgram()); + specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); + specialProgramReq.setPen(pen); + + CareerProgram careerProgram = new CareerProgram(); + careerProgram.setCode("XC"); + careerProgram.setDescription("XC Test"); + careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); + careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); + + StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); + studentCareerProgram.setId(UUID.randomUUID()); + studentCareerProgram.setStudentID(studentID); + studentCareerProgram.setCareerProgramCode("XC"); + + when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); + when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); + when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("1950") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .englishCert("E") - .frenchCert("F") - .studentStatus("A") - .studentGrade("AN") - .schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1950") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(new ArrayList<>()) - .build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); + when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); + ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") + .studentStatus("M").schoolOfRecord(mincode).graduationRequirementYear("1986") + .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1950"); + assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); + assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); } @Test - public void convertGraduatedStudent_forSCCP_whenSlpDate_isWrongFormat_thenReturnFailure() throws Exception { + public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + School school = new School(); + school.setMinCode(mincode); + school.setSchoolName("Test School"); + Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); penStudent.setPen(pen); @@ -3195,182 +436,74 @@ public void convertGraduatedStudent_forSCCP_whenSlpDate_isWrongFormat_thenReturn GraduationStudentRecord gradStudent = new GraduationStudentRecord(); gradStudent.setStudentID(studentID); gradStudent.setPen(pen); - gradStudent.setProgram("SCCP"); - gradStudent.setStudentGrade("11"); + gradStudent.setProgram("1996-EN"); + gradStudent.setStudentGrade("12"); gradStudent.setStudentStatus("CUR"); - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("11"); - tranStudentDemog.setGradReqtYear("SCCP"); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); + OptionalProgram specialProgram = new OptionalProgram(); + specialProgram.setOptionalProgramID(UUID.randomUUID()); + specialProgram.setGraduationProgramCode("1996-EN"); + specialProgram.setOptProgramCode("FI"); + specialProgram.setOptionalProgramName("French Immersion"); - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("SCCP"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("SCCP"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("SCCP"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("SCCP"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("SCCP"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("SCCP"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); + StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); + studentOptionalProgram.setId(UUID.randomUUID()); + studentOptionalProgram.setStudentID(studentID); + studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); + studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); + studentOptionalProgram.setPen(pen); - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .slpDate("202206") - .sccDate("20220601") - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .englishCert("E") - .frenchCert("F") - .studentStatus("A") - .studentGrade("11") - .schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("SCCP") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(new ArrayList<>()) - .build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); + StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); + specialProgramReq.setId(studentOptionalProgram.getId()); + specialProgramReq.setStudentID(studentID); + specialProgramReq.setMainProgramCode(gradStudent.getProgram()); + specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); + specialProgramReq.setPen(pen); + + CareerProgram careerProgram = new CareerProgram(); + careerProgram.setCode("XC"); + careerProgram.setDescription("XC Test"); + careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); + careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); + + StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); + studentCareerProgram.setId(UUID.randomUUID()); + studentCareerProgram.setStudentID(studentID); + studentCareerProgram.setCareerProgramCode("XC"); + + when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.courseProcess.isFrenchImmersionCourse(pen, "11", "123")).thenReturn(true); + when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); + when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); + when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); + when(this.restUtils.getOptionalProgram("1996-EN", "FI", "123")).thenReturn(specialProgram); + ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1996-EN") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1996") + .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("SCCP"); - assertThat(summary.getErrors()).isNotEmpty(); - assertThat(summary.getErrors().get(0).getReason()).startsWith("Bad data : slp_date format"); + assertThat(result.getGraduationRequirementYear()).isEqualTo("1996"); + assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); + } @Test - public void convertGraduatedStudent_forSCCP_thenReturnSuccess() throws Exception { + public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + School school = new School(); + school.setMinCode(mincode); + school.setSchoolName("Test School"); + Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); penStudent.setPen(pen); @@ -3378,353 +511,137 @@ public void convertGraduatedStudent_forSCCP_thenReturnSuccess() throws Exception GraduationStudentRecord gradStudent = new GraduationStudentRecord(); gradStudent.setStudentID(studentID); gradStudent.setPen(pen); - gradStudent.setProgram("SCCP"); - gradStudent.setStudentGrade("11"); + gradStudent.setProgram("1986-EN"); + gradStudent.setStudentGrade("12"); gradStudent.setStudentStatus("CUR"); - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("11"); - tranStudentDemog.setGradReqtYear("SCCP"); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); + OptionalProgram specialProgram = new OptionalProgram(); + specialProgram.setOptionalProgramID(UUID.randomUUID()); + specialProgram.setGraduationProgramCode("1986-EN"); + specialProgram.setOptProgramCode("FI"); + specialProgram.setOptionalProgramName("French Immersion"); - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("SCCP"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("SCCP"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("SCCP"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("SCCP"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("SCCP"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("SCCP"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); - when(this.courseProcess.isFrenchImmersionCourse(pen, "10", "123")).thenReturn(true); - when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getGradProgramRules("2018-EN", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); + StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); + studentOptionalProgram.setId(UUID.randomUUID()); + studentOptionalProgram.setStudentID(studentID); + studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); + studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); + studentOptionalProgram.setPen(pen); - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("SCCP") - .programCompletionDate(new Date(System.currentTimeMillis() - 100000L)) - .slpDate("20220601") - .sccDate("20220601") - .studentLoadType(StudentLoadType.GRAD_ONE) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .englishCert("E") - .frenchCert("F") - .studentStatus("A") - .studentGrade("11") - .schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("SCCP") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(new ArrayList<>()) - .build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); + StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); + specialProgramReq.setId(studentOptionalProgram.getId()); + specialProgramReq.setStudentID(studentID); + specialProgramReq.setMainProgramCode(gradStudent.getProgram()); + specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); + specialProgramReq.setPen(pen); + + CareerProgram careerProgram = new CareerProgram(); + careerProgram.setCode("XC"); + careerProgram.setDescription("XC Test"); + careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); + careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); + + StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); + studentCareerProgram.setId(UUID.randomUUID()); + studentCareerProgram.setStudentID(studentID); + studentCareerProgram.setCareerProgramCode("XC"); + + when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); + when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); + when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); + when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); + when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); + when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); + ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") + .archiveFlag("A").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1986") + .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("SCCP"); - assertThat(summary.getErrors()).isEmpty(); + assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); + assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); + } @Test - public void convertStudentFor2Programs_withAdult1950AndSCCP_thenReturnSuccess() throws Exception { + public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_thenReturnSuccess() throws Exception { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; String mincode = "222333"; + School school = new School(); + school.setMinCode(mincode); + school.setSchoolName("Test School"); + Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); penStudent.setPen(pen); - penStudent.setDob("2000-06-30"); GraduationStudentRecord gradStudent = new GraduationStudentRecord(); gradStudent.setStudentID(studentID); gradStudent.setPen(pen); - gradStudent.setProgram("1950"); - gradStudent.setStudentGrade("AD"); - gradStudent.setStudentStatus("CUR"); + gradStudent.setProgram("1986-EN"); + gradStudent.setStudentGrade("12"); + gradStudent.setStudentStatus("ARC"); - // TSW - TranscriptStudentDemog tranStudentDemog = new TranscriptStudentDemog(); - tranStudentDemog.setStudNo(pen); - tranStudentDemog.setMincode(mincode); - tranStudentDemog.setStudentGrade("AD"); - tranStudentDemog.setGradReqtYear("1950"); - tranStudentDemog.setGradMessage(StudentBaseService.TSW_PF_GRAD_MSG); - tranStudentDemog.setUpdateDate(20220601L); - - // TSW - TranscriptStudentCourse tswCourse1 = new TranscriptStudentCourse(); - tswCourse1.setStudNo(pen); - tswCourse1.setReportType("1"); - tswCourse1.setCourseCode("Generic"); - tswCourse1.setCourseName("Generic Course Name"); - tswCourse1.setCourseLevel("12"); - tswCourse1.setFinalPercentage("91.00"); - tswCourse1.setFinalLG("A"); - tswCourse1.setCourseSession("202206"); - tswCourse1.setNumberOfCredits("4"); - tswCourse1.setUsedForGrad("4"); - tswCourse1.setFoundationReq("10"); - tswCourse1.setUpdateDate(20220601L); - - TranscriptStudentCourse tswCourse2 = new TranscriptStudentCourse(); - tswCourse2.setStudNo(pen); - tswCourse2.setReportType("2"); - tswCourse2.setCourseCode("TestCourse"); - tswCourse2.setCourseName("Test Course Name"); - tswCourse2.setCourseLevel("12"); - tswCourse2.setFinalPercentage("92.00"); - tswCourse2.setFinalLG("A"); - tswCourse2.setCourseSession("202206"); - tswCourse2.setNumberOfCredits("4"); - tswCourse2.setUsedForGrad("4"); - tswCourse2.setFoundationReq("11"); - tswCourse2.setUpdateDate(20220601L); - - TranscriptStudentCourse tswAssessment = new TranscriptStudentCourse(); - tswAssessment.setStudNo(pen); - tswAssessment.setReportType("3"); - tswAssessment.setCourseCode("TestAssmt"); - tswAssessment.setCourseName("Test Assessment Name"); - tswAssessment.setCourseLevel("12"); - tswAssessment.setFinalPercentage("XMT"); - tswAssessment.setCourseSession("202206"); - tswAssessment.setFoundationReq("15"); - tswAssessment.setUpdateDate(new Date(System.currentTimeMillis() - 100000L).getTime()); + OptionalProgram specialProgram = new OptionalProgram(); + specialProgram.setOptionalProgramID(UUID.randomUUID()); + specialProgram.setGraduationProgramCode("1986-EN"); + specialProgram.setOptProgramCode("FI"); + specialProgram.setOptionalProgramName("French Immersion"); - School school = new School(); - school.setMinCode(mincode); - school.setSchoolName("Test School"); - school.setTranscriptEligibility("Y"); - school.setCertificateEligibility("Y"); - - // Rule 10 - ProgramRequirement pr10 = new ProgramRequirement(); - pr10.setProgramRequirementID(UUID.randomUUID()); - pr10.setGraduationProgramCode("1950"); - ProgramRequirementCode rule10 = new ProgramRequirementCode(); - rule10.setTraxReqNumber("10"); - rule10.setProReqCode("110"); - rule10.setLabel("Rule 10 Test Label"); - rule10.setDescription("Rule 10 Test Description"); - - pr10.setProgramRequirementCode(rule10); - - GradRuleDetails gradRule10Details = new GradRuleDetails(); - gradRule10Details.setRuleCode("110"); - gradRule10Details.setTraxReqNumber("10"); - gradRule10Details.setProgramCode("1950"); - gradRule10Details.setRequirementName("Rule 10 Test Label"); - - // Rule 11 - ProgramRequirement pr11 = new ProgramRequirement(); - pr11.setProgramRequirementID(UUID.randomUUID()); - pr11.setGraduationProgramCode("1950"); - ProgramRequirementCode rule11 = new ProgramRequirementCode(); - rule11.setTraxReqNumber("11"); - rule11.setProReqCode("111"); - rule11.setLabel("Rule 11 Test Label"); - rule11.setDescription("Rule 11 Test Description"); - - pr11.setProgramRequirementCode(rule11); - - GradRuleDetails gradRule11Details = new GradRuleDetails(); - gradRule11Details.setRuleCode("111"); - gradRule11Details.setTraxReqNumber("11"); - gradRule11Details.setProgramCode("1950"); - gradRule11Details.setRequirementName("Rule 11 Test Label"); - - // Rule 15 - ProgramRequirement pr15 = new ProgramRequirement(); - pr15.setProgramRequirementID(UUID.randomUUID()); - pr15.setGraduationProgramCode("1950"); - ProgramRequirementCode rule15 = new ProgramRequirementCode(); - rule15.setTraxReqNumber("15"); - rule15.setProReqCode("115"); - rule15.setLabel("Rule 15 Test Label"); - rule15.setDescription("Rule 15 Test Description"); - - pr15.setProgramRequirementCode(rule15); - - GradRuleDetails gradRule15Details = new GradRuleDetails(); - gradRule15Details.setRuleCode("115"); - gradRule15Details.setTraxReqNumber("15"); - gradRule15Details.setProgramCode("1950"); - gradRule15Details.setRequirementName("Rule 15 Test Label"); - - // SpecialCase - SpecialCase sc = new SpecialCase(); - sc.setSpCase("E"); - sc.setLabel("XMT"); - sc.setDescription("Exempt"); - sc.setPassFlag("Y"); - - ResponseObj responseObj = new ResponseObj(); - responseObj.setAccess_token("123"); - responseObj.setRefresh_token("123"); - - when(this.restUtils.getTokenResponseObject()).thenReturn(responseObj); - when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(gradStudent); - when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(GraduationStudentRecord.class), eq(false), eq("123"))).thenReturn(gradStudent); + StudentOptionalProgram studentOptionalProgram = new StudentOptionalProgram(); + studentOptionalProgram.setId(UUID.randomUUID()); + studentOptionalProgram.setStudentID(studentID); + studentOptionalProgram.setOptionalProgramID(specialProgram.getOptionalProgramID()); + studentOptionalProgram.setOptionalProgramName(specialProgram.getOptionalProgramName()); + studentOptionalProgram.setPen(pen); + + StudentOptionalProgramRequestDTO specialProgramReq = new StudentOptionalProgramRequestDTO(); + specialProgramReq.setId(studentOptionalProgram.getId()); + specialProgramReq.setStudentID(studentID); + specialProgramReq.setMainProgramCode(gradStudent.getProgram()); + specialProgramReq.setOptionalProgramCode(specialProgram.getOptProgramCode()); + specialProgramReq.setPen(pen); + + CareerProgram careerProgram = new CareerProgram(); + careerProgram.setCode("XC"); + careerProgram.setDescription("XC Test"); + careerProgram.setStartDate(new Date(System.currentTimeMillis() - 100000L).toString()); + careerProgram.setEndDate(new Date(System.currentTimeMillis() + 100000L).toString()); + + StudentCareerProgram studentCareerProgram = new StudentCareerProgram(); + studentCareerProgram.setId(UUID.randomUUID()); + studentCareerProgram.setStudentID(studentID); + studentCareerProgram.setCareerProgramCode("XC"); + + when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(null); + when(this.restUtils.saveStudentGradStatus(eq(studentID.toString()), any(), eq(false), eq("123"))).thenReturn(gradStudent); + when(this.courseProcess.isFrenchImmersionCourseForEN(pen, "11", "123")).thenReturn(true); + when(this.restUtils.saveStudentOptionalProgram(specialProgramReq, "123")).thenReturn(studentOptionalProgram); + when(this.restUtils.saveStudentCareerProgram(studentCareerProgram, "123")).thenReturn(studentCareerProgram); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(Arrays.asList(penStudent)); - when(this.restUtils.getGradProgramRules("1950", "123")).thenReturn(Arrays.asList(pr10, pr11, pr15)); - when(this.restUtils.getAllSpecialCases("123")).thenReturn(Arrays.asList(sc)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule10Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule10Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule11Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule11Details)); - when(this.restUtils.getGradProgramRulesByTraxReqNumber(gradRule15Details.getTraxReqNumber(), "123")).thenReturn(Arrays.asList(gradRule15Details)); - - ConvGradStudent student = ConvGradStudent.builder().pen(pen).program("1950") - .programCompletionDate(null) - .studentLoadType(StudentLoadType.GRAD_TWO) - .gpa("3.5") - .honoursStanding("Y") - .archiveFlag("A") - .slpDate(null) - .sccDate("20230308") - .englishCert("E") - .frenchCert("F") - .studentStatus("A") - .studentGrade("AD") - .schoolOfRecord(mincode).schoolAtGrad(mincode) - .graduationRequirementYear("1950") - .transcriptSchool(school) - .certificateSchool(school) - .transcriptSchoolCategoryCode("02") - .certificateSchoolCategoryCode("02") - .programCodes(new ArrayList<>()) - .build(); - student.setTranscriptStudentDemog(tranStudentDemog); - student.setTranscriptStudentCourses(Arrays.asList(tswCourse1, tswCourse2, tswAssessment)); + when(this.restUtils.getOptionalProgram("1986-EN", "FI", "123")).thenReturn(specialProgram); + when(this.restUtils.addNewPen(penStudent, "123")).thenReturn(penStudent); + ConvGradStudent student = ConvGradStudent.builder().pen("111222333").program("1986-EN") + .archiveFlag("I").studentStatus("A").schoolOfRecord(mincode).graduationRequirementYear("1986") + .programCodes(Arrays.asList("XC")).build(); ConversionStudentSummaryDTO summary = new ConversionStudentSummaryDTO(); summary.setAccessToken("123"); var result = studentProcess.convertStudent(student, summary, false, false); assertThat(result).isNotNull(); assertThat(result.getPen()).isEqualTo(pen); - assertThat(result.getGraduationRequirementYear()).isEqualTo("1950"); + assertThat(result.getGraduationRequirementYear()).isEqualTo("1986"); + assertThat(result.getProgram()).isEqualTo(specialProgram.getGraduationProgramCode()); } @@ -4282,15 +1199,4 @@ public void testTriggerGraduationBatchRun_withCurrentStatus_returnsNoBatchRun() assertThat(isExceptionThrown).isFalse(); } - @Test - public void testClearMaps() { - boolean isExceptionThrown = false; - try { - studentProcess.clearMaps(); - } catch (Exception e) { - isExceptionThrown = true; - } - assertThat(isExceptionThrown).isFalse(); - } - } diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java index 9504a35b..dbd49fbe 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/util/RestUtilsTest.java @@ -4,14 +4,8 @@ import ca.bc.gov.educ.api.dataconversion.messaging.jetstream.Subscriber; import ca.bc.gov.educ.api.dataconversion.model.StudentAssessment; import ca.bc.gov.educ.api.dataconversion.model.*; -import ca.bc.gov.educ.api.dataconversion.model.tsw.*; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportData; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportOptions; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.ReportRequest; -import ca.bc.gov.educ.api.dataconversion.model.tsw.report.Transcript; import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; import lombok.val; -import org.apache.commons.lang3.RandomUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -352,227 +346,26 @@ public void testCheckFrenchLanguageCourse_returnsTrue_with_APICallSuccess() { } @Test - public void testGetGradProgramRulesByTraxReqNumber_givenValues_returnsGradRuleDetails_withAPICallSuccess() { - final String traxReqNumber = "5"; - - final GradRuleDetails ruleDetails = new GradRuleDetails(); - ruleDetails.setRuleCode("100"); - ruleDetails.setTraxReqNumber(traxReqNumber); - ruleDetails.setProgramCode("Test Program"); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(eq(this.constants.getGradProgramRulesByTraxReqNumberUrl()), any(Function.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(ruleDetails))); - - val result = this.restUtils.getGradProgramRulesByTraxReqNumber(traxReqNumber, "abc"); - assertThat(result).isNotNull(); - assertThat(result.size() > 0).isTrue(); - } - - @Test - public void testGetGradProgramCode_givenValues_returnsGraduationProgramCode_withAPICallSuccess() { - final GraduationProgramCode program = new GraduationProgramCode(); - program.setProgramCode("Test"); - program.setDescription("Test Program"); - program.setProgramName("Test Name"); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(eq(this.constants.getGradProgramUrl()), any(Function.class))).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(program)); - - val result = this.restUtils.getGradProgramCode(program.getProgramCode(), "abc"); - assertThat(result).isNotNull(); - assertThat(result.getProgramName()).isEqualTo(program.getProgramName()); - } - - @Test - public void testGetGradProgram_givenValues_returnsGradProgram_withAPICallSuccess() { - final GradProgram program = new GradProgram(); - program.setProgramCode("Test"); - program.setProgramName("Test Name"); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(String.format(constants.getProgramNameEndpoint(), program.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(GradProgram.class)).thenReturn(Mono.just(program)); - - val result = this.restUtils.getGradProgram(program.getProgramCode(), "abc"); - assertThat(result).isNotNull(); - assertThat(result.getProgramName()).isEqualTo(program.getProgramName()); - } - - @Test - public void testGetProgramRules_givenValues_returnProgramRequirements_withAPICallSuccess() { - final ProgramRequirement programRequirement = new ProgramRequirement(); - programRequirement.setGraduationProgramCode("2018-EN"); - programRequirement.setProgramRequirementID(UUID.randomUUID()); - - final ProgramRequirementCode programRequirementCode = new ProgramRequirementCode(); - programRequirementCode.setProReqCode("101"); - programRequirementCode.setLabel("101 Label"); - programRequirementCode.setDescription("101 Test Description"); - - final RequirementTypeCode requirementTypeCode = new RequirementTypeCode(); - requirementTypeCode.setReqTypeCode("M"); - requirementTypeCode.setLabel("Match"); - requirementTypeCode.setDescription("Algorithm matches a specific course to a specific requirement"); - - programRequirementCode.setRequirementTypeCode(requirementTypeCode); - programRequirement.setProgramRequirementCode(programRequirementCode); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); - when(this.requestHeadersUriMock.uri(eq(this.constants.getGradProgramRulesUrl()), any(Function.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); - - final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { - }; - when(this.responseMock.bodyToMono(responseType)).thenReturn(Mono.just(Arrays.asList(programRequirement))); - - val result = this.restUtils.getGradProgramRules(programRequirement.getGraduationProgramCode(), "abc"); - assertThat(result).isNotNull(); - assertThat(result.size() > 0).isTrue(); - } - - @Test - public void testGetSpecialCase_givenValue_returnSpecialCase_withAPICallSuccess() { - GradProgram gP = new GradProgram(); - 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.requestHeadersUriMock.uri(eq(this.constants.getSpecialCase()), any(Function.class))).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)); - - val result = restUtils.getSpecialCase("A", "abc"); - assertThat(result).isNotNull(); - } - - @Test - public void testGetSchoolCategoryCode_givenValue_returnString_withAPICallSuccess() { - CommonSchool commSch = new CommonSchool(); - commSch.setSchlNo("1231123"); - commSch.setSchoolCategoryCode("02"); - - when(this.webClient.get()).thenReturn(this.requestHeadersUriMock); -// when(this.requestHeadersUriMock.uri(String.format(constants.getSchoolCategoryCode(),"06011033"))).thenReturn(this.requestHeadersMock); - when(this.requestHeadersUriMock.uri(eq(this.constants.getSchoolCategoryCode()), any(Function.class))).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)); - - val result = restUtils.getSchoolCategoryCode("06011033", "abc"); - assertThat(result).isNotNull(); - } - - @Test - public void testGetTranscriptReport_givenValues_returnByteArray_withAPICallSuccess() { - byte[] bytesSAR = RandomUtils.nextBytes(20); - - ReportRequest reportParams = new ReportRequest(); - ReportOptions options = new ReportOptions(); - options.setReportFile("transcript"); - options.setReportName("Transcript Report.pdf"); - - reportParams.setOptions(options); - - ReportData reportData = new ReportData(); - reportData.setTranscript(new Transcript()); - - reportParams.setData(reportData); - - 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)); - - val result = restUtils.getTranscriptReport(reportParams, "abc"); - assertThat(result).isNotNull(); - } - - @Test - public void testSaveGradStudentTranscript() { - String studentID = new UUID(1, 1).toString(); - String accessToken = "accessToken"; - boolean isGraduated= true; - GradStudentTranscripts rep = new GradStudentTranscripts(); - rep.setStudentID(UUID.fromString(studentID)); -// rep.setPen(pen); - byte[] bytesSAR = RandomUtils.nextBytes(20); - - 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(GradStudentTranscripts.class)).thenReturn(Mono.just(rep)); - - restUtils.saveGradStudentTranscript(rep, isGraduated, accessToken); - verify(this.webClient, times(1)).post(); - } - - @Test - public void testGetProgramCertificateTranscriptList() { - 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)); - - ProgramCertificateReq req = new ProgramCertificateReq(); - req.setProgramCode("Test"); - req.setOptionalProgram("OptionalTest"); - req.setSchoolCategoryCode(" "); - - val result = restUtils.getProgramCertificateTranscriptList(req, "123"); - assertThat(result).isNotNull(); + public void testTokenFallbackMethod_givenException_shouldReturnNull(){ + val result = this.restUtils.rtGetTokenFallback(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); + assertThat(result).isNull(); } @Test - public void testTokenFallBackMethod_givenException_shouldReturnNull(){ - val result = this.restUtils.rtGetTokenFallBack(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); + public void testGetStudentFallbackMethod_givenException_shouldReturnNull(){ + val result = this.restUtils.rtGetStudentGradStatusFallback(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); assertThat(result).isNull(); } @Test - public void testGetStudentFallBackMethod_givenException_shouldReturnNull(){ - val result = this.restUtils.rtGetStudentGradStatusFallback(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); + public void testSaveStudentFallbackMethod_givenException_shouldReturnNull(){ + val result = this.restUtils.rtSaveStudentGradStatusFallback(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); assertThat(result).isNull(); } @Test - public void testSaveStudentFallBackMethod_givenException_shouldReturnNull(){ - val result = this.restUtils.rtSaveStudentGradStatusFallback(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); + public void testUpdateStudentFallbackMethod_givenException_shouldReturnNull(){ + val result = this.restUtils.rtUpdateStudentGradStatusFallback(new HttpServerErrorException(HttpStatus.I_AM_A_TEAPOT)); assertThat(result).isNull(); } } diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 1d5869fa..fee5931c 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -125,16 +125,6 @@ endpoint: url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/optionalprograms optional-program-by-id: url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/optionalprograms/id - career-program: - url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/careerprogram - programs: - url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/programs - program-rules: - url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/programrules - program-rules-by-trax: - url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/programrules/by-trax - program_name_by_program_code: - url: https://educ-grad-program-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/program/programs/%s grad-student-api: add-new-pen: url: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student @@ -153,8 +143,6 @@ endpoint: student-assessments: by-pen: url: https://educ-grad-assessment-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/assessment/pen/%s - by-pen-and-assessment-code: - url: https://educ-grad-assessment-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/assessment/%s/pen/%s grad-trax-api: student: get-student-no-list-by-page: @@ -172,24 +160,6 @@ endpoint: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/common/course-restrictions get-course-requirements: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/common/course-requirements - grad-graduation-report-api: - get-transcript: https://educ-grad-graduation-report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/programtranscripts - update-grad-student-transcript: - url: https://educ-grad-graduation-report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studenttranscript?isGraduated=%s - get-cert-list: https://educ-grad-graduation-report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/programcertificates - update-grad-student-certificate: - url: https://educ-grad-graduation-report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentcertificate - update-grad-student-report: - url: https://educ-grad-graduation-report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/schoolreport - educ-school-api: - url: https://school-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/schools - grad-student-graduation-api: - get-special-cases: - url: https://educ-grad-student-graduation-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/studentgraduation/lgSc/specialcase - report-api: - transcript_report: https://report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/reports/transcriptreport - certificate_report: https://report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/reports/certificate - achievement_report: https://report-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/reports/achievementreport #Incremental Grad Update grad: diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index b1656833..ca30ca8c 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -54,17 +54,13 @@ oc create -n "$BUSINESS_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map --from-literal=APP_LOG_LEVEL="$APP_LOG_LEVEL" \ --from-literal=BASELINE_ON_MIGRATE="false" \ --from-literal=CONNECTION_TIMEOUT="90000" \ - --from-literal=EDUC_SCHOOL_API="http://school-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=ENABLE_FLYWAY="true" \ --from-literal=ENABLE_GRAD_UPDATE="true" \ --from-literal=ENABLE_SPLUNK_LOG_HELPER="false" \ --from-literal=GRAD_ASSESSMENT_API="http://educ-grad-assessment-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=GRAD_COURSE_API="http://educ-grad-course-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ - --from-literal=GRAD_GRADUATION_REPORT_API="http://educ-grad-graduation-report-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=GRAD_PROGRAM_API="http://educ-grad-program-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ - --from-literal=GRAD_REPORT_API="http://educ-grad-report-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=GRAD_STUDENT_API="http://educ-grad-student-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ - --from-literal=GRAD_STUDENT_GRADUATION_API="http://educ-grad-student-graduation-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=GRAD_TRAX_API="http://educ-grad-trax-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ --from-literal=IDLE_TIMEOUT="400000" \ --from-literal=KEYCLOAK_TOKEN_URL="https://soam-$envValue.apps.silver.devops.gov.bc.ca/" \