Skip to content

Commit

Permalink
GRAD2-2283 (#672)
Browse files Browse the repository at this point in the history
* GRAD2-2283
Student Archive Process - Backend endpoints To COMPLETE

* GRAD2-2283
Student Archive Process - Backend endpoints To COMPLETE

* Tests fix
  • Loading branch information
arybakov-cgi authored Aug 16, 2024
1 parent 4fa5246 commit 243684b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,13 @@ public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID,
}

@Retry(name = "generalpostcall")
public void saveStudentHistoryRecordDistributionRun(UUID studentID, Long batchId, String activityCode) {
public void saveStudentHistoryRecordDistributionRun(UUID studentID, Long batchId, String activityCode, String studentStatus) {
Optional<GraduationStudentRecordEntity> gradStatusOptional = graduationStatusRepository.findById(studentID);
if (gradStatusOptional.isPresent()) {
GraduationStudentRecordEntity gradEntity = gradStatusOptional.get();
if(StringUtils.isNotBlank(studentStatus)) {
gradEntity.setStudentStatus(studentStatus);
}
gradEntity.setUpdateUser(null);
gradEntity.setUpdateDate(null);
gradEntity.setBatchId(batchId);
Expand Down Expand Up @@ -1395,13 +1398,13 @@ public Integer archiveStudents(long batchId, List<String> schoolOfRecords, Strin
if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) {
List<UUID> graduationStudentRecordGuids = graduationStatusRepository.findBySchoolOfRecordInAndStudentStatus(schoolOfRecords, recordStudentStatus);
for(UUID graduationStudentRecordGuid: graduationStudentRecordGuids) {
saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC");
saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC", "ARC");
}
return graduationStatusRepository.archiveStudents(schoolOfRecords, recordStudentStatus, "ARC", batchId);
} else {
List<UUID> graduationStudentRecordGuids = graduationStatusRepository.findByStudentStatus(recordStudentStatus);
for(UUID graduationStudentRecordGuid: graduationStudentRecordGuids) {
saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC");
saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC", "ARC");
}
return graduationStatusRepository.archiveStudents(recordStudentStatus, "ARC", batchId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
@ActiveProfiles("test")
public class GraduationStatusServiceTest {

@Autowired
EducGradStudentApiConstants constants;
@Autowired EducGradStudentApiConstants constants;
@Autowired GraduationStatusService graduationStatusService;
@MockBean GradStudentService gradStudentService;
@MockBean HistoryService historyService;
Expand Down Expand Up @@ -2220,6 +2219,9 @@ public void testSaveStudentRecord_DistributionRun() {

@Test
public void testSaveStudentRecord_DistributionRun_2() {

GraduationStatusService graduationStatusServiceMock = mock(GraduationStatusService.class);

UUID studentID = new UUID(1, 1);
Long batchId = null;
GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
Expand All @@ -2230,9 +2232,13 @@ public void testSaveStudentRecord_DistributionRun_2() {

when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));

graduationStatusService.saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE");
doNothing().when(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "ARC");
graduationStatusServiceMock.saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "ARC");
Mockito.verify(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "ARC");

assertThat(graduationStatusEntity).isNotNull();
doNothing().when(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", null);
graduationStatusServiceMock.saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", null);
Mockito.verify(graduationStatusServiceMock).saveStudentHistoryRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", null);
}

@Test
Expand Down

0 comments on commit 243684b

Please sign in to comment.