Skip to content

Commit

Permalink
Fixed the updated logic and put more junit test cases to cover it.
Browse files Browse the repository at this point in the history
Fixed the updated logic and put more junit test cases to cover it.
  • Loading branch information
infstar committed May 8, 2024
1 parent f840660 commit e015e0a
Show file tree
Hide file tree
Showing 2 changed files with 289 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ 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;
}
// Processing order is important for the first 3 fields below.
String newStudentStatus = getGradStudentStatus(updateGrad.getStudentStatus(), updateGrad.getArchiveFlag());
// 0. Student Status
Expand All @@ -92,87 +89,89 @@ public void processStudent(TraxGraduationUpdateDTO updateGrad, StudentGradDTO cu
log.info(" => student status : current = {}, request = {}", currentStudent.getStudentStatus(), currentStudent.getNewStudentStatus());
isChanged = true;
}
// 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())) {
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) {
Expand Down
Loading

0 comments on commit e015e0a

Please sign in to comment.