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 70f5988..198312d 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 @@ -185,7 +185,7 @@ private void convertStudentData(ConvGradStudent student, Student penStudent, Gra gradStudent.setStudentGrade(student.getStudentGrade()); gradStudent.setStudentStatus(getGradStudentStatus(student.getStudentStatus(), student.getArchiveFlag())); - handleAdultStartRule(student, penStudent, gradStudent); + handleAdultStartRule(penStudent, gradStudent); // flags if (StringUtils.equalsIgnoreCase(gradStudent.getStudentStatus(), STUDENT_STATUS_MERGED)) { @@ -610,7 +610,7 @@ public void triggerGraduationBatchRun(EventType eventType, UUID studentID, Strin } } - private void handleAdultStartRule(ConvGradStudent student, Student penStudent, GraduationStudentRecord gradStudent) { + private void handleAdultStartRule(Student penStudent, GraduationStudentRecord gradStudent) { if ("1950".equalsIgnoreCase(gradStudent.getProgram())) { Date dob = EducGradDataConversionApiUtils.parseDate(penStudent.getDob()); Date adultStartDate = DateUtils.addYears(dob, 18); 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 c2afcb9..87654c5 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 @@ -10,7 +10,10 @@ import java.util.Arrays; import java.util.List; -public class StudentBaseService { +public abstract class StudentBaseService { + + // NULL String => Nullify (set to NULL) + public static final String NULL_VALUE = "NULL"; // Student Status public static final String STUDENT_STATUS_CURRENT = "CUR"; @@ -109,14 +112,21 @@ protected String getGradProgram(String graduationRequirementYear, String schoolO } protected void populateNewBatchFlags(StudentGradDTO currentStudent) { - if (STUDENT_STATUS_ARCHIVED.equalsIgnoreCase(currentStudent.getStudentStatus())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - } else { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + } + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + default -> { + // do not set flags to Y + currentStudent.setNewRecalculateGradStatus(null); + currentStudent.setNewRecalculateProjectedGrad(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 new file mode 100644 index 0000000..1486cfd --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentGraduationUpdateBaseService.java @@ -0,0 +1,269 @@ +package ca.bc.gov.educ.api.dataconversion.service.student; + +import ca.bc.gov.educ.api.dataconversion.model.StudentGradDTO; +import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateUtils; + +import java.util.Date; + +public abstract class StudentGraduationUpdateBaseService extends StudentBaseService { + + protected abstract boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken); + + protected void handleProgramChange(String newGradProgram, StudentGradDTO currentStudent, String pen, String accessToken) { + boolean addDualDogwood = false; + boolean addFrenchImmersion = false; + + if (!currentStudent.isSCCP() && currentStudent.isGraduated()) { + currentStudent.setNewProgram(null); + return; + } + + if (newGradProgram.endsWith("-PF")) { + // from EN to PF + // from PF to PF + // from 1950 to PF + // from SCCP to PF + addDualDogwood = true; + } else if (newGradProgram.endsWith("-EN") && (currentStudent.getProgram().endsWith("-PF") || hasAnyFrenchImmersionCourse(newGradProgram, pen, accessToken))) { + // from PF to EN - allowed for SD93/Yukon PF schools + // from EN to EN + // from 1950 to EN + // from SCCP to EN + addFrenchImmersion = true; + } + + currentStudent.setAddDualDogwood(addDualDogwood); + currentStudent.setAddFrenchImmersion(addFrenchImmersion); + + currentStudent.setNewProgram(newGradProgram); + } + + protected void handleAdultStartDate(StudentGradDTO currentStudent) { + if (StringUtils.equalsIgnoreCase(currentStudent.getNewProgram(), "1950") && StringUtils.isBlank(currentStudent.getAdultStartDate())) { + Date dob = EducGradDataConversionApiUtils.parseDate(currentStudent.getBirthday()); + Date adultStartDate = DateUtils.addYears(dob, 18); + currentStudent.setNewAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd + } + } + + protected boolean processSchoolOfRecord(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewSchoolOfRecord(value); + // Do not set flags to Y + isChanged = true; + } + } + return isChanged; + } + + protected boolean processStudentGrade(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // UpdData + currentStudent.setNewStudentGrade(value); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + if (!currentStudent.isGraduated()) { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + } + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewStudentGrade(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewStudentGrade(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewStudentGrade(value); + // Do not set flags to Y + isChanged = true; + } + } + return isChanged; + } + + protected boolean processGraduationProgram(StudentGradDTO currentStudent, String pen, String gradProgram, String accessToken) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + if (!currentStudent.isGraduated() || currentStudent.isSCCP()) { + // UpdData + handleProgramChange(gradProgram, currentStudent, pen, accessToken); + handleAdultStartDate(currentStudent); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> { + if (!currentStudent.isGraduated() || currentStudent.isSCCP()) { + // UpdData + handleProgramChange(gradProgram, currentStudent, pen, accessToken); + handleAdultStartDate(currentStudent); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + default -> { // MER or DEC + if (!currentStudent.isGraduated() || currentStudent.isSCCP()) { + // UpdData + handleProgramChange(gradProgram, currentStudent, pen, accessToken); + handleAdultStartDate(currentStudent); + // Do not set flags to Y + isChanged = true; + } + } + + } + return isChanged; + } + + protected boolean processSlpDate(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewGradDate(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_TERMINATED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewGradDate(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + default -> { // MER or DEC + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewGradDate(value); + // Do not set flags to Y + isChanged = true; + } + } + + } + return isChanged; + } + + protected boolean processCitizenship(StudentGradDTO currentStudent, String value) { + boolean isChanged = false; + switch(currentStudent.getStudentStatus()) { + case STUDENT_STATUS_CURRENT -> { + // UpdData + currentStudent.setNewCitizenship(value); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + if (!currentStudent.isGraduated()) { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + } + isChanged = true; + } + case STUDENT_STATUS_ARCHIVED -> { + if (!currentStudent.isGraduated()) { + // UpdData + currentStudent.setNewCitizenship(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + } + case STUDENT_STATUS_TERMINATED -> { + // UpdData + currentStudent.setNewCitizenship(value); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + isChanged = true; + } + default -> { // MER or DEC + // UpdData + currentStudent.setNewCitizenship(value); + // Do not set flags to Y + isChanged = true; + } + + } + return isChanged; + } + + protected void processStudentStatus(StudentGradDTO currentStudent, String value) { + // UpdData + currentStudent.setNewStudentStatus(value); + switch(value) { + case STUDENT_STATUS_ARCHIVED, STUDENT_STATUS_MERGED -> { + // TVR + currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); + } + case STUDENT_STATUS_CURRENT -> { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad("Y"); + } + case STUDENT_STATUS_TERMINATED -> { + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); + // TVR + currentStudent.setNewRecalculateProjectedGrad(NULL_VALUE); + } + default -> { // DEC + } + } + } +} 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 d96b951..310c6b2 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 @@ -6,23 +6,20 @@ import ca.bc.gov.educ.api.dataconversion.repository.EventRepository; import ca.bc.gov.educ.api.dataconversion.service.EventService; 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; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.time.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; -import java.util.Date; import static ca.bc.gov.educ.api.dataconversion.constant.EventStatus.PROCESSED; import static ca.bc.gov.educ.api.dataconversion.constant.EventType.UPD_GRAD; @Service @Slf4j -public class StudentGraduationUpdateEventService extends StudentBaseService implements EventService { +public class StudentGraduationUpdateEventService extends StudentGraduationUpdateBaseService implements EventService { private final EventRepository eventRepository; @@ -74,105 +71,49 @@ 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. School of record + if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { + isChanged = processSchoolOfRecord(currentStudent, updateGrad.getSchoolOfRecord()); + log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); + } + // 2. Grad Program + String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); + if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { + isChanged = processGraduationProgram(currentStudent, updateGrad.getPen(), gradProgram, accessToken); + if (isChanged && StringUtils.isNotBlank(currentStudent.getNewProgram())) { + log.info(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram()); + } else { + log.info(" => grad program : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getProgram(), gradProgram); + } + } + // 3. SLP Date + String slpDate = updateGrad.getSlpDateWithDefaultFormat(); + if (slpDate != null && "SCCP".equalsIgnoreCase(currentStudent.getUpToDateGradProgram()) + && !StringUtils.equals(slpDate, currentStudent.getGradDate())) { + isChanged = processSlpDate(currentStudent, slpDate); + if (isChanged) { + log.info(" => slp date : current = {}, request = {}", currentStudent.getGradDate(), slpDate); + } else { + log.info(" => slp date : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getGradDate(), slpDate); + } + } + // 4. Student Grade + if (!StringUtils.equals(updateGrad.getStudentGrade(), currentStudent.getStudentGrade())) { + isChanged = processStudentGrade(currentStudent, updateGrad.getStudentGrade()); + log.info(" => student grade : current = {}, request = {}", currentStudent.getStudentGrade(), currentStudent.getNewStudentGrade()); + } + // 5. Citizenship + if (!StringUtils.equals(updateGrad.getCitizenship(), currentStudent.getCitizenship())) { + isChanged = processCitizenship(currentStudent, updateGrad.getCitizenship()); + log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship()); + } String newStudentStatus = getGradStudentStatus(updateGrad.getStudentStatus(), updateGrad.getArchiveFlag()); - // 0. Student Status + // 6. Student Status if (!StringUtils.equals(newStudentStatus, currentStudent.getStudentStatus())) { - currentStudent.setNewStudentStatus(newStudentStatus); - if (StringUtils.equalsIgnoreCase(currentStudent.getNewStudentStatus(), STUDENT_STATUS_CURRENT) - || StringUtils.equalsIgnoreCase(currentStudent.getNewStudentStatus(), STUDENT_STATUS_TERMINATED) - || StringUtils.equalsIgnoreCase(currentStudent.getNewStudentStatus(), STUDENT_STATUS_DECEASED)) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } + processStudentStatus(currentStudent, newStudentStatus); log.info(" => student status : current = {}, request = {}", currentStudent.getStudentStatus(), currentStudent.getNewStudentStatus()); isChanged = true; } - if (!currentStudent.isArchived() || !currentStudent.isGraduated()) { - // 1. School of record - if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { - currentStudent.setNewSchoolOfRecord(updateGrad.getSchoolOfRecord()); - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); - isChanged = true; - } - // 2. Grad Program - String gradProgram = getGradProgram(updateGrad.getGraduationRequirementYear(), currentStudent.getUpToDateSchoolOfRecord(), null); - if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { - handleProgramChange(gradProgram, currentStudent, updateGrad.getPen(), accessToken); - handleAdultStartDate(currentStudent); - if (StringUtils.isNotBlank(currentStudent.getNewProgram())) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram()); - isChanged = true; - } else { - log.info(" => grad program : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getProgram(), gradProgram); - } - } - // 3. SLP Date - String slpDate = updateGrad.getSlpDateWithDefaultFormat(); - if (slpDate != null && "SCCP".equalsIgnoreCase(currentStudent.getUpToDateGradProgram()) - && !StringUtils.equals(slpDate, currentStudent.getGradDate())) { - if (!currentStudent.isGraduated()) { - currentStudent.setNewGradDate(slpDate); - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => slp date : current = {}, request = {}", currentStudent.getGradDate(), slpDate); - isChanged = true; - } else { - log.info(" => slp date : current = {}, request = {} => no change(undo completion is required instead)", currentStudent.getGradDate(), slpDate); - } - } - // Student Grade - if (!StringUtils.equals(updateGrad.getStudentGrade(), currentStudent.getStudentGrade())) { - currentStudent.setNewStudentGrade(updateGrad.getStudentGrade()); - if (!currentStudent.isGraduated()) { // non grad - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - } else { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => student grade : current = {}, request = {}", currentStudent.getStudentGrade(), currentStudent.getNewStudentGrade()); - isChanged = true; - } - // Citizenship - if (!StringUtils.equals(updateGrad.getCitizenship(), currentStudent.getCitizenship())) { - currentStudent.setNewCitizenship(updateGrad.getCitizenship()); - if (!currentStudent.isGraduated()) { // non grad - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - } else { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } - log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship()); - isChanged = true; - } - } if (isChanged) { log.info(" Save Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); @@ -180,45 +121,14 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu } } - private void handleProgramChange(String newGradProgram, StudentGradDTO currentStudent, String pen, String accessToken) { - boolean addDualDogwood = false; - boolean addFrenchImmersion = false; - - if (!currentStudent.isSCCP() && currentStudent.isGraduated()) { - currentStudent.setNewProgram(null); - return; - } - - if (newGradProgram.endsWith("-PF")) { - // from EN to PF - // from PF to PF - // from 1950 to PF - // from SCCP to PF - addDualDogwood = true; - } else if (newGradProgram.endsWith("-EN") && (currentStudent.getProgram().endsWith("-PF") || studentProcess.hasAnyFrenchImmersionCourse(newGradProgram, pen, accessToken))) { - // from PF to EN - allowed for SD93/Yukon PF schools - // from EN to EN - // from 1950 to EN - // from SCCP to EN - addFrenchImmersion = true; - } - - currentStudent.setAddDualDogwood(addDualDogwood); - currentStudent.setAddFrenchImmersion(addFrenchImmersion); - - currentStudent.setNewProgram(newGradProgram); - } - - private void handleAdultStartDate(StudentGradDTO currentStudent) { - if (StringUtils.equalsIgnoreCase(currentStudent.getNewProgram(), "1950") && StringUtils.isBlank(currentStudent.getAdultStartDate())) { - Date dob = EducGradDataConversionApiUtils.parseDate(currentStudent.getBirthday()); - Date adultStartDate = DateUtils.addYears(dob, 18); - currentStudent.setNewAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd - } - } - @Override public String getEventType() { return UPD_GRAD.toString(); } + + @Override + public boolean hasAnyFrenchImmersionCourse(String gradProgramCode, String pen, String accessToken) { + return studentProcess.hasAnyFrenchImmersionCourse(gradProgramCode, pen, accessToken); + } + } 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 afa2c8b..57af61a 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 @@ -315,6 +315,137 @@ public void testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_ assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); } + @Test + public void testProcessTerminatedGraduatedStudentForGrad2018ENProgram_givenUpdated_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("T"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("TER"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate("2022/02"); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessDeceasedGraduatedStudentForGrad2018ENProgram_givenUpdated_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("DEC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate("2022/02"); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { // ID @@ -325,7 +456,329 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ String program = "2018-EN"; String mincode = "222333"; - String newMincode = "333444"; + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("CUR"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_STUDENT_whenGradeAndSchoolAreChangedAndStatusIsCurrent_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenGradeAndSchoolAreChangedAndStatusIsTerminated_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "333444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setCitizenship("C"); + traxGraduationUpdate.setStudentGrade("11"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("T"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship("C"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newCitizenship = "C"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("CUR"); + currentStudent.setCitizenship(null); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newCitizenship = "C"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setCitizenship(null); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("FI"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessTerminatedStudentForGrad2018ENProgram_givenUpdated_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newCitizenship = "C"; String updateType = "UPD_GRAD"; @@ -333,11 +786,11 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); traxGraduationUpdate.setPen(pen); traxGraduationUpdate.setGraduationRequirementYear("2018"); - traxGraduationUpdate.setCitizenship("C"); - traxGraduationUpdate.setStudentGrade("11"); - traxGraduationUpdate.setSchoolOfRecord(newMincode); - traxGraduationUpdate.setStudentStatus("A"); - traxGraduationUpdate.setArchiveFlag("I"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("T"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -352,10 +805,11 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("CUR"); - currentStudent.setCitizenship("C"); + currentStudent.setStudentStatus("TER"); + currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); currentStudent.getProgramCodes().add("FI"); @@ -380,7 +834,7 @@ public void testProcessCurrentStudentForGrad2018ENProgram_givenUpdated_Archived_ } @Test - public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_STUDENT_whenGradeAndSchoolAreChangedAndStatusIsArchived_then_returnsAPICallSuccess() { + public void testProcessDeceasedStudentForGrad2018ENProgram_givenUpdated_whenCitizenshipIsChanged_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -389,7 +843,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ String program = "2018-EN"; String mincode = "222333"; - String newMincode = "333444"; + String newCitizenship = "C"; String updateType = "UPD_GRAD"; @@ -397,11 +851,11 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); traxGraduationUpdate.setPen(pen); traxGraduationUpdate.setGraduationRequirementYear("2018"); - traxGraduationUpdate.setCitizenship("C"); - traxGraduationUpdate.setStudentGrade("11"); - traxGraduationUpdate.setSchoolOfRecord(newMincode); - traxGraduationUpdate.setStudentStatus("A"); - traxGraduationUpdate.setArchiveFlag("A"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); // Event Event event = new Event(); @@ -416,10 +870,11 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("ARC"); - currentStudent.setCitizenship("C"); + currentStudent.setStudentStatus("DEC"); + currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate(null); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); currentStudent.getProgramCodes().add("FI"); @@ -444,7 +899,7 @@ public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Current_ } @Test - public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpDateAndCitizenshipAreChanged_then_returnsAPICallSuccess() { + public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -453,7 +908,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD String program = "2018-EN"; String mincode = "222333"; - String newCitizenship = "C"; + String newMincode = "093444"; String updateType = "UPD_GRAD"; @@ -462,8 +917,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD traxGraduationUpdate.setPen(pen); traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); - traxGraduationUpdate.setSchoolOfRecord(mincode); - traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setSchoolOfRecord(newMincode); traxGraduationUpdate.setStudentStatus("A"); traxGraduationUpdate.setArchiveFlag("A"); @@ -481,13 +935,11 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); currentStudent.setStudentStatus("CUR"); - currentStudent.setCitizenship(null); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); - currentStudent.setGradDate(null); // Optional Program Codes currentStudent.getProgramCodes().add("XC"); - currentStudent.getProgramCodes().add("FI"); + currentStudent.getProgramCodes().add("DD"); // Courses StudentCourse course1 = new StudentCourse(); course1.setCourseCode("Test"); @@ -509,7 +961,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD } @Test - public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { + public void testProcessArchivedNonGradStudentForGrad2018ENProgram_givenUpdated_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -529,7 +981,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); traxGraduationUpdate.setStudentStatus("A"); - traxGraduationUpdate.setArchiveFlag("A"); + traxGraduationUpdate.setArchiveFlag("I"); // Event Event event = new Event(); @@ -544,7 +996,69 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg currentStudent.setStudentID(studentID); currentStudent.setProgram(program); currentStudent.setStudentGrade("12"); - currentStudent.setStudentStatus("CUR"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("DD"); + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessDeceasedNonGradStudentForGrad2018ENProgram_givenUpdated_whenProgramIsChangedTo2018PF_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "2018-EN"; + String mincode = "222333"; + + String newMincode = "093444"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("2018"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("DEC"); currentStudent.setSchoolOfRecord(mincode); currentStudent.setSchoolAtGrad(mincode); // Optional Program Codes @@ -1115,6 +1629,136 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); } + @Test + public void testProcessArchivedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "SCCP"; + String mincode = "093333"; + + String newSlpDate = "208006"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("SCCP"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + currentStudent.setBirthday("2000-01-01"); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("ARC"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("DD"); + + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + + @Test + public void testProcessDeceasedNonGradStudentForSCCP_givenUpdated_whenSlpDateIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "SCCP"; + String mincode = "093333"; + + String newSlpDate = "208006"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("SCCP"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("D"); + traxGraduationUpdate.setArchiveFlag("I"); + + // Event + Event event = new Event(); + event.setEventType(EventType.UPD_GRAD.name()); + event.setEventStatus(EventStatus.DB_COMMITTED.name()); + event.setActivityCode(updateType); + event.setEventId(UUID.randomUUID()); + + // current GRAD Student + StudentGradDTO currentStudent = new StudentGradDTO(); + currentStudent.setBirthday("2000-01-01"); + // GraduationStudentRecord + currentStudent.setStudentID(studentID); + currentStudent.setProgram(program); + currentStudent.setStudentGrade("12"); + currentStudent.setStudentStatus("DEC"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + // Optional Program Codes + currentStudent.getProgramCodes().add("XC"); + currentStudent.getProgramCodes().add("DD"); + + // Courses + StudentCourse course1 = new StudentCourse(); + course1.setCourseCode("Test"); + course1.setCourseLevel("12"); + course1.setCourseName("Test Course"); + course1.setCreditsUsedForGrad(Integer.valueOf("4")); + course1.setCompletedCoursePercentage(Double.valueOf("92.00")); + course1.setCredits(Integer.valueOf("4")); + course1.setPen(pen); + currentStudent.getCourses().add(course1); + + when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent); + when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event)); + + studentGraduationUpdateEventService.processEvent(traxGraduationUpdate, event); + + assertThat(event).isNotNull(); + assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name()); + } + @Test public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { // ID