From 1b38a7a589cb4412bc69bc76785123eaefea373d Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 13 Jan 2025 15:40:21 -0800 Subject: [PATCH 1/5] GRAD2-3164: task is complete. GRAD2-3164: task is complete. --- .../dataconversion/model/StudentGradDTO.java | 4 + .../model/institute/School.java | 34 ++++ .../model/tsw/GraduationData.java | 2 +- .../api/dataconversion/model/tsw/School.java | 156 ------------------ .../dataconversion/model/tsw/SchoolClob.java | 77 +++++++++ .../process/StudentProcess.java | 5 +- .../student/NewStudentEventService.java | 1 + .../StudentAssessmentUpdateEventService.java | 9 +- .../service/student/StudentBaseService.java | 28 +++- .../StudentCourseUpdateEventService.java | 8 +- ...StudentDemographicsUpdateEventService.java | 7 +- .../StudentFrenchImmersionEventService.java | 7 +- .../StudentGraduationUpdateBaseService.java | 6 + .../StudentGraduationUpdateEventService.java | 10 +- .../student/StudentXProgramEventService.java | 7 +- .../EducGradDataConversionApiConstants.java | 3 + .../api/dataconversion/util/RestUtils.java | 20 +++ api/src/main/resources/application.yaml | 2 + .../process/StudentProcessTest.java | 42 ++--- api/src/test/resources/application.yaml | 2 + 20 files changed, 207 insertions(+), 223 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/institute/School.java delete mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/School.java create mode 100644 api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java index c3fb2d05..e1e6b64c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/StudentGradDTO.java @@ -40,6 +40,10 @@ public String getUpToDateSchoolOfRecord() { return StringUtils.isNotBlank(newSchoolOfRecord)? newSchoolOfRecord : this.getSchoolOfRecord(); } + public UUID getUpToDateSchoolOfRecordId() { + return newSchoolOfRecordId != null? newSchoolOfRecordId : this.getSchoolOfRecordId(); + } + @Override public boolean isArchived() { if (StringUtils.isNotBlank(newStudentStatus) && "ARC".equalsIgnoreCase(newStudentStatus)) { // Student Status from TRAX diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/institute/School.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/institute/School.java new file mode 100644 index 00000000..7ab19fb8 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/institute/School.java @@ -0,0 +1,34 @@ +package ca.bc.gov.educ.api.dataconversion.model.institute; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.stereotype.Component; + +@Data +@EqualsAndHashCode +@Component("instituteSchool") +@JsonIgnoreProperties(ignoreUnknown = true) +public class School { + + private String schoolId; + private String districtId; + private String mincode; + private String independentAuthorityId; + private String schoolNumber; + private String faxNumber; + private String phoneNumber; + private String email; + private String website; + private String displayName; + private String displayNameNoSpecialChars; + private String schoolReportingRequirementCode; + private String schoolOrganizationCode; + private String schoolCategoryCode; + private String facilityTypeCode; + private String openedDate; + private String closedDate; + private boolean canIssueTranscripts; + private boolean canIssueCertificates; + +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/GraduationData.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/GraduationData.java index 8041e3b4..6e322531 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/GraduationData.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/GraduationData.java @@ -17,7 +17,7 @@ public class GraduationData { private GradSearchStudent gradStudent; private GradAlgorithmGraduationStudentRecord gradStatus; private List optionalGradStatus; - private School school; + private SchoolClob school; private StudentCourses studentCourses; private StudentAssessments studentAssessments; // nullable private StudentExams studentExams; // nullable diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/School.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/School.java deleted file mode 100644 index 69aa1a4a..00000000 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/School.java +++ /dev/null @@ -1,156 +0,0 @@ -package ca.bc.gov.educ.api.dataconversion.model.tsw; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.Data; -import org.springframework.stereotype.Component; - -import java.util.Objects; - -@Data -@Component -@JsonIgnoreProperties(ignoreUnknown = true) -public class School implements Comparable { - - private String minCode; - private String schoolName; - private String districtName; - private String transcriptEligibility; - private String certificateEligibility; - private String independentDesignation; - private String mailerType; - private String address1; - private String address2; - private String city; - private String provCode; - private String provinceName; - private String countryCode; - private String countryName; - private String postal; - private String independentAffiliation; - private String openFlag; - private String signatureDistrict; - private String newMinCode; - private String schoolOrg; - private String appendTrans; - private String ministryContact; - private String principalName; - private String schoolPhone; - private String schoolFax; - private String schoolEmail; - - private String schoolCategory; - - public String getSchoolName() { - return schoolName != null ? schoolName.trim(): ""; - } - - public String getDistrictName() { - return districtName != null ? districtName.trim(): ""; - } - - public String getAddress1() { - return address1 != null ? address1.trim(): ""; - } - - public String getAddress2() { - return address2 != null ? address2.trim(): ""; - } - - public String getCity() { - return city != null ? city.trim(): ""; - } - - public String getProvinceName() { - return provinceName != null ? provinceName.trim(): ""; - } - - public String getCountryName() { - return countryName != null ? countryName.trim(): ""; - } - - public String getPostal() { - return postal != null ? postal.trim(): ""; - } - - public String getIndependentDesignation() { - return independentDesignation != null ? independentDesignation.trim(): ""; - } - - public String getIndependentAffiliation() { - return independentAffiliation != null ? independentAffiliation.trim(): ""; - } - - public String getOpenFlag() { - return openFlag != null ? openFlag.trim(): ""; - } - - public String getReportingFlag() { - return getOpenFlag(); - } - - public String getSignatureDistrict() { - return signatureDistrict != null ? signatureDistrict.trim(): ""; - } - - public String getSchoolEmail() { - return schoolEmail != null ? schoolEmail.trim(): ""; - } - - public String getPrincipalName() { - return principalName != null ? principalName.trim(): ""; - } - - public String getAppendTrans() { - return appendTrans != null ? appendTrans.trim(): ""; - } - - public String getMinistryContact() { - return ministryContact != null ? ministryContact.trim(): ""; - } - - public String getMinCode() { - return minCode != null ? minCode.trim(): ""; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - School school = (School) o; - return getMinCode().equals(school.getMinCode()) - && getSchoolName().equals(school.getSchoolName()); - } - - @Override - public int hashCode() { - return Objects.hash(getMinCode(), getSchoolName()); - } - - @Override - public String toString() { - return "School [minCode=" + minCode + ", schoolName=" + schoolName + ", districtName=" + districtName - + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" - + certificateEligibility + ", independentDesignation=" + independentDesignation + ", mailerType=" - + mailerType + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" - + provCode + ", provinceName=" + provinceName + ", countryCode=" + countryCode + ", countryName=" - + countryName + ", postal=" + postal + ", independentAffiliation=" + independentAffiliation - + ", openFlag=" + openFlag + ", signatureDistrict=" + signatureDistrict + ", newMinCode=" + newMinCode - + ", schoolOrg=" + schoolOrg + ", appendTrans=" + appendTrans + ", ministryContact=" + ministryContact - + ", principalName=" + principalName + ", schoolPhone=" + schoolPhone + ", schoolFax=" + schoolFax - + ", schoolEmail=" + schoolEmail + "]"; - } - - @Override - public int compareTo(School o) { - int result = 0; - { - if (result == 0) { - result = getMinCode().compareToIgnoreCase(o.getMinCode()); - } - if (result == 0) { - result = getSchoolName().compareToIgnoreCase(o.getSchoolName()); - } - } - return result; - } -} diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java new file mode 100644 index 00000000..0764a4e0 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java @@ -0,0 +1,77 @@ +package ca.bc.gov.educ.api.dataconversion.model.tsw; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; +import org.springframework.stereotype.Component; + +@Data +@Component +@JsonIgnoreProperties(ignoreUnknown = true) +public class SchoolClob implements Comparable { + + private String minCode; + private String schoolId; + private String schoolName; + private String districtName; + private String transcriptEligibility; + private String certificateEligibility; + private String address1; + private String address2; + private String city; + private String provCode; + private String countryCode; + private String postal; + private String openFlag; + private String schoolCategoryCode; + private String schoolCategoryLegacyCode; + + public String getSchoolName() { + return schoolName != null ? schoolName.trim(): null; + } + + public String getDistrictName() { + return districtName != null ? districtName.trim(): null; + } + + public String getAddress1() { + return address1 != null ? address1.trim(): null; + } + + public String getAddress2() { + return address2 != null ? address2.trim(): null; + } + + public String getCity() { + return city != null ? city.trim(): null; + } + + public String getPostal() { + return postal != null ? postal.trim(): null; + } + + public String getOpenFlag() { + return openFlag != null ? openFlag.trim(): null; + } + + @Override + public String toString() { + return "SchoolClob [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolCategoryLegacyCode=" + schoolCategoryLegacyCode + + ", schoolName=" + schoolName + ", districtName=" + districtName + ", transcriptEligibility=" + transcriptEligibility + ", certificateEligibility=" + certificateEligibility + + ", address1=" + address1 + ", address2=" + address2 + ", city=" + city + ", provCode=" + provCode + ", countryCode=" + countryCode + ", postal=" + postal + ", openFlag=" + openFlag + + "]"; + } + + @Override + public int compareTo(SchoolClob o) { + int result = 0; + { + if (result == 0) { + result = getMinCode().compareToIgnoreCase(o.getMinCode()); + } + if (result == 0) { + result = getSchoolName().compareToIgnoreCase(o.getSchoolName()); + } + } + return result; + } +} 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 171f1b8c..8e2800bd 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 @@ -35,6 +35,7 @@ public class StudentProcess extends StudentBaseService { public StudentProcess(RestUtils restUtils, AssessmentProcess assessmentProcess, CourseProcess courseProcess) { + super(restUtils); this.restUtils = restUtils; this.assessmentProcess = assessmentProcess; this.courseProcess = courseProcess; @@ -282,9 +283,7 @@ private Pair handleProgramCode(String programCode private ConversionResultType processSccpFrenchCertificates(GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { if (StringUtils.equals(student.getProgram(), "SCCP") - && ( StringUtils.isNotBlank(student.getSchoolOfRecord()) - && student.getSchoolOfRecord().startsWith("093") ) - ) { + && isSchoolForProgramFrancophone(student.getSchoolOfRecordId())) { return createStudentOptionalProgram("FR", student, summary); } return ConversionResultType.SUCCESS; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java index 3e0ed085..d676f635 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/NewStudentEventService.java @@ -33,6 +33,7 @@ public NewStudentEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java index 8ddcf744..6d65bfae 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentAssessmentUpdateEventService.java @@ -1,7 +1,6 @@ package ca.bc.gov.educ.api.dataconversion.service.student; import ca.bc.gov.educ.api.dataconversion.entity.Event; -import ca.bc.gov.educ.api.dataconversion.model.ResponseObj; import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO; import ca.bc.gov.educ.api.dataconversion.model.TraxStudentUpdateDTO; import ca.bc.gov.educ.api.dataconversion.process.StudentProcess; @@ -34,6 +33,7 @@ public StudentAssessmentUpdateEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; @@ -45,12 +45,7 @@ public void processEvent(T request, Event event) { TraxStudentUpdateDTO studentAssessmentUpdate = (TraxStudentUpdateDTO) request; if (studentAssessmentUpdate != null && constants.isGradUpdateEnabled()) { // Get Access Token - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } - + String accessToken = restUtils.fetchAccessToken(); // Load grad student StudentGradDTO currentStudent = studentProcess.loadStudentData(studentAssessmentUpdate.getPen(), accessToken); if (currentStudent != null) { 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 87654c56..e3d2e8b4 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 @@ -5,10 +5,13 @@ import ca.bc.gov.educ.api.dataconversion.model.ConversionAlert; import ca.bc.gov.educ.api.dataconversion.model.ConversionStudentSummaryDTO; import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO; +import ca.bc.gov.educ.api.dataconversion.model.institute.School; +import ca.bc.gov.educ.api.dataconversion.util.RestUtils; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import java.util.List; +import java.util.UUID; public abstract class StudentBaseService { @@ -27,6 +30,12 @@ public abstract class StudentBaseService { private static final List OPTIONAL_PROGRAM_CODES_FOR_RECREATION = Arrays.asList("AD", "BC", "BD", "CP"); private static final List OPTIONAL_PROGRAM_CODES_FOR_SCCP_RECREATION = Arrays.asList("FR", "CP"); + private final RestUtils restUtils; + + protected StudentBaseService(RestUtils restUtils) { + this.restUtils = restUtils; + } + protected void handleException(ConvGradStudent convGradStudent, ConversionStudentSummaryDTO summary, String pen, ConversionResultType type, String reason) { ConversionAlert error = new ConversionAlert(); error.setItem(pen); @@ -55,7 +64,7 @@ protected String getGradStudentStatus(String traxStudentStatus, String traxArchi } protected boolean determineProgram(ConvGradStudent student, ConversionStudentSummaryDTO summary) { - String gradProgram = getGradProgram(student.getGraduationRequirementYear(), student.getSchoolOfRecord(), student.getFrenchDogwood()); + String gradProgram = getGradProgram(student.getGraduationRequirementYear(), student.getSchoolOfRecordId(), student.getFrenchDogwood()); if (StringUtils.isNotBlank(gradProgram)) { student.setProgram(gradProgram); updateProgramCountsInSummary(summary, gradProgram, false); @@ -67,32 +76,32 @@ protected boolean determineProgram(ConvGradStudent student, ConversionStudentSum } } - protected String getGradProgram(String graduationRequirementYear, String schoolOfRecord, String frenchDogwood) { + protected String getGradProgram(String graduationRequirementYear, UUID schoolOfRecordId, String frenchDogwood) { String gradProgram = null; switch (graduationRequirementYear) { case "2023" -> { - if (isSchoolForProgramFrancophone(schoolOfRecord)) { + if (isSchoolForProgramFrancophone(schoolOfRecordId)) { gradProgram = "2023-PF"; } else { gradProgram = "2023-EN"; } } case "2018" -> { - if (isSchoolForProgramFrancophone(schoolOfRecord)) { + if (isSchoolForProgramFrancophone(schoolOfRecordId)) { gradProgram = "2018-PF"; } else { gradProgram = "2018-EN"; } } case "2004" -> { - if (schoolOfRecord.startsWith("093")) { + if (isSchoolForProgramFrancophone(schoolOfRecordId)) { gradProgram = "2004-PF"; } else { gradProgram = "2004-EN"; } } case "1996", "1995" -> { - if (schoolOfRecord.startsWith("093")) { + if (isSchoolForProgramFrancophone(schoolOfRecordId)) { gradProgram = "1996-PF"; } else { gradProgram = "1996-EN"; @@ -144,9 +153,10 @@ public boolean isOptionalProgramRecreationRequired(String code, String program) return "SCCP".equalsIgnoreCase(program)? OPTIONAL_PROGRAM_CODES_FOR_SCCP_RECREATION.contains(code) : OPTIONAL_PROGRAM_CODES_FOR_RECREATION.contains(code); } - // GRAD2-2103: applied to 2023 & 2018 programs. - private boolean isSchoolForProgramFrancophone(String schoolOfRecord) { - return schoolOfRecord.startsWith("093") || "09898009".equalsIgnoreCase(schoolOfRecord) || "09898047".equalsIgnoreCase(schoolOfRecord); + protected boolean isSchoolForProgramFrancophone(UUID schoolOfRecordId) { + String accessToken = restUtils.fetchAccessToken(); + School school = restUtils.getSchool(schoolOfRecordId, accessToken); + return school != null && "CSF".equalsIgnoreCase(school.getSchoolReportingRequirementCode()); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java index 4217bfc7..3b3b6bf9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentCourseUpdateEventService.java @@ -1,7 +1,6 @@ package ca.bc.gov.educ.api.dataconversion.service.student; import ca.bc.gov.educ.api.dataconversion.entity.Event; -import ca.bc.gov.educ.api.dataconversion.model.ResponseObj; import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO; import ca.bc.gov.educ.api.dataconversion.model.TraxStudentUpdateDTO; import ca.bc.gov.educ.api.dataconversion.process.StudentProcess; @@ -34,6 +33,7 @@ public StudentCourseUpdateEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; @@ -45,11 +45,7 @@ public void processEvent(T request, Event event) { TraxStudentUpdateDTO studentCourseUpdate = (TraxStudentUpdateDTO) request; if (studentCourseUpdate != null && constants.isGradUpdateEnabled()) { // Get Access Token - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } + String accessToken = restUtils.fetchAccessToken(); // Load grad student StudentGradDTO currentStudent = studentProcess.loadStudentData(studentCourseUpdate.getPen(), accessToken); if (currentStudent != null) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java index 1d66af6e..5be446cb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentDemographicsUpdateEventService.java @@ -33,6 +33,7 @@ public StudentDemographicsUpdateEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; @@ -44,11 +45,7 @@ public void processEvent(T request, Event event) { TraxDemographicsUpdateDTO updateDemog = (TraxDemographicsUpdateDTO) request; if (updateDemog != null && constants.isGradUpdateEnabled()) { // Get Access Token - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } + String accessToken = restUtils.fetchAccessToken(); // Load grad student StudentGradDTO currentStudent = studentProcess.loadStudentData(updateDemog.getPen(), accessToken); if (currentStudent != null) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java index 9716537c..28a0268f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentFrenchImmersionEventService.java @@ -32,6 +32,7 @@ public StudentFrenchImmersionEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; @@ -43,11 +44,7 @@ public void processEvent(T request, Event event) { TraxFrenchImmersionUpdateDTO frenchImmersionUpdate = (TraxFrenchImmersionUpdateDTO) request; if (frenchImmersionUpdate != null && constants.isGradUpdateEnabled()) { // Get Access Token - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } + String accessToken = restUtils.fetchAccessToken(); // Load grad student StudentGradDTO currentStudent = studentProcess.loadStudentData(frenchImmersionUpdate.getPen(), accessToken); if (currentStudent != null) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java index 1b5dc13b..d4ce6dc5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java @@ -2,6 +2,7 @@ import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; +import ca.bc.gov.educ.api.dataconversion.util.RestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; @@ -10,6 +11,10 @@ public abstract class StudentGraduationUpdateBaseService extends StudentBaseService { + protected StudentGraduationUpdateBaseService(RestUtils restUtils) { + super(restUtils); + } + protected abstract boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken); protected void handleProgramChange(String newGradProgram, StudentGradDTO currentStudent, String pen, String accessToken) { @@ -305,4 +310,5 @@ protected void processStudentStatus(StudentGradDTO currentStudent, String value) } } } + } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index 1785b331..8466c489 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -33,6 +33,7 @@ public StudentGraduationUpdateEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; @@ -71,18 +72,18 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); // Processing order is important for the first 3 fields below. - // 1.1 School of Record - if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { + // 1.1 SchoolClob of Record + if (StringUtils.isNotBlank(updateGrad.getSchoolOfRecord()) && !StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { isChanged = processSchoolOfRecord(currentStudent, updateGrad.getSchoolOfRecord()); log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); } - // 1.2 School of Record Guid + // 1.2 SchoolClob of Record Guid if (updateGrad.getSchoolOfRecordId() != null && updateGrad.getSchoolOfRecordId() != currentStudent.getSchoolOfRecordId()) { isChanged = processSchoolOfRecordId(currentStudent, updateGrad.getSchoolOfRecordId()); log.info(" => school of record id : current = {}, request = {}", currentStudent.getSchoolOfRecordId(), currentStudent.getNewSchoolOfRecordId()); } // 2. Grad Program - String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); + String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecordId(), null); if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { isChanged = processGraduationProgram(currentStudent, updateGrad.getPen(), gradProgram, accessToken); if (isChanged && StringUtils.isNotBlank(currentStudent.getNewProgram())) { @@ -135,5 +136,4 @@ public String getEventType() { public boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken) { return studentProcess.hasAnyFrenchImmersionCourse(gradProgramCode, pen, accessToken); } - } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java index b7b8eb63..b56060f3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentXProgramEventService.java @@ -34,6 +34,7 @@ public StudentXProgramEventService(EventRepository eventRepository, StudentProcess studentProcess, RestUtils restUtils, EducGradDataConversionApiConstants constants) { + super(restUtils); this.eventRepository = eventRepository; this.studentProcess = studentProcess; this.restUtils = restUtils; @@ -45,11 +46,7 @@ public void processEvent(T request, Event event) { TraxXProgramDTO xprogram = (TraxXProgramDTO) request; if (xprogram != null && constants.isGradUpdateEnabled()) { // Get Access Token - ResponseObj res = restUtils.getTokenResponseObject(); - String accessToken = null; - if (res != null) { - accessToken = res.getAccess_token(); - } + String accessToken = restUtils.fetchAccessToken(); // Load grad student StudentGradDTO currentStudent = studentProcess.loadStudentData(xprogram.getPen(), accessToken); if (currentStudent != null) { 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 e19c7733..e229c56f 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 @@ -167,6 +167,9 @@ public class EducGradDataConversionApiConstants { @Value("${endpoint.grad-graduation-report-api.delete-student-achievements.url}") private String deleteStudentAchievementsUrl; + @Value("${endpoint.grad-trax-api.student.school-by-school-id.url}") + private String schoolBySchoolIdUrl; + // 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 be1ff4d2..8e56aa45 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 @@ -3,6 +3,8 @@ 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.institute.School; +import ca.bc.gov.educ.api.dataconversion.model.tsw.SchoolClob; import io.github.resilience4j.retry.annotation.Retry; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -44,6 +46,15 @@ public ResponseObj getTokenResponseObject() { return responseObjCache.getResponseObj(); } + public String fetchAccessToken() { + log.info("Fetching the access token from KeyCloak API"); + ResponseObj res = getTokenResponseObject(); + if (res != null) { + return res.getAccess_token(); + } + return null; + } + @Retry(name = "rt-getToken", fallbackMethod = "rtGetTokenFallback") private ResponseObj getTokenResponseObj() { log.info("Fetching the access token from KeyCloak API"); @@ -421,6 +432,15 @@ public void removeAllStudentRelatedData(UUID studentID, String accessToken) { }).retrieve().bodyToMono(Void.class).block(); } + public School getSchool(UUID schoolId, String accessToken) { + if (schoolId == null) return null; + return this.webClient.get().uri(String.format(constants.getSchoolBySchoolIdUrl(), schoolId)) + .headers(h -> { + h.setBearerAuth(accessToken); + h.set(EducGradDataConversionApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID()); + }).retrieve().bodyToMono(School.class).block(); + } + // READ StudentOptionalProgram - GET /student/optionalprogram/studentid/{id} public List getStudentOptionalPrograms(String studentID, String accessToken) { final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 5b2e05e6..ce5372c6 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -233,6 +233,8 @@ endpoint: url: ${GRAD_TRAX_API}api/v1/trax/common/trax-student-no delete-trax-student-no: url: ${GRAD_TRAX_API}api/v1/trax/common/trax-student-no/%s + school-by-school-id: + url: ${GRAD_TRAX_API}api/v2/trax/school/%s course: get-course-restrictions: url: ${GRAD_TRAX_API}api/v1/trax/common/course-restrictions 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 0f188e5c..5f5a44ef 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 @@ -4,7 +4,7 @@ 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.SchoolClob; import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiConstants; import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; @@ -76,9 +76,9 @@ public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_the String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(new ArrayList<>()); @@ -102,9 +102,9 @@ public void convertStudent_forPenStudentValidation_whenPENAPI_isDown_thenReturnF String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); when(this.restUtils.getStudentsByPen(pen, "123")).thenThrow(new RuntimeException("Test")); @@ -131,9 +131,9 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -171,9 +171,9 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -213,9 +213,9 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -284,9 +284,9 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -361,9 +361,9 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -438,9 +438,9 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -515,9 +515,9 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -593,9 +593,9 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP String mincode = "222333"; UUID schoolOfRecordId = UUID.randomUUID(); - School school = new School(); + SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test School"); + school.setSchoolName("Test SchoolClob"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 146b108f..943b06e8 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -159,6 +159,8 @@ endpoint: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/common/trax-student-no delete-trax-student-no: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/common/trax-student-no/%s + school-by-school-id: + url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/trax/school/%s course: get-course-restrictions: url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/common/course-restrictions From 6288dea6741a3e397c3f596a072460c9e53dfad2 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 13 Jan 2025 17:10:42 -0800 Subject: [PATCH 2/5] Fixed the broken junit test is fixed for PF validation. Fixed the broken junit test is fixed for PF validation. --- ...udentGraduationUpdateEventServiceTest.java | 225 ++++++++++++++++++ 1 file changed, 225 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index bb70697f..ae5696e7 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -6,6 +6,7 @@ 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.institute.School; import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; import ca.bc.gov.educ.api.dataconversion.service.student.StudentGraduationUpdateEventService; import ca.bc.gov.educ.api.dataconversion.process.StudentProcess; @@ -111,6 +112,14 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_returnsA course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); ResponseObj res = new ResponseObj(); @@ -184,6 +193,14 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -252,6 +269,14 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Archived course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -321,6 +346,14 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -390,6 +423,14 @@ public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdat course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -459,6 +500,14 @@ public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -528,6 +577,14 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -596,6 +653,14 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -664,6 +729,14 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGrad course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -732,6 +805,14 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenCiti course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -800,6 +881,14 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCiti course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -868,6 +957,14 @@ public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCi course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -936,6 +1033,14 @@ public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCiti course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1002,6 +1107,14 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1068,6 +1181,14 @@ public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_w course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1134,6 +1255,14 @@ public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_w course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1200,6 +1329,14 @@ public void testProcessStudentForGrad2018PFProgram_givenUpdated_STUDENT_whenProg course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1266,6 +1403,14 @@ public void testProcessStudentFor1950AdultProgram_givenUpdated_STUDENT_whenProgr course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.studentProcess.hasAnyFrenchImmersionCourse(eq("2018-EN"), eq(pen), any())).thenReturn(true); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1335,6 +1480,14 @@ public void testProcessStudentFor2018EN_givenUpdated_STUDENT_whenProgramIsChange course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1405,6 +1558,14 @@ public void testProcessStudentFor2018ENProgram_givenUpdated_STUDENT_whenProgramI course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1475,6 +1636,14 @@ public void testProcessStudentFor2018PFProgram_givenUpdated_STUDENT_whenProgramI course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1544,6 +1713,14 @@ public void testProcessStudentForSCCPProgram_givenUpdated_STUDENT_whenProgramIsC course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1637,6 +1814,14 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1706,6 +1891,14 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1773,6 +1966,14 @@ public void testProcessArchivedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1840,6 +2041,14 @@ public void testProcessDeceasedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("CSF"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1909,6 +2118,14 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(newSchoolOfRecordId.toString()); + school.setMincode(newMincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1977,6 +2194,14 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT course1.setPen(pen); currentStudent.getCourses().add(course1); + // School + School school = new School(); + school.setSchoolId(schoolOfRecordId.toString()); + school.setMincode(mincode); + school.setSchoolReportingRequirementCode("PUBLIC"); + + when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); From 0d6f1b829f6a66ff274d0e649bd392748150e5b8 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 14 Jan 2025 09:28:40 -0800 Subject: [PATCH 3/5] More coverage & clean up comments. More coverage & clean up comments. --- .../StudentGraduationUpdateEventService.java | 4 ++-- .../process/StudentProcessTest.java | 20 +++++++++---------- ...udentGraduationUpdateEventServiceTest.java | 18 ++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java index 8466c489..bfffa2bb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateEventService.java @@ -72,12 +72,12 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); // Processing order is important for the first 3 fields below. - // 1.1 SchoolClob of Record + // 1.1 School of Record if (StringUtils.isNotBlank(updateGrad.getSchoolOfRecord()) && !StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { isChanged = processSchoolOfRecord(currentStudent, updateGrad.getSchoolOfRecord()); log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); } - // 1.2 SchoolClob of Record Guid + // 1.2 School of Record Guid if (updateGrad.getSchoolOfRecordId() != null && updateGrad.getSchoolOfRecordId() != currentStudent.getSchoolOfRecordId()) { isChanged = processSchoolOfRecordId(currentStudent, updateGrad.getSchoolOfRecordId()); log.info(" => school of record id : current = {}, request = {}", currentStudent.getSchoolOfRecordId(), currentStudent.getNewSchoolOfRecordId()); 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 5f5a44ef..34d3e9f9 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 @@ -78,7 +78,7 @@ public void convertStudent_forPenStudentValidation_whenGivenPen_doesNotExist_the SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); when(this.restUtils.getStudentsByPen(pen, "123")).thenReturn(new ArrayList<>()); @@ -104,7 +104,7 @@ public void convertStudent_forPenStudentValidation_whenPENAPI_isDown_thenReturnF SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); when(this.restUtils.getStudentsByPen(pen, "123")).thenThrow(new RuntimeException("Test")); @@ -133,7 +133,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withSccpProgram_ SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -173,7 +173,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withAdultProgram SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -215,7 +215,7 @@ public void convertStudent_forExistingGradStudent_whenGivenData_withFrenchImmers SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -286,7 +286,7 @@ public void convertStudent_whenGivenData_withFrenchImmersionSpecialProgram_thenR SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -363,7 +363,7 @@ public void convertStudent_whenGivenData_forMergedStatus_withFrenchImmersionSpec SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -440,7 +440,7 @@ public void convertStudent_whenGiven1996Data_withFrenchImmersionSpecialProgram_t SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -517,7 +517,7 @@ public void convertStudent_whenGiven1986Data_withFrenchImmersionSpecialProgram_t SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); @@ -595,7 +595,7 @@ public void convertArchivedStudent_whenGiven1986Data_withFrenchImmersionSpecialP SchoolClob school = new SchoolClob(); school.setMinCode(mincode); - school.setSchoolName("Test SchoolClob"); + school.setSchoolName("Test School"); Student penStudent = new Student(); penStudent.setStudentID(studentID.toString()); diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index ae5696e7..bc1d6d3e 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -118,7 +118,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_returnsA school.setMincode(mincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); @@ -811,7 +811,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenCiti school.setMincode(mincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -887,7 +887,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCiti school.setMincode(mincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -963,7 +963,7 @@ public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCi school.setMincode(mincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1039,7 +1039,7 @@ public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCiti school.setMincode(mincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1897,7 +1897,7 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI school.setMincode(mincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1972,7 +1972,7 @@ public void testProcessArchivedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC school.setMincode(mincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -2047,7 +2047,7 @@ public void testProcessDeceasedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsC school.setMincode(mincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -2200,7 +2200,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT school.setMincode(mincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(schoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(schoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); From 224683dbff6390efef836cfa66c7795b00c6ba6e Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 14 Jan 2025 09:36:30 -0800 Subject: [PATCH 4/5] Fixed the broken flows in Junit test. Fixed the broken flows in Junit test. --- ...udentGraduationUpdateEventServiceTest.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java index bc1d6d3e..7b4989ad 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/dataconversion/service/StudentGraduationUpdateEventServiceTest.java @@ -199,7 +199,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -275,7 +275,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Archived school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -352,7 +352,7 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -429,7 +429,7 @@ public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdat school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -506,7 +506,7 @@ public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -583,7 +583,7 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -659,7 +659,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -735,7 +735,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGrad school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1113,7 +1113,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg school.setMincode(newMincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1187,7 +1187,7 @@ public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_w school.setMincode(newMincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1261,7 +1261,7 @@ public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_w school.setMincode(newMincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1335,7 +1335,7 @@ public void testProcessStudentForGrad2018PFProgram_givenUpdated_STUDENT_whenProg school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1409,7 +1409,7 @@ public void testProcessStudentFor1950AdultProgram_givenUpdated_STUDENT_whenProgr school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.studentProcess.hasAnyFrenchImmersionCourse(eq("2018-EN"), eq(pen), any())).thenReturn(true); @@ -1486,7 +1486,7 @@ public void testProcessStudentFor2018EN_givenUpdated_STUDENT_whenProgramIsChange school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1564,7 +1564,7 @@ public void testProcessStudentFor2018ENProgram_givenUpdated_STUDENT_whenProgramI school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1642,7 +1642,7 @@ public void testProcessStudentFor2018PFProgram_givenUpdated_STUDENT_whenProgramI school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1719,7 +1719,7 @@ public void testProcessStudentForSCCPProgram_givenUpdated_STUDENT_whenProgramIsC school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -1820,7 +1820,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT school.setMincode(newMincode); school.setSchoolReportingRequirementCode("CSF"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); @@ -2124,7 +2124,7 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT school.setMincode(newMincode); school.setSchoolReportingRequirementCode("PUBLIC"); - when(this.restUtils.getSchool(newSchoolOfRecordId, "accessToken")).thenReturn(school); + when(this.restUtils.getSchool(eq(newSchoolOfRecordId), any())).thenReturn(school); when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); From ca27a8463deb63f87243a5ec8e88cc1ab3bba0c0 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 14 Jan 2025 16:23:30 -0800 Subject: [PATCH 5/5] Updated to improve after code review. Updated to improve after code review. --- .../dataconversion/model/tsw/SchoolClob.java | 28 ------------------- .../process/StudentProcess.java | 2 +- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java index 0764a4e0..e62c70d7 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/tsw/SchoolClob.java @@ -25,34 +25,6 @@ public class SchoolClob implements Comparable { private String schoolCategoryCode; private String schoolCategoryLegacyCode; - public String getSchoolName() { - return schoolName != null ? schoolName.trim(): null; - } - - public String getDistrictName() { - return districtName != null ? districtName.trim(): null; - } - - public String getAddress1() { - return address1 != null ? address1.trim(): null; - } - - public String getAddress2() { - return address2 != null ? address2.trim(): null; - } - - public String getCity() { - return city != null ? city.trim(): null; - } - - public String getPostal() { - return postal != null ? postal.trim(): null; - } - - public String getOpenFlag() { - return openFlag != null ? openFlag.trim(): null; - } - @Override public String toString() { return "SchoolClob [minCode=" + minCode + ", schoolId=" + schoolId + ", schoolCategoryCode=" + schoolCategoryCode + ", schoolCategoryLegacyCode=" + schoolCategoryLegacyCode 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 8e2800bd..db12ab11 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 @@ -282,7 +282,7 @@ private Pair handleProgramCode(String programCode } private ConversionResultType processSccpFrenchCertificates(GraduationStudentRecord student, ConversionStudentSummaryDTO summary) { - if (StringUtils.equals(student.getProgram(), "SCCP") + if (StringUtils.equals(student.getProgram(), "SCCP") && student.getSchoolOfRecordId() != null && isSchoolForProgramFrancophone(student.getSchoolOfRecordId())) { return createStudentOptionalProgram("FR", student, summary); }