Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2303: task is complete. #300

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,41 +70,25 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St
boolean isChanged = false;
// Last Name
if (!StringUtils.equals(updateDemog.getLastName(), currentStudent.getLastName())) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");

populateNewBatchFlags(currentStudent);
isChanged = true;
log.info(" => student last name : current = {}, request = {}", currentStudent.getLastName(), updateDemog.getLastName());
}
// First Name
if (!StringUtils.equals(updateDemog.getFirstName(), currentStudent.getFirstName())) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");

populateNewBatchFlags(currentStudent);
isChanged = true;
log.info(" => student first name : current = {}, request = {}", currentStudent.getFirstName(), updateDemog.getFirstName());
}
// Middle Names
if (!StringUtils.equals(updateDemog.getMiddleNames(), currentStudent.getMiddleName())) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");

populateNewBatchFlags(currentStudent);
isChanged = true;
log.info(" => student middle name : current = {}, request = {}", currentStudent.getMiddleName(), updateDemog.getMiddleNames());
}
// Date of Birth
if (!StringUtils.equals(updateDemog.getBirthday(), currentStudent.getBirthday())) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");

populateNewBatchFlags(currentStudent);
isChanged = true;
log.info(" => student dob : current = {}, request = {}", currentStudent.getBirthday(), updateDemog.getBirthday());
}
Expand All @@ -115,6 +99,18 @@ public void processStudentDemographics(TraxDemographicsUpdateDTO updateDemog, St
}
}

private void populateNewBatchFlags(StudentGradDTO currentStudent) {
if ("ARC".equalsIgnoreCase(currentStudent.getStudentStatus())) {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
} else {
// Transcript
currentStudent.setNewRecalculateGradStatus("Y");
// TVR
currentStudent.setNewRecalculateProjectedGrad("Y");
}
}

@Override
public String getEventType() {
return UPD_DEMOG.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu
boolean isChanged = false;

log.info(" Process Student : studentID = {}, pen = {}", currentStudent.getStudentID(), updateGrad.getPen());
if ("ARC".equalsIgnoreCase(currentStudent.getStudentStatus())) {
return;
}
// Order is important for first 3 items below!!!
// 1. School of record
if (!StringUtils.equals(updateGrad.getSchoolOfRecord(), currentStudent.getSchoolOfRecord())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testProcessStudentAssessmentForGrad2018ENProgram_givenUpdated_STUDEN
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);
// Optional Program Codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testProcessStudentCourseForGrad2018ENProgram_givenUpdated_STUDENT_re
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);
// Optional Program Codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,53 @@ public void testProcessStudentDemographicsForGrad2018ENProgram_givenUpdated_UPD_
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);

when(this.studentProcess.loadStudentData(eq(pen), any())).thenReturn(currentStudent);
when(this.eventRepository.findByEventId(event.getEventId())).thenReturn(Optional.of(event));

studentDemographicsUpdateEventService.processEvent(traxDemogUpdate, event);

assertThat(event).isNotNull();
assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name());
}

@Test
public void testProcessStudentDemographicsForArchivedGrad2018ENProgram_givenUpdated_UPD_DEMOG_then_returnsAPICallSuccess() {
// ID
UUID studentID = UUID.randomUUID();
String pen = "111222333";

// Program & School
String program = "2018-EN";
String mincode = "222333";

String updateType = "UPD_DEMOG";

// TraxUpdateInGrad
TraxDemographicsUpdateDTO traxDemogUpdate = new TraxDemographicsUpdateDTO();
traxDemogUpdate.setPen(pen);
traxDemogUpdate.setFirstName("Test");
traxDemogUpdate.setMiddleNames("and");
traxDemogUpdate.setLastName("QA");
traxDemogUpdate.setBirthday("19960601");

// Event
Event event = new Event();
event.setEventType(EventType.UPD_DEMOG.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.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_FI10ADD_whenNewC
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);
// Optional Program Codes
Expand Down Expand Up @@ -141,7 +141,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_FI10DELETE_whenC
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);
// Optional Program Codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,68 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_STUDENT_whenGrad
assertThat(event.getEventStatus()).isEqualTo(EventStatus.PROCESSED.name());
}

@Test
public void testProcessStudentForGrad2018ENProgram_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);

// 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_whenSlpDateAndCitizenshipAreChanged_then_returnsAPICallSuccess() {
// ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_XPROGRAM_whenCou
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);
// Optional Program Codes
Expand Down Expand Up @@ -374,7 +374,7 @@ public void testProcessStudentForGrad2018ENProgram_givenUpdated_XPROGRAM_whenNew
currentStudent.setStudentID(studentID);
currentStudent.setProgram(program);
currentStudent.setStudentGrade("12");
currentStudent.setStudentStatus("A");
currentStudent.setStudentStatus("CUR");
currentStudent.setSchoolOfRecord(mincode);
currentStudent.setSchoolAtGrad(mincode);
// Optional Program Codes
Expand Down
Loading