Skip to content

Commit 159c600

Browse files
committed
test
1 parent 1d1ca0a commit 159c600

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/helpers/PRPorYouthHeadcountHelperTest.java

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import ca.bc.gov.educ.studentdatacollection.api.model.v1.*;
88
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcDistrictCollectionRepository;
99
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository;
10-
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentEnrolledProgramRepository;
1110
import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentRepository;
1211
import ca.bc.gov.educ.studentdatacollection.api.rest.RestUtils;
12+
import ca.bc.gov.educ.studentdatacollection.api.struct.external.institute.v1.SchoolTombstone;
1313
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudent;
1414
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.PRPorYouthHeadcountResult;
1515
import ca.bc.gov.educ.studentdatacollection.api.struct.v1.headcounts.HeadcountResultsTable;
@@ -29,6 +29,7 @@
2929
import java.util.*;
3030
import java.util.stream.IntStream;
3131

32+
import static org.junit.jupiter.api.Assertions.*;
3233
import static org.mockito.Mockito.when;
3334

3435
@SpringBootTest(classes = StudentDataCollectionApiApplication.class)
@@ -37,9 +38,6 @@ class PRPorYouthHeadcountHelperTest extends BaseStudentDataCollectionAPITest {
3738
@Autowired
3839
private SdcSchoolCollectionStudentRepository studentRepository;
3940

40-
@Autowired
41-
private SdcSchoolCollectionStudentEnrolledProgramRepository enrolledProgramRepository;
42-
4341
private PRPorYouthHeadcountHelper helper;
4442

4543
private SdcDistrictCollectionEntity mockDistrictCollectionEntity;
@@ -140,4 +138,51 @@ void testConvertHeadcountResultsToSchoolGradeTable_ShouldReturnTableContents(){
140138
var schoolSection = actualResultsTable.getRows().stream().map(row -> row.get("section")).toList();
141139
assert(schoolSection.stream().anyMatch(val -> val.getCurrentValue().contains("All Schools")));
142140
}
141+
142+
@Test
143+
void testGetPRPAndYouthSchoolUUIDs_ShouldReturnCorrectUUIDs() {
144+
helper = new PRPorYouthHeadcountHelper(schoolCollectionRepository, studentRepository, sdcDistrictCollectionRepository, restUtils);
145+
146+
SchoolTombstone youthSchool = new SchoolTombstone();
147+
youthSchool.setSchoolId(UUID.randomUUID().toString());
148+
youthSchool.setFacilityTypeCode(FacilityTypeCodes.YOUTH.getCode());
149+
150+
SchoolTombstone shortPrpSchool = new SchoolTombstone();
151+
shortPrpSchool.setSchoolId(UUID.randomUUID().toString());
152+
shortPrpSchool.setFacilityTypeCode(FacilityTypeCodes.SHORT_PRP.getCode());
153+
154+
SchoolTombstone longPrpSchool = new SchoolTombstone();
155+
longPrpSchool.setSchoolId(UUID.randomUUID().toString());
156+
longPrpSchool.setFacilityTypeCode(FacilityTypeCodes.LONG_PRP.getCode());
157+
158+
PRPorYouthHeadcountHelper spyHelper = org.mockito.Mockito.spy(helper);
159+
Map<String, List<SchoolTombstone>> mockTombstones = new HashMap<>();
160+
mockTombstones.put("ALLPRPORYOUTH", Arrays.asList(youthSchool, shortPrpSchool, longPrpSchool));
161+
mockTombstones.put("YOUTH", List.of(youthSchool));
162+
mockTombstones.put("SHORT_PRP", List.of(shortPrpSchool));
163+
mockTombstones.put("LONG_PRP", List.of(longPrpSchool));
164+
165+
org.mockito.Mockito.doReturn(mockTombstones).when(spyHelper).getAllPRPAndYouthSchoolTombstones(
166+
mockDistrictCollectionEntity.getSdcDistrictCollectionID()
167+
);
168+
169+
Map<String, List<UUID>> result = spyHelper.getPRPAndYouthSchoolUUIDs(
170+
mockDistrictCollectionEntity.getSdcDistrictCollectionID()
171+
);
172+
173+
assertEquals(4, result.size());
174+
assertTrue(result.containsKey("ALLPRPORYOUTH"));
175+
assertTrue(result.containsKey("YOUTH"));
176+
assertTrue(result.containsKey("SHORT_PRP"));
177+
assertTrue(result.containsKey("LONG_PRP"));
178+
179+
assertEquals(3, result.get("ALLPRPORYOUTH").size());
180+
assertEquals(1, result.get("YOUTH").size());
181+
assertEquals(1, result.get("SHORT_PRP").size());
182+
assertEquals(1, result.get("LONG_PRP").size());
183+
184+
assertEquals(UUID.fromString(youthSchool.getSchoolId()), result.get("YOUTH").get(0));
185+
assertEquals(UUID.fromString(shortPrpSchool.getSchoolId()), result.get("SHORT_PRP").get(0));
186+
assertEquals(UUID.fromString(longPrpSchool.getSchoolId()), result.get("LONG_PRP").get(0));
187+
}
143188
}

0 commit comments

Comments
 (0)