From df9d0f069bd98bd6a481c988cc20953d1252b860 Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 19 Aug 2024 12:15:06 -0600 Subject: [PATCH 1/2] Fix username for student history --- .../gradstudent/controller/GraduationStatusController.java | 4 ++-- .../api/gradstudent/service/GraduationStatusService.java | 6 +++--- .../controller/GraduationStatusControllerTest.java | 6 +++--- .../gradstudent/service/GraduationStatusServiceTest.java | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java index ea01799e..cf83a39f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java @@ -349,9 +349,9 @@ public ResponseEntity> getStudentsForYearlyRun() { @PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT) @Operation(summary = "Save Student Grad Status by Student ID for projected run", description = "Save Student Grad Status by Student ID for projected run", tags = { "Student Graduation Status" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - public ResponseEntity saveStudentGradStatusDistributionRun(@PathVariable String studentID, @RequestParam(required = false) Long batchId,@RequestParam(required = false) String activityCode) { + public ResponseEntity saveStudentGradStatusDistributionRun(@PathVariable String studentID, @RequestParam(required = false) Long batchId, @RequestParam(required = false) String activityCode, @RequestParam(required = false) String username) { logger.debug("Save Distribution student Grad Status for Student ID"); - GraduationStudentRecord gradRecord = gradStatusService.saveStudentRecordDistributionRun(UUID.fromString(studentID),batchId,activityCode); + GraduationStudentRecord gradRecord = gradStatusService.saveStudentRecordDistributionRun(UUID.fromString(studentID),batchId,activityCode,username); return response.GET(gradRecord); } 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 745211b0..fd342bda 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 @@ -1219,12 +1219,12 @@ public boolean restoreGradStudentRecord(UUID studentID,boolean isGraduated) { } @Retry(name = "generalpostcall") - public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID, Long batchId, String activityCode) { + public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID, Long batchId, String activityCode, String username) { Optional gradStatusOptional = graduationStatusRepository.findById(studentID); if (gradStatusOptional.isPresent()) { GraduationStudentRecordEntity gradEntity = gradStatusOptional.get(); - gradEntity.setUpdateUser(null); - gradEntity.setUpdateDate(null); + gradEntity.setUpdateUser(username); + gradEntity.setUpdateDate(LocalDateTime.now()); gradEntity.setBatchId(batchId); gradEntity = graduationStatusRepository.saveAndFlush(gradEntity); historyService.createStudentHistory(gradEntity, activityCode); diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java index 040e6dd7..b3015da2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java @@ -438,9 +438,9 @@ public void testSaveStudentRecord_DsitributionRun() { graduationStatus.setSchoolOfRecord("12345678"); graduationStatus.setRecalculateGradStatus("Y"); - Mockito.when(graduationStatusService.saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE")).thenReturn(graduationStatus); - graduationStatusController.saveStudentGradStatusDistributionRun(studentID.toString(),null,"ACTIVITYCODE"); - Mockito.verify(graduationStatusService).saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE"); + Mockito.when(graduationStatusService.saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE", "USER")).thenReturn(graduationStatus); + graduationStatusController.saveStudentGradStatusDistributionRun(studentID.toString(),null,"ACTIVITYCODE", "USER"); + Mockito.verify(graduationStatusService).saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE", "USER"); } @Test 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 275b7ee6..0928f8dd 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 @@ -2214,7 +2214,7 @@ public void testSaveStudentRecord_DistributionRun() { when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity)); when(graduationStatusRepository.saveAndFlush(graduationStatusEntity2)).thenReturn(graduationStatusEntity2); - GraduationStudentRecord res =graduationStatusService.saveStudentRecordDistributionRun(studentID, batchId, "ACTIVITYCODE"); + GraduationStudentRecord res =graduationStatusService.saveStudentRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "USER"); assertThat(res).isNotNull(); } From 6b79c6e2644f42bd0e2a62576e6acb6367983f1b Mon Sep 17 00:00:00 2001 From: arybakov Date: Mon, 19 Aug 2024 12:25:04 -0600 Subject: [PATCH 2/2] Fix username for student history --- .../educ/api/gradstudent/service/GraduationStatusService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fd342bda..e865c800 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 @@ -1223,7 +1223,7 @@ public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID, Optional gradStatusOptional = graduationStatusRepository.findById(studentID); if (gradStatusOptional.isPresent()) { GraduationStudentRecordEntity gradEntity = gradStatusOptional.get(); - gradEntity.setUpdateUser(username); + gradEntity.setUpdateUser(StringUtils.isNotBlank(username) && !StringUtils.equalsIgnoreCase(username, "null") ? username : null); gradEntity.setUpdateDate(LocalDateTime.now()); gradEntity.setBatchId(batchId); gradEntity = graduationStatusRepository.saveAndFlush(gradEntity);