diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java index 27b6ca28..f6c5f381 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/model/StudentSearchRequest.java @@ -27,7 +27,7 @@ public class StudentSearchRequest implements Serializable { private List programs = new ArrayList<>(); private List studentIDs = new ArrayList<>(); private List statuses = new ArrayList<>(); - private List reportTypes = new ArrayList(); + private List reportTypes = new ArrayList<>(); private String user; private Address address; diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java index 5baadd76..87d9769c 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/rest/RestUtils.java @@ -578,10 +578,6 @@ public SchoolClob getSchoolClob(String schoolId) { return restService.get(String.format(constants.getSchoolClobBySchoolId(), schoolId), SchoolClob.class); } - public ca.bc.gov.educ.api.batchgraduation.model.institute.School getSchool(String schoolId) { - return restService.get(String.format(constants.getSchoolBySchoolId(), schoolId), ca.bc.gov.educ.api.batchgraduation.model.institute.School.class); - } - public List getDeceasedStudentIDs(List studentIDs) { var response = restService.post(constants.getDeceasedStudentIDList(), studentIDs, List.class); return jsonTransformer.convertValue(response, new TypeReference<>(){}); diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index acd962e3..530814b3 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -1111,6 +1111,14 @@ public void testGetDistrictsBySchoolCategoryCode() { assertThat(res).isNotNull(); } + @Test + public void testGetDistrictsBySchoolCategoryCode_whenException_isThrown() { + when(this.restService.get(String.format(constants.getDistricstBySchoolCategory(), "02"), List.class)).thenThrow(new RuntimeException("Test Exception")); + + List res = this.restUtils.getDistrictsBySchoolCategoryCode("02"); + assertThat(res).isEmpty(); + } + @Test public void testGetSchoolsBySchoolCategoryCode() { ca.bc.gov.educ.api.batchgraduation.model.institute.School school = new ca.bc.gov.educ.api.batchgraduation.model.institute.School(); @@ -1124,6 +1132,14 @@ public void testGetSchoolsBySchoolCategoryCode() { assertThat(res).isNotNull(); } + @Test + public void testGetSchoolsBySchoolCategoryCode_whenException_isThrown() { + when(this.restService.get(String.format(constants.getSchoolsBySchoolCategory(), "02"), List.class)).thenThrow(new RuntimeException("Test Exception")); + + List res = this.restUtils.getSchoolsBySchoolCategoryCode("02"); + assertThat(res).isEmpty(); + } + @Test public void testSearchSchoolsByDistrictId() { UUID schoolId = UUID.randomUUID(); @@ -1140,6 +1156,54 @@ public void testSearchSchoolsByDistrictId() { assertThat(res).isNotNull(); } + @Test + public void testSearchSchoolsByDistrictId_whenException_isThrown() { + UUID districtId = UUID.randomUUID(); + when(this.restService.get(String.format(constants.getSearchSchoolsByDistrictId(), districtId), List.class)).thenThrow(new RuntimeException("Test Exception")); + + List res = this.restUtils.getSchoolsByDistrictId(districtId); + assertThat(res).isEmpty(); + } + + @Test + public void testSearchSchoolsByDistrictNumber() { + UUID schoolId = UUID.randomUUID(); + UUID districtId = UUID.randomUUID(); + String districtNumber = "039"; + + ca.bc.gov.educ.api.batchgraduation.model.institute.School school = new ca.bc.gov.educ.api.batchgraduation.model.institute.School(); + school.setSchoolId(schoolId.toString()); + school.setDistrictId(districtId.toString()); + school.setMincode("1234567"); + + when(this.restService.get(String.format(constants.getSearchSchoolsByDistrictNumber(), districtNumber), List.class)).thenReturn(List.of(school)); + + List res = this.restUtils.getSchoolsByDistrictNumber(districtNumber); + assertThat(res).isNotNull(); + } + + @Test + public void testSearchSchoolsByDistrictNumber_whenException_isThrown() { + String districtNumber = "039"; + when(this.restService.get(String.format(constants.getSearchSchoolsByDistrictNumber(), districtNumber), List.class)).thenThrow(new RuntimeException("Test Exception")); + + List res = this.restUtils.getSchoolsByDistrictNumber(districtNumber); + assertThat(res).isEmpty(); + } + + public void testGetSchoolClob() { + UUID schoolId = UUID.randomUUID(); + + SchoolClob school = new SchoolClob(); + school.setSchoolId(schoolId.toString()); + school.setMinCode("1234567"); + + when(this.restService.get(String.format(constants.getSchoolClobBySchoolId(), schoolId), List.class)).thenReturn(List.of(school)); + + val res = this.restUtils.getSchoolClob(schoolId.toString()); + assertThat(res).isNotNull(); + } + @Test public void testExecutePostDistribution() { DistributionResponse distributionResponse = new DistributionResponse();