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-2280: task is completed. #567

Merged
merged 1 commit into from
Aug 17, 2023
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 @@ -264,4 +264,16 @@ public ResponseEntity<List<String>> getDistrictReportDataForYearEndNonGrad() {
logger.debug("getSchoolReportDataForYearEndNonGrad :");
return response.GET(gradStudentReportService.getGradDistrictsForNonGradYearEndReport());
}

@PostMapping(EducGradStudentApiConstants.GET_DECEASED_STUDENT_ID)
@PreAuthorize(PermissionsConstants.READ_GRAD_STUDENT_STATUS)
@Operation(summary = "Find Deceased Student IDs by List of GUIDs",
description = "Find Deceased Student IDs by List of GUIDs", tags = {"Student Graduation Data for School Reports"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "204", description = "NO CONTENT.")})
public ResponseEntity<List<UUID>> getDeceasedStudentIDs(@RequestBody List<UUID> studentIds) {
logger.debug("getDeceasedStudentIDs :");
return response.GET(commonService.getDeceasedStudentIDs(studentIds));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ void updateStudentGuidPenXrefRecord(
@Query(value="select STUDENT_GUID from STUDENT_GUID_PEN_XREF \n"
+ "where STUDENT_PEN = :pen", nativeQuery = true)
byte[] findStudentID(@Param("pen") String pen);

@Query("select c.studentID from GraduationStudentRecordEntity c where c.studentStatus = :statusCode and c.studentID in :studentIDList")
List<UUID> filterGivenStudentsByStatusCode(@Param("studentIDList") List<UUID> studentIDs, @Param("statusCode") String statusCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,9 @@ public HistoryActivity getSpecificHistoryActivityCode(String activityCode) {
return null;
}
}

@Transactional
public List<UUID> getDeceasedStudentIDs(List<UUID> studentIDs) {
return gradStudentService.getStudentIDsByStatusCode(studentIDs, "DEC");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,12 @@ public Student addNewPenFromStudentAPI(StudentCreate student, String accessToken
.body(BodyInserters.fromValue(student))
.retrieve().bodyToMono(Student.class).block();
}

@Transactional
public List<UUID> getStudentIDsByStatusCode(List<UUID> studentIDs, String statusCode) {
if (StringUtils.isBlank(statusCode) || studentIDs.isEmpty()) {
return new ArrayList<>();
}
return graduationStatusRepository.filterGivenStudentsByStatusCode(studentIDs, statusCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class EducGradStudentApiConstants {
public static final String GET_ALL_STUDENT_NON_GRAD_REPORT_DATA_MINCODE = "/studentnongradreportdata/{mincode}";
public static final String GET_ALL_SCHOOL_NON_GRAD_REPORT_DATA = "/schoolnongradreportdata";
public static final String GET_ALL_DISTRICT_NON_GRAD_REPORT_DATA = "/districtnongradreportdata";
public static final String GET_DECEASED_STUDENT_ID = "/deceasedstudentid";

public static final String RETURN_TO_ORIGINAL_STATE = "/algorithmerror/{studentID}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

Expand All @@ -38,7 +39,7 @@ public class CommonControllerTest {
@Mock GradValidation validation;

@InjectMocks
private CommonController codeController;
private CommonController commonController;

@Test
public void testGetReportGradStudentDataByMincode() {
Expand All @@ -51,11 +52,11 @@ public void testGetReportGradStudentDataByMincode() {
reportGradStudentData.setMincode("03939000");

Mockito.when(gradStudentReportService.getGradStudentDataByMincode(reportGradStudentData.getMincode())).thenReturn(List.of(reportGradStudentData));
codeController.getStudentReportDataByMincode(reportGradStudentData.getMincode());
commonController.getStudentReportDataByMincode(reportGradStudentData.getMincode());
Mockito.verify(gradStudentReportService).getGradStudentDataByMincode(reportGradStudentData.getMincode());

Mockito.when(gradStudentReportService.getGradSchoolsForNonGradYearEndReport()).thenReturn(List.of(reportGradStudentData.getMincode()));
codeController.getSchoolReportDataForYearEndNonGrad();
commonController.getSchoolReportDataForYearEndNonGrad();
Mockito.verify(gradStudentReportService).getGradSchoolsForNonGradYearEndReport();
}

Expand All @@ -70,11 +71,11 @@ public void testGetReportGradStudentDataByDistcode() {
reportGradStudentData.setMincode("005");

Mockito.when(gradStudentReportService.getGradStudentDataByMincode(reportGradStudentData.getMincode())).thenReturn(List.of(reportGradStudentData));
codeController.getStudentReportDataByMincode(reportGradStudentData.getMincode());
commonController.getStudentReportDataByMincode(reportGradStudentData.getMincode());
Mockito.verify(gradStudentReportService).getGradStudentDataByMincode(reportGradStudentData.getMincode());

Mockito.when(gradStudentReportService.getGradDistrictsForNonGradYearEndReport()).thenReturn(List.of(reportGradStudentData.getMincode()));
codeController.getDistrictReportDataForYearEndNonGrad();
commonController.getDistrictReportDataForYearEndNonGrad();
Mockito.verify(gradStudentReportService).getGradDistrictsForNonGradYearEndReport();
}

Expand All @@ -90,15 +91,15 @@ public void testGetReportGradStudentData() {
reportGradStudentData.setMincode("005");

Mockito.when(gradStudentReportService.getGradStudentDataByStudentGuids(List.of(reportGradStudentData.getGraduationStudentRecordId()))).thenReturn(List.of(reportGradStudentData));
codeController.getStudentReportData(List.of(reportGradStudentData.getGraduationStudentRecordId()));
commonController.getStudentReportData(List.of(reportGradStudentData.getGraduationStudentRecordId()));
Mockito.verify(gradStudentReportService).getGradStudentDataByStudentGuids(List.of(reportGradStudentData.getGraduationStudentRecordId()));

Mockito.when(gradStudentReportService.getGradStudentDataForNonGradYearEndReport(reportGradStudentData.getMincode())).thenReturn(List.of(reportGradStudentData));
codeController.getStudentReportDataForYearEndNonGrad(reportGradStudentData.getMincode());
commonController.getStudentReportDataForYearEndNonGrad(reportGradStudentData.getMincode());
Mockito.verify(gradStudentReportService).getGradStudentDataForNonGradYearEndReport(reportGradStudentData.getMincode());

Mockito.when(gradStudentReportService.getGradStudentDataForNonGradYearEndReport()).thenReturn(List.of(reportGradStudentData));
codeController.getStudentReportDataForYearEndNonGrad();
commonController.getStudentReportDataForYearEndNonGrad();
Mockito.verify(gradStudentReportService).getGradStudentDataForNonGradYearEndReport();
}

Expand All @@ -107,7 +108,7 @@ public void testGetSpecificHistoryActivityCode() {
HistoryActivity activity = new HistoryActivity();
activity.setCode("01");
Mockito.when(commonService.getSpecificHistoryActivityCode(activity.getCode())).thenReturn(activity);
codeController.getSpecificHistoryActivityCode(activity.getCode());
commonController.getSpecificHistoryActivityCode(activity.getCode());
Mockito.verify(commonService).getSpecificHistoryActivityCode(activity.getCode());
}

Expand All @@ -116,15 +117,15 @@ public void testGetAllHistoryActivityCode() {
HistoryActivity activity = new HistoryActivity();
activity.setCode("01");
Mockito.when(commonService.getAllHistoryActivityCodeList()).thenReturn(List.of(activity));
codeController.getAllHistoryActivityCodeList();
commonController.getAllHistoryActivityCodeList();
Mockito.verify(commonService).getAllHistoryActivityCodeList();
}

@Test
public void testGetStudentCareerProgram() {
final String programCode = "2018-EN";
Mockito.when(commonService.getStudentCareerProgram(programCode)).thenReturn(true);
codeController.getStudentCareerProgram(programCode);
commonController.getStudentCareerProgram(programCode);
Mockito.verify(commonService).getStudentCareerProgram(programCode);
}

Expand Down Expand Up @@ -154,7 +155,7 @@ public void testGetAllStudentCareerProgramsList() {


Mockito.when(commonService.getAllGradStudentCareerProgramList(pen, "accessToken")).thenReturn(gradStudentCareerProgramList);
codeController.getAllStudentCareerProgramsList(pen, "accessToken");
commonController.getAllStudentCareerProgramsList(pen, "accessToken");
Mockito.verify(commonService).getAllGradStudentCareerProgramList(pen, "accessToken");
}

Expand All @@ -180,7 +181,7 @@ public void testGetAllStudentNotes() {
allNotesList.add(note2);

Mockito.when(commonService.getAllStudentNotes(studentID)).thenReturn(allNotesList);
codeController.getAllStudentNotes(studentID.toString());
commonController.getAllStudentNotes(studentID.toString());
Mockito.verify(commonService).getAllStudentNotes(studentID);
}

Expand All @@ -195,7 +196,7 @@ public void testSaveStudentNotes() {
studentNote.setNote("Test Note Body");

Mockito.when(commonService.saveStudentNote(studentNote)).thenReturn(studentNote);
codeController.saveStudentNotes(studentNote);
commonController.saveStudentNotes(studentNote);
Mockito.verify(commonService).saveStudentNote(studentNote);
}

Expand All @@ -205,92 +206,92 @@ public void testDeleteNotes() {
final UUID noteID = UUID.randomUUID();

Mockito.when(commonService.deleteNote(noteID)).thenReturn(1);
codeController.deleteNotes(noteID.toString());
commonController.deleteNotes(noteID.toString());
Mockito.verify(commonService).deleteNote(noteID);
}

@Test
public void testGetAllStudentStatusCodeList() {
List<StudentStatus> studentStatusList = new ArrayList<>();
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
studentStatusList.add(obj);
obj = new StudentStatus();
obj.setCode("CC");
obj.setDescription("Courses not complete");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
studentStatusList.add(obj);
Mockito.when(commonService.getAllStudentStatusCodeList()).thenReturn(studentStatusList);
codeController.getAllStudentStatusCodeList();
Mockito.verify(commonService).getAllStudentStatusCodeList();
}
@Test
public void testGetSpecificStudentStatusCode() {
String requirementType = "DC";
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
Mockito.when(commonService.getSpecificStudentStatusCode(requirementType)).thenReturn(obj);
codeController.getSpecificStudentStatusCode(requirementType);
Mockito.verify(commonService).getSpecificStudentStatusCode(requirementType);
}
@Test
public void testGetSpecificStudentStatusCode_noContent() {
String requirementType = "AB";
Mockito.when(commonService.getSpecificStudentStatusCode(requirementType)).thenReturn(null);
codeController.getSpecificStudentStatusCode(requirementType);
Mockito.verify(commonService).getSpecificStudentStatusCode(requirementType);
}
@Test
public void testCreateStudentStatus() {
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
Mockito.when(commonService.createStudentStatus(obj)).thenReturn(obj);
codeController.createStudentStatus(obj);
Mockito.verify(commonService).createStudentStatus(obj);
}
@Test
public void testUpdateStudentStatus() {
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
Mockito.when(commonService.updateStudentStatus(obj)).thenReturn(obj);
codeController.updateStudentStatusCode(obj);
Mockito.verify(commonService).updateStudentStatus(obj);
}
@Test
public void testDeleteStudentStatus() {
String statusCode = "DC";
Mockito.when(commonService.deleteStudentStatus(statusCode)).thenReturn(1);
codeController.deleteStudentStatusCodes(statusCode);
Mockito.verify(commonService).deleteStudentStatus(statusCode);
}
public void testGetAllStudentStatusCodeList() {
List<StudentStatus> studentStatusList = new ArrayList<>();
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
studentStatusList.add(obj);
obj = new StudentStatus();
obj.setCode("CC");
obj.setDescription("Courses not complete");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
studentStatusList.add(obj);
Mockito.when(commonService.getAllStudentStatusCodeList()).thenReturn(studentStatusList);
commonController.getAllStudentStatusCodeList();
Mockito.verify(commonService).getAllStudentStatusCodeList();
}

@Test
public void testGetSpecificStudentStatusCode() {
String requirementType = "DC";
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
Mockito.when(commonService.getSpecificStudentStatusCode(requirementType)).thenReturn(obj);
commonController.getSpecificStudentStatusCode(requirementType);
Mockito.verify(commonService).getSpecificStudentStatusCode(requirementType);
}

@Test
public void testGetSpecificStudentStatusCode_noContent() {
String requirementType = "AB";
Mockito.when(commonService.getSpecificStudentStatusCode(requirementType)).thenReturn(null);
commonController.getSpecificStudentStatusCode(requirementType);
Mockito.verify(commonService).getSpecificStudentStatusCode(requirementType);
}

@Test
public void testCreateStudentStatus() {
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
Mockito.when(commonService.createStudentStatus(obj)).thenReturn(obj);
commonController.createStudentStatus(obj);
Mockito.verify(commonService).createStudentStatus(obj);
}

@Test
public void testUpdateStudentStatus() {
StudentStatus obj = new StudentStatus();
obj.setCode("DC");
obj.setDescription("Data Correction by School");
obj.setCreateUser("GRADUATION");
obj.setUpdateUser("GRADUATION");
obj.setCreateDate(LocalDateTime.now());
obj.setUpdateDate(LocalDateTime.now());
Mockito.when(commonService.updateStudentStatus(obj)).thenReturn(obj);
commonController.updateStudentStatusCode(obj);
Mockito.verify(commonService).updateStudentStatus(obj);
}

@Test
public void testDeleteStudentStatus() {
String statusCode = "DC";
Mockito.when(commonService.deleteStudentStatus(statusCode)).thenReturn(1);
commonController.deleteStudentStatusCodes(statusCode);
Mockito.verify(commonService).deleteStudentStatus(statusCode);
}

@Test
public void testgetStudentGradStatusForAlgorithm() {
Expand All @@ -311,6 +312,17 @@ public void testgetStudentGradStatusForAlgorithm() {
data.setGraduationStudentRecord(gsr);

Mockito.when(commonService.getGradStudentAlgorithmData(studentID,"accessToken")).thenReturn(data);
codeController.getStudentGradStatusForAlgorithm(studentID, "accessToken");
commonController.getStudentGradStatusForAlgorithm(studentID, "accessToken");
}

@Test
public void testGetDeceasedStudentIDs() {
UUID studentID1 = UUID.randomUUID();
UUID studentID2 = UUID.randomUUID();

Mockito.when(commonService.getDeceasedStudentIDs(Arrays.asList(studentID1, studentID2))).thenReturn(Arrays.asList(studentID1, studentID2));
commonController.getDeceasedStudentIDs(Arrays.asList(studentID1, studentID2));
Mockito.verify(commonService).getDeceasedStudentIDs(Arrays.asList(studentID1, studentID2));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,15 @@ public void testGetGradStudentAlgorithmData() {
GradStudentAlgorithmData data = commonService.getGradStudentAlgorithmData(studentID.toString(),null);
assertThat(data).isNotNull();
}

@Test
public void testGetDeceasedStudentIDs() {
UUID studentID1 = UUID.randomUUID();
UUID studentID2 = UUID.randomUUID();

when(gradStudentService.getStudentIDsByStatusCode(Arrays.asList(studentID1, studentID2), "DEC")).thenReturn(Arrays.asList(studentID1, studentID2));
List<UUID> results = commonService.getDeceasedStudentIDs(Arrays.asList(studentID1, studentID2));

assertThat(results).isNotEmpty();
}
}
Loading
Loading