Skip to content

Commit

Permalink
Merge pull request #313 from bcgov/GRAD2-2465-km
Browse files Browse the repository at this point in the history
GRAD2-2465 - Delete a student and related data
  • Loading branch information
arybakov-cgi authored Mar 18, 2024
2 parents 4504aec + c040273 commit 99ef6a2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,8 +115,8 @@ public ResponseEntity<TraxStudentNo> 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<TraxStudentNo> updateTraxStudentNo(@PathVariable String pen) {
public ResponseEntity<TraxStudentNo> updateTraxStudentNo(@RequestBody TraxStudentNo traxStudentNo) {
logger.debug("updateTraxStudentNo : ");
return response.GET(traxCommonService.updateTraxStudentNo(pen));
return response.GET(traxCommonService.updateTraxStudentNo(traxStudentNo));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ public TraxStudentNo saveTraxStudentNo(TraxStudentNo traxStudentNo) {
}

@Transactional
public TraxStudentNo updateTraxStudentNo(String pen) {
Optional<TraxStudentNoEntity> optional = traxStudentNoRepository.findById(pen);
public TraxStudentNo updateTraxStudentNo(TraxStudentNo traxStudentNo) {
Optional<TraxStudentNoEntity> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class TraxCommonControllerTest {

@Mock
ResponseHelper response;

@InjectMocks
private TraxCommonController traxCommonController;

@Mock
GradValidation validation;

@Mock
MessageHelper messagesHelper;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 99ef6a2

Please sign in to comment.