diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index 900cecbe..e8ed5be9 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -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 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); @@ -1395,13 +1398,13 @@ public Integer archiveStudents(long batchId, List schoolOfRecords, Strin if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) { List 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 graduationStudentRecordGuids = graduationStatusRepository.findByStudentStatus(recordStudentStatus); for(UUID graduationStudentRecordGuid: graduationStudentRecordGuids) { - saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC"); + saveStudentHistoryRecordDistributionRun(graduationStudentRecordGuid, batchId, "USERSTUDARC", "ARC"); } return graduationStatusRepository.archiveStudents(recordStudentStatus, "ARC", batchId); } diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java index d8d8f920..7fc023b2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java @@ -53,8 +53,7 @@ @ActiveProfiles("test") public class GraduationStatusServiceTest { - @Autowired - EducGradStudentApiConstants constants; + @Autowired EducGradStudentApiConstants constants; @Autowired GraduationStatusService graduationStatusService; @MockBean GradStudentService gradStudentService; @MockBean HistoryService historyService; @@ -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(); @@ -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