|
3 | 3 | import ca.bc.gov.educ.api.graduation.exception.EntityNotFoundException; |
4 | 4 | import ca.bc.gov.educ.api.graduation.exception.ServiceException; |
5 | 5 | import ca.bc.gov.educ.api.graduation.model.dto.*; |
| 6 | +import ca.bc.gov.educ.api.graduation.model.dto.GraduationData; |
6 | 7 | import ca.bc.gov.educ.api.graduation.model.dto.institute.YearEndReportRequest; |
7 | | -import ca.bc.gov.educ.api.graduation.model.report.Code; |
8 | | -import ca.bc.gov.educ.api.graduation.model.report.ReportData; |
9 | | -import ca.bc.gov.educ.api.graduation.model.report.Transcript; |
| 8 | +import ca.bc.gov.educ.api.graduation.model.report.*; |
10 | 9 | import ca.bc.gov.educ.api.graduation.util.*; |
11 | 10 | import com.fasterxml.jackson.core.type.TypeReference; |
12 | 11 | import com.fasterxml.jackson.databind.ObjectMapper; |
@@ -149,6 +148,41 @@ public void testIsValidCutOffCoursePrefersHighestNonNullPercentage() { |
149 | 148 | assertFalse(nullResult); |
150 | 149 | } |
151 | 150 |
|
| 151 | + @Test |
| 152 | + public void testIsHigherCompletedPercentageHandlesNullsAndComparison() { |
| 153 | + TranscriptResult existing = new TranscriptResult(); |
| 154 | + Mark existingMark = new Mark(); |
| 155 | + existingMark.setCompletedCoursePercentage(70.0); |
| 156 | + existing.setMark(existingMark); |
| 157 | + |
| 158 | + TranscriptResult higherCandidate = new TranscriptResult(); |
| 159 | + Mark higherCandidateMark = new Mark(); |
| 160 | + higherCandidateMark.setCompletedCoursePercentage(85.0); |
| 161 | + higherCandidate.setMark(higherCandidateMark); |
| 162 | + |
| 163 | + Boolean higherResult = ReflectionTestUtils.invokeMethod(reportService, "isHigherCompletedPercentage", existing, higherCandidate); |
| 164 | + assertTrue(higherResult); |
| 165 | + |
| 166 | + TranscriptResult lowerCandidate = new TranscriptResult(); |
| 167 | + Mark lowerCandidateMark = new Mark(); |
| 168 | + lowerCandidateMark.setCompletedCoursePercentage(65.0); |
| 169 | + lowerCandidate.setMark(lowerCandidateMark); |
| 170 | + |
| 171 | + Boolean lowerResult = ReflectionTestUtils.invokeMethod(reportService, "isHigherCompletedPercentage", existing, lowerCandidate); |
| 172 | + assertFalse(lowerResult); |
| 173 | + |
| 174 | + TranscriptResult nullCandidate = new TranscriptResult(); |
| 175 | + Boolean nullResult = ReflectionTestUtils.invokeMethod(reportService, "isHigherCompletedPercentage", existing, nullCandidate); |
| 176 | + assertFalse(nullResult); |
| 177 | + |
| 178 | + TranscriptResult nullExisting = new TranscriptResult(); |
| 179 | + Boolean nullExistingResult = ReflectionTestUtils.invokeMethod(reportService, "isHigherCompletedPercentage", nullExisting, higherCandidate); |
| 180 | + assertTrue(nullExistingResult); |
| 181 | + |
| 182 | + Boolean bothNullResult = ReflectionTestUtils.invokeMethod(reportService, "isHigherCompletedPercentage", nullExisting, nullCandidate); |
| 183 | + assertFalse(bothNullResult); |
| 184 | + } |
| 185 | + |
152 | 186 | @Test |
153 | 187 | public void testGetStudentsForSchoolYearEndNonGradReportWithMincode() { |
154 | 188 | List<ReportGradStudentData> gradStudentDataList = createStudentSchoolYearEndData("json/studentSchoolYearEndResponse.json"); |
|
0 commit comments