From b1cb04e40764c6792c937c9ff6bd43f63c4b885f Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 30 Jan 2024 17:21:41 -0800 Subject: [PATCH] GRAD2-2479: new requirements are implemented. GRAD2-2479: new requirements are implemented. --- .../StudentGraduationUpdateEventService.java | 62 +++-- ...udentGraduationUpdateEventServiceTest.java | 250 ++++++++++++++++++ 2 files changed, 285 insertions(+), 27 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 c4ecf128..ae5a679d 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 @@ -80,9 +80,9 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu // 1. School of record if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) { currentStudent.setNewSchoolOfRecord(updateGrad.getSchoolOfRecord()); + // Transcript + currentStudent.setNewRecalculateGradStatus("Y"); if (!currentStudent.isArchived()) { - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); // TVR currentStudent.setNewRecalculateProjectedGrad("Y"); } @@ -94,42 +94,50 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu if (!StringUtils.equals(gradProgram, currentStudent.getProgram())) { handleProgramChange(gradProgram, currentStudent, updateGrad.getPen(), accessToken); handleAdultStartDate(currentStudent); - if (!currentStudent.isArchived()) { + if (StringUtils.isNotBlank(currentStudent.getNewProgram())) { // Transcript currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("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(" => grad program : current = {}, request = {}", currentStudent.getProgram(), currentStudent.getNewProgram()); - isChanged = true; } // 3. SLP Date String slpDate = updateGrad.getSlpDateWithDefaultFormat(); if (slpDate != null && "SCCP".equalsIgnoreCase(currentStudent.getUpToDateGradProgram()) && !StringUtils.equals(slpDate, currentStudent.getGradDate())) { - currentStudent.setNewGradDate(slpDate); - if (!currentStudent.isArchived()) { + if (!currentStudent.isGraduated()) { + currentStudent.setNewGradDate(slpDate); // Transcript currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("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); } - log.info(" => student slp date : current = {}, request = {}", currentStudent.getGradDate(), slpDate); - isChanged = true; } // Student Grade if (!StringUtils.equals(updateGrad.getStudentGrade(), currentStudent.getStudentGrade())) { currentStudent.setNewStudentGrade(updateGrad.getStudentGrade()); - if (!currentStudent.isArchived()) { - if (!currentStudent.isGraduated()) { // non grad - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } else { + 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; @@ -137,16 +145,16 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu // Citizenship if (!StringUtils.equals(updateGrad.getCitizenship(), currentStudent.getCitizenship())) { currentStudent.setNewCitizenship(updateGrad.getCitizenship()); - if (!currentStudent.isArchived()) { - if (!currentStudent.isGraduated()) { // non grad - // Transcript - currentStudent.setNewRecalculateGradStatus("Y"); - // TVR - currentStudent.setNewRecalculateProjectedGrad("Y"); - } else { + 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; 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 c3ac6d2c..b99513c2 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 @@ -767,5 +767,255 @@ public void testProcessStudentForGrad2018ENProgram_whenException_isThrown_return assertThat(event.getEventStatus()).isEqualTo(EventStatus.DB_COMMITTED.name()); } + @Test + public void testProcessGraduatedStudentForGrad2018ENProgram_givenUpdated_STUDENT_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); + + // 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.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate("2022/06"); + // 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 testProcessGraduatedStudentForSCCP_givenUpdated_STUDENT_whenSlpDateIsChanged_then_returnsAPICallSuccess() { + // ID + UUID studentID = UUID.randomUUID(); + String pen = "111222333"; + + // Program & School + String program = "SCCP"; + String mincode = "093333"; + + String newSlpDate = "202006"; + + String updateType = "UPD_GRAD"; + + // TraxGraduationUpdateDTO + TraxGraduationUpdateDTO traxGraduationUpdate = new TraxGraduationUpdateDTO(); + traxGraduationUpdate.setPen(pen); + traxGraduationUpdate.setGraduationRequirementYear("SCCP"); + traxGraduationUpdate.setStudentGrade("12"); + traxGraduationUpdate.setSchoolOfRecord(mincode); + traxGraduationUpdate.setSlpDate(newSlpDate); + + // 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("CUR"); + currentStudent.setSchoolOfRecord(mincode); + currentStudent.setSchoolAtGrad(mincode); + currentStudent.setGradDate("2022/06"); + // 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 + 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); + + // 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/06"); + // 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 testProcessGraduatedStudentForGrad2018ENProgram_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); + + // 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("2022/06"); + // 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()); + } }