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 #308

Merged
merged 6 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 @@ -112,4 +112,12 @@ public ResponseEntity<TraxStudentNo> saveTraxStudentNo(@RequestBody TraxStudentN
logger.debug("saveTraxStudentNo : ");
return response.GET(traxCommonService.saveTraxStudentNo(traxStudentNo));
}

@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) {
logger.debug("updateTraxStudentNo : ");
return response.GET(traxCommonService.updateTraxStudentNo(pen));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ public TraxStudentNo saveTraxStudentNo(TraxStudentNo traxStudentNo) {
return traxStudentNo;
}

@Transactional
public TraxStudentNo updateTraxStudentNo(String pen) {
Optional<TraxStudentNoEntity> optional = traxStudentNoRepository.findById(pen);
if (optional.isPresent()) {
TraxStudentNoEntity entity = optional.get();
entity.setStatus(null);
return traxStudentNoTransformer.transformToDTO(traxStudentNoRepository.save(entity));
}
return null;
}

private List<ConvGradStudent> buildConversionGradStudents(List<Object[]> traxStudents) {
List<ConvGradStudent> students = new ArrayList<>();
traxStudents.forEach(result -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class EducGradTraxApiConstants {
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 POST_SAVE_TRAX_STUDENT_NO_MAPPING = "/trax-student-no";
public static final String PUT_SAVE_TRAX_STUDENT_NO_MAPPING = "/trax-student-no/{pen}";

//Default Attribute value constants
public static final String DEFAULT_CREATED_BY = "API_GRAD_TRAX";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ 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(pen)).thenReturn(obj);
traxCommonController.updateTraxStudentNo(pen);
Mockito.verify(traxCommonService).updateTraxStudentNo(pen);
}

// @Test
// public void testGetStudentIsGraduatedByPen() {
// Mockito.when(traxCommonService.isGraduatedStudent("123456789")).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,23 @@ 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.getStudNo());
assertThat(result).isNotNull();
assertThat(traxStudentNo.getStudNo()).isEqualTo(result.getStudNo());
assertThat(traxStudentNo.getStatus()).isNull();
}

// @Test
// public void testStudentIsNotGraduated() {
// // Student is graduated or not
Expand Down
Loading