Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2465 - Delete a student and related data #313

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading