diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/controller/TraxCommonController.java b/api/src/main/java/ca/bc/gov/educ/api/trax/controller/TraxCommonController.java index 01fa1ce9..f3ba82a3 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/controller/TraxCommonController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/controller/TraxCommonController.java @@ -26,8 +26,7 @@ @RequestMapping(EducGradTraxApiConstants.GRAD_TRAX_COMMON_URL_MAPPING) @OpenAPIDefinition(info = @Info(title = "API for TRAX Data.", description = "This API is for TRAX.", version = "1")) public class TraxCommonController { - private static Logger logger = LoggerFactory.getLogger(TraxCommonController.class); - private static final String BEARER = "Bearer "; + private static final Logger logger = LoggerFactory.getLogger(TraxCommonController.class); @Autowired TraxCommonService traxCommonService; @@ -116,8 +115,8 @@ public ResponseEntity saveTraxStudentNo(@RequestBody TraxStudentN @PutMapping(EducGradTraxApiConstants.PUT_SAVE_TRAX_STUDENT_NO_MAPPING) @PreAuthorize(PermissionsConstants.UPDATE_GRAD_TRAX_STUDENT_DATA) @Operation(summary = "Update TraxStudentNo status", description = "Update TraxStudentNo status", tags = {"Student"}) - public ResponseEntity updateTraxStudentNo(@PathVariable String pen) { + public ResponseEntity updateTraxStudentNo(@RequestBody TraxStudentNo traxStudentNo) { logger.debug("updateTraxStudentNo : "); - return response.GET(traxCommonService.updateTraxStudentNo(pen)); + return response.GET(traxCommonService.updateTraxStudentNo(traxStudentNo)); } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/service/TraxCommonService.java b/api/src/main/java/ca/bc/gov/educ/api/trax/service/TraxCommonService.java index 76c479ff..db6d7305 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/service/TraxCommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/service/TraxCommonService.java @@ -174,11 +174,12 @@ public TraxStudentNo saveTraxStudentNo(TraxStudentNo traxStudentNo) { } @Transactional - public TraxStudentNo updateTraxStudentNo(String pen) { - Optional optional = traxStudentNoRepository.findById(pen); + public TraxStudentNo updateTraxStudentNo(TraxStudentNo traxStudentNo) { + Optional optional = traxStudentNoRepository.findById(traxStudentNo.getStudNo()); if (optional.isPresent()) { TraxStudentNoEntity entity = optional.get(); - entity.setStatus(null); + entity.setStatus(traxStudentNo.getStatus()); + entity.setReason(traxStudentNo.getReason()); return traxStudentNoTransformer.transformToDTO(traxStudentNoRepository.save(entity)); } return null; diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/controller/TraxCommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/controller/TraxCommonControllerTest.java index 8d1fed18..ce089970 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/trax/controller/TraxCommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/trax/controller/TraxCommonControllerTest.java @@ -27,13 +27,13 @@ public class TraxCommonControllerTest { @Mock ResponseHelper response; - + @InjectMocks private TraxCommonController traxCommonController; @Mock GradValidation validation; - + @Mock MessageHelper messagesHelper; @@ -151,9 +151,9 @@ public void testUpdateTraxStudentNo() { TraxStudentNo obj = new TraxStudentNo(); obj.setStudNo(pen); - Mockito.when(traxCommonService.updateTraxStudentNo(pen)).thenReturn(obj); - traxCommonController.updateTraxStudentNo(pen); - Mockito.verify(traxCommonService).updateTraxStudentNo(pen); + Mockito.when(traxCommonService.updateTraxStudentNo(obj)).thenReturn(obj); + traxCommonController.updateTraxStudentNo(obj); + Mockito.verify(traxCommonService).updateTraxStudentNo(obj); } // @Test diff --git a/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java index c27598f6..d9a33f8f 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/trax/service/TraxCommonServiceTest.java @@ -688,7 +688,7 @@ public void updateSaveTraxStudentNo() { when(traxStudentNoRepository.findById(traxStudentNo.getStudNo())).thenReturn(Optional.of(traxStudentNoEntity)); when(traxStudentNoRepository.save(traxStudentNoEntity)).thenReturn(traxStudentNoEntity); - var result = traxCommonService.updateTraxStudentNo(traxStudentNo.getStudNo()); + var result = traxCommonService.updateTraxStudentNo(traxStudentNo); assertThat(result).isNotNull(); assertThat(traxStudentNo.getStudNo()).isEqualTo(result.getStudNo()); assertThat(traxStudentNo.getStatus()).isNull();