From bb85825382732310e0ce1552b422eb30387f8baa Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Mon, 18 Mar 2024 15:52:17 -0600 Subject: [PATCH] Revert "GRAD2-2465 - Delete a student and related data" --- .../trax/controller/TraxCommonController.java | 13 +++---------- .../api/trax/service/TraxCommonService.java | 12 ------------ .../api/trax/util/EducGradTraxApiConstants.java | 2 +- .../controller/TraxCommonControllerTest.java | 15 ++------------- .../api/trax/service/TraxCommonServiceTest.java | 17 ----------------- 5 files changed, 6 insertions(+), 53 deletions(-) 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 b60135cb..df2d8823 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,7 +26,8 @@ @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 final Logger logger = LoggerFactory.getLogger(TraxCommonController.class); + private static Logger logger = LoggerFactory.getLogger(TraxCommonController.class); + private static final String BEARER = "Bearer "; @Autowired TraxCommonService traxCommonService; @@ -104,19 +105,11 @@ public ResponseEntity> getCourseRequirements() { return response.GET(traxCommonService.loadGradCourseRequirementsDataFromTrax()); } - @PostMapping(EducGradTraxApiConstants.SAVE_TRAX_STUDENT_NO_MAPPING) + @PostMapping(EducGradTraxApiConstants.POST_SAVE_TRAX_STUDENT_NO_MAPPING) @PreAuthorize(PermissionsConstants.UPDATE_GRAD_TRAX_STUDENT_DATA) @Operation(summary = "Save TraxStudentNo", description = "Save TraxStudentNo", tags = {"Student"}) public ResponseEntity saveTraxStudentNo(@RequestBody TraxStudentNo traxStudentNo) { logger.debug("saveTraxStudentNo : "); return response.GET(traxCommonService.saveTraxStudentNo(traxStudentNo)); } - - @PutMapping(EducGradTraxApiConstants.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(@RequestBody TraxStudentNo traxStudentNo) { - logger.debug("updateTraxStudentNo : "); - 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 db6d7305..7ac0cfa9 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 @@ -173,18 +173,6 @@ public TraxStudentNo saveTraxStudentNo(TraxStudentNo traxStudentNo) { return traxStudentNo; } - @Transactional - public TraxStudentNo updateTraxStudentNo(TraxStudentNo traxStudentNo) { - Optional optional = traxStudentNoRepository.findById(traxStudentNo.getStudNo()); - if (optional.isPresent()) { - TraxStudentNoEntity entity = optional.get(); - entity.setStatus(traxStudentNo.getStatus()); - entity.setReason(traxStudentNo.getReason()); - return traxStudentNoTransformer.transformToDTO(traxStudentNoRepository.save(entity)); - } - return null; - } - private List buildConversionGradStudents(List traxStudents) { List students = new ArrayList<>(); traxStudents.forEach(result -> { diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java index 936e99ae..5b54f029 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/util/EducGradTraxApiConstants.java @@ -70,7 +70,7 @@ public class EducGradTraxApiConstants { public static final String GET_TOTAL_NUMBER_OF_TRAX_STUDENT_NO_LIST_MAPPING = "/student-no-list/total-count"; public static final String GET_COURSE_RESTRICTION_LIST_MAPPING = "/course-restrictions"; public static final String GET_COURSE_REQUIREMENT_LIST_MAPPING = "/course-requirements"; - public static final String SAVE_TRAX_STUDENT_NO_MAPPING = "/trax-student-no"; + public static final String POST_SAVE_TRAX_STUDENT_NO_MAPPING = "/trax-student-no"; //Default Attribute value constants public static final String DEFAULT_CREATED_BY = "API_GRAD_TRAX"; 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 ce089970..5a361d0f 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; @@ -145,17 +145,6 @@ public void testSaveTraxStudentNo() { Mockito.verify(traxCommonService).saveTraxStudentNo(obj); } - @Test - public void testUpdateTraxStudentNo() { - final String pen = "123456789"; - TraxStudentNo obj = new TraxStudentNo(); - obj.setStudNo(pen); - - Mockito.when(traxCommonService.updateTraxStudentNo(obj)).thenReturn(obj); - traxCommonController.updateTraxStudentNo(obj); - Mockito.verify(traxCommonService).updateTraxStudentNo(obj); - } - // @Test // public void testGetStudentIsGraduatedByPen() { // Mockito.when(traxCommonService.isGraduatedStudent("123456789")).thenReturn(true); 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 d9a33f8f..5435d6af 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 @@ -677,23 +677,6 @@ public void testSaveTraxStudentNo() { assertThat(traxStudentNo.getStatus()).isEqualTo(result.getStatus()); } - @Test - public void updateSaveTraxStudentNo() { - TraxStudentNo traxStudentNo = new TraxStudentNo(); - traxStudentNo.setStudNo("123456789"); - traxStudentNo.setStatus(null); - - TraxStudentNoEntity traxStudentNoEntity = traxStudentNoTransformer.transformToEntity(traxStudentNo); - - when(traxStudentNoRepository.findById(traxStudentNo.getStudNo())).thenReturn(Optional.of(traxStudentNoEntity)); - when(traxStudentNoRepository.save(traxStudentNoEntity)).thenReturn(traxStudentNoEntity); - - var result = traxCommonService.updateTraxStudentNo(traxStudentNo); - assertThat(result).isNotNull(); - assertThat(traxStudentNo.getStudNo()).isEqualTo(result.getStudNo()); - assertThat(traxStudentNo.getStatus()).isNull(); - } - // @Test // public void testStudentIsNotGraduated() { // // Student is graduated or not