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

Hotfix/alex grad2 2855 #536

Merged
merged 2 commits into from
Jul 5, 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 @@ -307,7 +307,8 @@ private List<GraduationStudentRecord> filterStudentList(List<GraduationStudentRe
}

private int processGradRegReport(School schoolObj, List<Student> stdList, String mincode, String accessToken, int numberOfReports) {
if(stdList != null && !stdList.isEmpty()) {
Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolObj.getMincode());
if(studentsCount > 0) {
ReportData gradReport = getReportDataObj(schoolObj, stdList);
createAndSaveSchoolReportGradRegReport(gradReport, mincode, accessToken);
numberOfReports++;
Expand All @@ -316,14 +317,29 @@ private int processGradRegReport(School schoolObj, List<Student> stdList, String
}

private int processNonGradRegReport(School schoolObj, List<Student> stdList, String mincode, int numberOfReports) {
if(stdList != null && !stdList.isEmpty()) {
Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolObj.getMincode());
if(studentsCount > 0) {
ReportData gradReport = getReportDataObj(schoolObj, stdList);
createAndSaveSchoolReportNonGradRegReport(gradReport, mincode);
numberOfReports++;
}
return numberOfReports;
}

private int processStudentNonGradPrjReport(School schoolObj, List<Student> stdList, String mincode, String accessToken, int numberOfReports) {
Integer studentsCount = countStudentsForAmalgamatedSchoolReport(schoolObj.getMincode());
if(studentsCount > 0) {
ReportData nongradProjected = getReportDataObj(schoolObj, stdList);
createAndSaveSchoolReportStudentNonGradPrjReport(nongradProjected, mincode, accessToken);
numberOfReports++;
}
return numberOfReports;
}

private int countStudentsForAmalgamatedSchoolReport(String mincode) {
return restService.get(String.format(educGraduationApiConstants.getGradStudentCountSchoolReport(), mincode), Integer.class);
}

private ReportData getReportDataObj(School schoolObj, List<Student> stdList) {
ReportData data = new ReportData();
schoolObj.setStudents(stdList);
Expand All @@ -333,15 +349,6 @@ private ReportData getReportDataObj(School schoolObj, List<Student> stdList) {
return data;
}

private int processStudentNonGradPrjReport(School schoolObj, List<Student> stdList, String mincode, String accessToken, int numberOfReports) {
if(stdList != null && !stdList.isEmpty()) {
ReportData nongradProjected = getReportDataObj(schoolObj, stdList);
createAndSaveSchoolReportStudentNonGradPrjReport(nongradProjected, mincode, accessToken);
numberOfReports++;
}
return numberOfReports;
}

/**
private int processStudentNonGradReport(School schoolObj, List<Student> stdList, String mincode, String accessToken, int numberOfReports) {
ReportData nongradProjected = getReportDataObj(schoolObj, stdList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class EducGraduationApiConstants {

@Value("${endpoint.grad-student-api.student-for-school-report}")
private String gradStudentListSchoolReport;

@Value("${endpoint.grad-student-api.student-count-for-school-report}")
private String gradStudentCountSchoolReport;

@Value("${endpoint.grad-student-api.read-grad-student-record}")
private String readGradStudentRecord;
Expand Down
1 change: 1 addition & 0 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ endpoint:
update-grad-status-algo-error: ${GRAD_STUDENT_API}api/v1/student/algorithmerror/%s?isGraduated=%s
update-grad-status-projected: ${GRAD_STUDENT_API}api/v1/student/projected/studentid/%s
student-for-school-report: ${GRAD_STUDENT_API}api/v1/student/batch/schoolreport/%s
student-count-for-school-report: ${GRAD_STUDENT_API}api/v1/student/amalgamated/schoolreport/%s/count
school-nongrad-year-end-students: ${GRAD_STUDENT_API}api/v1/student/studentschoolreportdata
student-nongrad-report-data: ${GRAD_STUDENT_API}api/v1/student/studentnongradreportdata
student-nongrad-report-data-mincode: ${GRAD_STUDENT_API}api/v1/student/studentnongradreportdata/%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2035,10 +2035,12 @@ public void testCreateAndStoreSchoolReports() {
when(this.tokenUtils.getAccessToken(any())).thenReturn(Pair.of("accessToken", System.currentTimeMillis()));
when(this.tokenUtils.checkAndGetAccessToken(any())).thenReturn(Pair.of("accessToken", System.currentTimeMillis()));

when(this.restService.get(any(), any())).thenReturn(1);

Mockito.when(gradStatusService.getStudentListByMinCode(mincode, "accessToken")).thenReturn(sList);
Mockito.when(schoolService.getTraxSchoolDetails(mincode, "accessToken", exception)).thenReturn(sTrax);
int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG","accessToken");
assertEquals(1,numberOfRecord);
assertEquals(2,numberOfRecord);

Mockito.when(gradStatusService.getStudentListByMinCode(mincode, "accessToken")).thenReturn(List.of());
numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"REGALG","accessToken");
Expand Down Expand Up @@ -2264,6 +2266,8 @@ public void testCreateAndStoreSchoolReports_TVR() {

when(this.tokenUtils.getAccessToken(any())).thenReturn(Pair.of("accessToken", System.currentTimeMillis()));

when(this.restService.get(any(), any())).thenReturn(1);

Mockito.when(gradStatusService.getStudentListByMinCode(mincode, "accessToken")).thenReturn(sList);
Mockito.when(schoolService.getTraxSchoolDetails(mincode, "accessToken", exception)).thenReturn(sTrax);
int numberOfRecord = graduationService.createAndStoreSchoolReports(uniqueList,"TVRRUN","accessToken");
Expand Down
1 change: 1 addition & 0 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ endpoint:
update-grad-status-algo-error: https://educ-grad-student-api-77c02f-test.apps.silver.devops.gov.bc.ca/api/v1/student/algorithmerror/%s?isGraduated=%s
update-grad-status-projected: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/projected/studentid/%s
student-for-school-report: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/batch/schoolreport/%s
student-count-for-school-report: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/amalgamated/schoolreport/%s/count
school-nongrad-year-end-students: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/studentschoolreportdata
student-nongrad-report-data: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/studentnongradreportdata
student-nongrad-report-data-mincode: https://educ-grad-student-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/student/studentnongradreportdata/%s
Expand Down
Loading