7
7
import ca .bc .gov .educ .studentdatacollection .api .model .v1 .*;
8
8
import ca .bc .gov .educ .studentdatacollection .api .repository .v1 .SdcDistrictCollectionRepository ;
9
9
import ca .bc .gov .educ .studentdatacollection .api .repository .v1 .SdcSchoolCollectionRepository ;
10
- import ca .bc .gov .educ .studentdatacollection .api .repository .v1 .SdcSchoolCollectionStudentEnrolledProgramRepository ;
11
10
import ca .bc .gov .educ .studentdatacollection .api .repository .v1 .SdcSchoolCollectionStudentRepository ;
12
11
import ca .bc .gov .educ .studentdatacollection .api .rest .RestUtils ;
12
+ import ca .bc .gov .educ .studentdatacollection .api .struct .external .institute .v1 .SchoolTombstone ;
13
13
import ca .bc .gov .educ .studentdatacollection .api .struct .v1 .SdcSchoolCollectionStudent ;
14
14
import ca .bc .gov .educ .studentdatacollection .api .struct .v1 .headcounts .PRPorYouthHeadcountResult ;
15
15
import ca .bc .gov .educ .studentdatacollection .api .struct .v1 .headcounts .HeadcountResultsTable ;
29
29
import java .util .*;
30
30
import java .util .stream .IntStream ;
31
31
32
+ import static org .junit .jupiter .api .Assertions .*;
32
33
import static org .mockito .Mockito .when ;
33
34
34
35
@ SpringBootTest (classes = StudentDataCollectionApiApplication .class )
@@ -37,9 +38,6 @@ class PRPorYouthHeadcountHelperTest extends BaseStudentDataCollectionAPITest {
37
38
@ Autowired
38
39
private SdcSchoolCollectionStudentRepository studentRepository ;
39
40
40
- @ Autowired
41
- private SdcSchoolCollectionStudentEnrolledProgramRepository enrolledProgramRepository ;
42
-
43
41
private PRPorYouthHeadcountHelper helper ;
44
42
45
43
private SdcDistrictCollectionEntity mockDistrictCollectionEntity ;
@@ -140,4 +138,51 @@ void testConvertHeadcountResultsToSchoolGradeTable_ShouldReturnTableContents(){
140
138
var schoolSection = actualResultsTable .getRows ().stream ().map (row -> row .get ("section" )).toList ();
141
139
assert (schoolSection .stream ().anyMatch (val -> val .getCurrentValue ().contains ("All Schools" )));
142
140
}
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
+ }
143
188
}
0 commit comments