Skip to content

Commit

Permalink
Merge pull request #681 from bcgov/develop/alex-GRAD2-2591
Browse files Browse the repository at this point in the history
GRAD2-2591
  • Loading branch information
arybakov-cgi authored Sep 18, 2024
2 parents 934a78b + c082043 commit a063c59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,15 @@ public Pair<GraduationStudentRecord, GradStatusEvent> undoCompletionStudent(UUID
if (gradStatusEvent != null) {
gradStatusEventRepository.save(gradStatusEvent);
}
List<StudentOptionalProgramEntity> studentOptionalProgramEntities = gradStudentOptionalProgramRepository.findByStudentID(studentID);
for(StudentOptionalProgramEntity studentOptionalProgramEntity: studentOptionalProgramEntities) {
studentOptionalProgramEntity.setOptionalProgramCompletionDate(null);
studentOptionalProgramEntity.setStudentOptionalProgramData(null);
studentOptionalProgramEntity.setUpdateDate(LocalDateTime.now());
studentOptionalProgramEntity.setUpdateUser(ThreadLocalStateUtil.getCurrentUser());
gradStudentOptionalProgramRepository.save(studentOptionalProgramEntity);
historyService.createStudentOptionalProgramHistory(studentOptionalProgramEntity,USER_UNDO_CMPL);
}
return Pair.of(graduationStatusTransformer.transformToDTOWithModifiedProgramCompletionDate(gradEntity), gradStatusEvent);
} else {
validation.addErrorAndStop(String.format("Student ID [%s] does not exists", studentID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,14 @@ public void testUgradStudent() throws JsonProcessingException {
when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
when(graduationStatusRepository.save(responseGraduationStatus)).thenReturn(responseGraduationStatus);

StudentOptionalProgramEntity studentOptionalProgramEntity = new StudentOptionalProgramEntity();
studentOptionalProgramEntity.setId(UUID.randomUUID());
studentOptionalProgramEntity.setStudentID(studentID);
studentOptionalProgramEntity.setOptionalProgramCompletionDate(new Date(System.currentTimeMillis()));

when(gradStudentOptionalProgramRepository.findByStudentID(studentID)).thenReturn(List.of(studentOptionalProgramEntity));
doNothing().when(historyService).createStudentOptionalProgramHistory(any(), any());

var response = graduationStatusService.undoCompletionStudent(studentID, ungradReasonCode,ungradReasonDesc, "accessToken");
assertThat(response).isNotNull();

Expand Down

0 comments on commit a063c59

Please sign in to comment.