diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java index c7b66fb6..59c75eb5 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/choreographer/ChoreographEventHandler.java @@ -56,7 +56,7 @@ public void handleEvent(@NonNull final Event event) { final TraxGraduationUpdateDTO updateGrad = JsonUtil.getJsonObjectFromString(TraxGraduationUpdateDTO.class, event.getEventPayload()); this.eventServiceMap.get(UPD_GRAD.toString()).processEvent(updateGrad, event); break; - case "UPD_STD_STATUS": + case "UPD_STD_STATUS": // UPD_STD_STATUS will be deprecated log.debug("Processing UPD_STD_STATUS event record :: {} ", event); final TraxStudentStatusUpdateDTO updateStudentStatus = JsonUtil.getJsonObjectFromString(TraxStudentStatusUpdateDTO.class, event.getEventPayload()); this.eventServiceMap.get(UPD_STD_STATUS.toString()).processEvent(updateStudentStatus, event); diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/EventType.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/EventType.java index 1cf1114c..07ab2513 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/EventType.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/constant/EventType.java @@ -13,7 +13,7 @@ public enum EventType { NEWSTUDENT, UPD_DEMOG, UPD_GRAD, - UPD_STD_STATUS, + UPD_STD_STATUS, // UPD_STD_STATUS will be deprecated XPROGRAM, ASSESSMENT, COURSE, 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 34d56d00..3c364a2a 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 @@ -39,4 +39,13 @@ public String getUpToDateSchoolOfRecord() { return StringUtils.isNotBlank(newSchoolOfRecord)? newSchoolOfRecord : this.getSchoolOfRecord(); } + @Override + public boolean isArchived() { + if (StringUtils.isNotBlank(newStudentStatus) && "ARC".equalsIgnoreCase(newStudentStatus)) { // Student Status from TRAX + return true; + } else { + return super.isArchived(); // Student Status from GRAD + } + } + } diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java index 1ce9b8d5..f8a633b0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxGraduationUpdateDTO.java @@ -24,6 +24,10 @@ public class TraxGraduationUpdateDTO extends TraxStudentUpdateDTO { private String slpDate; // STUD_CITIZ private String citizenship; + // STUD_STATUS + private String studentStatus; + // ARCHIVE_FLAG + private String archiveFlag; public String getSlpDateWithDefaultFormat() { if (StringUtils.isBlank(slpDate)) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxStudentStatusUpdateDTO.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxStudentStatusUpdateDTO.java index cdf9d166..047e1c66 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxStudentStatusUpdateDTO.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/model/TraxStudentStatusUpdateDTO.java @@ -11,6 +11,7 @@ @AllArgsConstructor @NoArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) +// UPD_STD_STATUS will be deprecated public class TraxStudentStatusUpdateDTO extends TraxStudentUpdateDTO { // STUD_STATUS 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 1fd8f1cb..8846fc94 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 @@ -440,6 +440,13 @@ public void saveGraduationStudent(String pen, StudentGradDTO gradStudent, EventT requestDTO.setEventType(eventType); // UPD_GRAD ==================================================== if (eventType == EventType.UPD_GRAD) { + // Student Status + if (StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) { + OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() + .type(FieldType.STRING).name(FieldName.STUDENT_STATUS).value(gradStudent.getNewStudentStatus()) + .build(); + requestDTO.getUpdateFields().add(field); + } // School of Record if (StringUtils.isNotBlank(gradStudent.getNewSchoolOfRecord())) { OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() @@ -483,7 +490,7 @@ public void saveGraduationStudent(String pen, StudentGradDTO gradStudent, EventT requestDTO.getUpdateFields().add(field); } } - // UPD_GRAD ==================================================== + // UPD_STD_STATUS will be deprecated // Student Status if (eventType == EventType.UPD_STD_STATUS && StringUtils.isNotBlank(gradStudent.getNewStudentStatus())) { OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder() 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 ae5a679d..d96b951d 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 @@ -73,91 +73,105 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu boolean isChanged = false; log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen()); - if (currentStudent.isArchived() && currentStudent.isGraduated()) { - return; - } - // Order is important for first 3 items below!!! - // 1. School of record - if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { - currentStudent.setNewSchoolOfRecord(updateGrad.getSchoolOfRecord()); - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - if (!currentStudent.isArchived()) { + // Processing order is important for the first 3 fields below. + String newStudentStatus = getGradStudentStatus(updateGrad.getStudentStatus(), updateGrad.getArchiveFlag()); + // 0. 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"); } - log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); + log.info(" => student status : current = {}, request = {}", currentStudent.getStudentStatus(), currentStudent.getNewStudentStatus()); 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())) { + 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(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram()); + log.info(" => school of record : current = {}, request = {}", currentStudent.getSchoolOfRecord(), currentStudent.getNewSchoolOfRecord()); 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"); + // 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); } - 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()) { + // 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"); } - } else { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); + log.info(" => student grade : current = {}, request = {}", currentStudent.getStudentGrade(), currentStudent.getNewStudentGrade()); + isChanged = true; } - 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()) { + // 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"); } - } else { - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); + log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship()); + isChanged = true; } - log.info(" => student citizenship : current = {}, request = {}", currentStudent.getCitizenship(), currentStudent.getNewCitizenship()); - isChanged = true; } if (isChanged) { diff --git a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java index 51f52e8b..202b7116 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/dataconversion/service/student/StudentStatusUpdateEventService.java @@ -21,6 +21,7 @@ @Service @Slf4j +// UPD_STD_STATUS will be deprecated public class StudentStatusUpdateEventService extends StudentBaseService implements EventService { private final EventRepository eventRepository; 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 9001eaf6..e0121bb3 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 @@ -886,6 +886,43 @@ public void testSaveGraduationStudent_whenENisChangedTo1950Adult_then_returnAPIC assertThat(exceptionIsThrown).isFalse(); } + @Test + public void testSaveGraduationStudent_whenStudentStatus_isChanged_then_returnAPICallSuccess() { + String program = "2018-EN"; + String pen = "111222333"; + UUID studentID = UUID.randomUUID(); + + GraduationStudentRecord graduationStudentRecord = new GraduationStudentRecord(); + graduationStudentRecord.setStudentID(studentID); + graduationStudentRecord.setProgram(program); + graduationStudentRecord.setStudentGrade("11"); + graduationStudentRecord.setStudentStatus("CUR"); + graduationStudentRecord.setSchoolOfRecord("222336"); + + when(this.restUtils.getStudentGradStatus(studentID.toString(), "123")).thenReturn(graduationStudentRecord); + + StudentGradDTO requestStudent = new StudentGradDTO(); + requestStudent.setStudentID(studentID); + requestStudent.setProgram(program); + requestStudent.setNewProgram("1950"); + requestStudent.setNewStudentGrade("AD"); + requestStudent.setNewSchoolOfRecord("333456"); + requestStudent.setNewStudentStatus("ARC"); + requestStudent.setNewRecalculateGradStatus("Y"); + requestStudent.setNewRecalculateProjectedGrad("Y"); + requestStudent.setNewAdultStartDate("2010-01-01"); + requestStudent.setNewCitizenship("C"); + requestStudent.setNewGradDate("2022/06/01"); + + boolean exceptionIsThrown = false; + try { + studentProcess.saveGraduationStudent(pen, requestStudent, EventType.UPD_STD_STATUS, "123"); + } catch (Exception e) { + exceptionIsThrown = true; + } + assertThat(exceptionIsThrown).isFalse(); + } + @Test public void testLoadStudentData_whenPENStudentAPIisDown_returnsNull() { // ID 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 20a38f27..afa2c8b3 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 @@ -75,6 +75,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_returnsA traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -141,6 +143,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -183,7 +187,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad } @Test - public void testProcessStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { + public void testProcessArchivedStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT_whenGradeAndSchoolAreChanged_then_returnsAPICallSuccess() { // ID UUID studentID = UUID.randomUUID(); String pen = "111222333"; @@ -203,6 +207,201 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT 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("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 testProcessCurrentGraduatedStudentForGrad2018ENProgram_givenUpdated_Archived_STUDENT_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("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); + 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 + 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("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_whenGradeAndSchoolAreChangedAndStatusIsArchived_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(); @@ -265,6 +464,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenSlpD traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -327,6 +528,8 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenProg traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -387,6 +590,8 @@ public void testProcessStudentForGrad2018PFProgram_givenUpdated_STUDENT_whenProg traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -447,6 +652,8 @@ public void testProcessStudentFor1950AdultProgram_givenUpdated_STUDENT_whenProgr traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -508,6 +715,8 @@ public void testProcessStudentFor2018EN_givenUpdated_STUDENT_whenProgramIsChange traxGraduationUpdate.setGraduationRequirementYear("1950"); traxGraduationUpdate.setStudentGrade("AD"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -572,6 +781,8 @@ public void testProcessStudentFor2018ENProgram_givenUpdated_STUDENT_whenProgramI traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -636,6 +847,8 @@ public void testProcessStudentFor2018PFProgram_givenUpdated_STUDENT_whenProgramI traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -698,6 +911,8 @@ public void testProcessStudentForSCCPProgram_givenUpdated_STUDENT_whenProgramIsC traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -791,6 +1006,8 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT traxGraduationUpdate.setGraduationRequirementYear("2018"); traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -853,6 +1070,8 @@ public void testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateI traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); traxGraduationUpdate.setSlpDate(newSlpDate); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -917,6 +1136,8 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT traxGraduationUpdate.setCitizenship("C"); traxGraduationUpdate.setStudentGrade("11"); traxGraduationUpdate.setSchoolOfRecord(newMincode); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event(); @@ -980,6 +1201,8 @@ public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT traxGraduationUpdate.setStudentGrade("12"); traxGraduationUpdate.setSchoolOfRecord(mincode); traxGraduationUpdate.setCitizenship(newCitizenship); + traxGraduationUpdate.setStudentStatus("A"); + traxGraduationUpdate.setArchiveFlag("A"); // Event Event event = new Event();