Skip to content

Commit d123caa

Browse files
committed
test report generation controller
1 parent dc4ac73 commit d123caa

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/ReportGenerationControllerTest.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ public void after() {
8787
"INDIGENOUS_HEADCOUNT",
8888
"BAND_RESIDENCE_HEADCOUNT",
8989
"ELL_HEADCOUNT",
90-
"SPECIAL_EDUCATION_HEADCOUNT"
90+
"SPECIAL_EDUCATION_HEADCOUNT",
91+
"ALL_STUDENT_SCHOOL_CSV",
92+
"ALL_STUDENT_ERRORS_WARNS_SCHOOL_CSV",
93+
"ALL_STUDENT_FRENCH_SCHOOL_CSV",
94+
"ALL_STUDENT_CAREER_SCHOOL_CSV",
95+
"ALL_STUDENT_INDIGENOUS_SCHOOL_CSV",
96+
"ALL_STUDENT_INCLUSIVE_SCHOOL_CSV",
97+
"ALL_STUDENT_ELL_SCHOOL_CSV"
9198
})
9299
void testGetGradeEnrollmentHeadcountReport_ShouldReturnCollection(String reportTypeCode) throws Exception {
93100
final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_SDC_COLLECTION";
@@ -125,6 +132,56 @@ void testGetGradeEnrollmentHeadcountReport_ShouldReturnCollection(String reportT
125132
.andDo(print()).andExpect(status().isOk());
126133
}
127134

135+
@ParameterizedTest
136+
@CsvSource({
137+
"ALL_STUDENT_DIS_CSV",
138+
"ALL_STUDENT_ERRORS_WARNS_DIS_CSV",
139+
"ALL_STUDENT_FRENCH_DIS_CSV",
140+
"ALL_STUDENT_CAREER_DIS_CSV",
141+
"ALL_STUDENT_INDIGENOUS_DIS_CSV",
142+
"ALL_STUDENT_INCLUSIVE_DIS_CSV",
143+
"ALL_STUDENT_ELL_DIS_CSV"
144+
})
145+
void testAllDistrictCsvReports_ShouldReturnCollection(String reportTypeCode) throws Exception {
146+
final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_SDC_COLLECTION";
147+
final SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor mockAuthority = oidcLogin().authorities(grantedAuthority);
148+
149+
var district = this.createMockDistrict();
150+
when(this.restUtils.getDistrictByDistrictID(anyString())).thenReturn(Optional.of(district));
151+
var schoolMock = this.createMockSchool();
152+
when(this.restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(schoolMock));
153+
154+
CollectionEntity collection = createMockCollectionEntity();
155+
collection.setCloseDate(LocalDateTime.now().plusDays(2));
156+
collectionRepository.save(collection);
157+
158+
SdcDistrictCollectionEntity sdcMockDistrict = createMockSdcDistrictCollectionEntity(collection, UUID.fromString(district.getDistrictId()));
159+
sdcMockDistrict = sdcDistricCollectionRepository.save(sdcMockDistrict);
160+
161+
SchoolTombstone schoolTombstone = createMockSchool();
162+
SdcSchoolCollectionEntity sdcMockSchool = createMockSdcSchoolCollectionEntity(collection, UUID.fromString(schoolTombstone.getSchoolId()));
163+
sdcMockSchool.setUploadDate(null);
164+
sdcMockSchool.setUploadFileName(null);
165+
sdcMockSchool.setSdcDistrictCollectionID(sdcMockDistrict.getSdcDistrictCollectionID());
166+
sdcMockSchool = sdcSchoolCollectionRepository.save(sdcMockSchool);
167+
168+
SdcSchoolCollectionStudentEntity student1 = createMockSchoolStudentEntity(sdcMockSchool);
169+
student1.setIsSchoolAged(true);
170+
student1.setFte(new BigDecimal(1.0));
171+
sdcSchoolCollectionStudentRepository.save(student1);
172+
173+
SdcSchoolCollectionStudentEntity student2 = createMockSchoolStudentEntity(sdcMockSchool);
174+
student2.setBandCode("0600");
175+
student2.setIsSchoolAged(false);
176+
student2.setIsAdult(true);
177+
student2.setFte(new BigDecimal(2.0));
178+
sdcSchoolCollectionStudentRepository.save(student2);
179+
180+
this.mockMvc.perform(
181+
get(URL.BASE_URL_REPORT_GENERATION + "/sdcDistrictCollection/" + sdcMockDistrict.getSdcDistrictCollectionID() + "/" + reportTypeCode).with(mockAuthority))
182+
.andDo(print()).andExpect(status().isOk());
183+
}
184+
128185
@Test
129186
void testGetFrenchProgramHeadcountReportCSF_ShouldReturnCollection() throws Exception {
130187
final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_SDC_COLLECTION";

0 commit comments

Comments
 (0)