Skip to content

Commit

Permalink
GRAD2-2479: new requirements are implemented.
Browse files Browse the repository at this point in the history
GRAD2-2479: new requirements are implemented.
  • Loading branch information
infstar committed Jan 31, 2024
1 parent 468cd62 commit b1cb04e
Show file tree
Hide file tree
Showing 2 changed files with 285 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -94,59 +94,67 @@ 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;
}
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}

0 comments on commit b1cb04e

Please sign in to comment.