Skip to content

Commit 30ae5e7

Browse files
committed
fix tests
1 parent 7afb866 commit 30ae5e7

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/calculator/FteCalculatorChainProcessorIntegrationTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ void testProcessFteCalculator_DistrictDoubleReported() {
331331

332332
this.studentData.getSchool().setSchoolId(sdcSchoolCollectionEntityOrig.getSchoolID().toString());
333333
this.studentData.getSchool().setDistrictId(String.valueOf(districtID));
334+
this.studentData.getSchool().setIndependentAuthorityId(null);
334335
SdcSchoolCollectionStudentEntity sdcSchoolCollectionStudentEntity = createMockSchoolStudentForSagaEntity(sdcSchoolCollectionEntityOrig);
335336

336337
sdcSchoolCollectionStudentEntity.setEnrolledGradeCode("08");
@@ -341,7 +342,7 @@ void testProcessFteCalculator_DistrictDoubleReported() {
341342
var oldCollection = createMockCollectionEntity();
342343
var oldSnapDate = LocalDate.of(LocalDateTime.now().minusYears(1).getYear(), Month.SEPTEMBER, 29);
343344
oldCollection.setSnapshotDate(oldSnapDate);
344-
var oldSdcCollection = createMockSdcSchoolCollectionEntity(oldCollection, null);
345+
var oldSdcCollection = createMockSdcSchoolCollectionEntity(oldCollection, sdcSchoolCollectionEntityOrig.getSchoolID());
345346
collectionRepository.save(oldCollection);
346347
var oldDistrictColl = sdcDistrictCollectionRepository.save(createMockSdcDistrictCollectionEntity(oldCollection, districtID));
347348
oldSdcCollection.setSdcDistrictCollectionID(oldDistrictColl.getSdcDistrictCollectionID());
@@ -358,6 +359,7 @@ void testProcessFteCalculator_DistrictDoubleReported() {
358359
penMatchResult.getMatchingRecords().get(0).setStudentID(oneYearAgoCollectionStudent.getAssignedStudentId().toString());
359360
when(this.restUtils.getPenMatchResult(any(),any(), any())).thenReturn(penMatchResult);
360361
when(this.restUtils.getMergedStudentIds(any(), any())).thenReturn(List.of(studentMerge));
362+
when(restUtils.getAllSchoolTombstones()).thenReturn(List.of(this.studentData.getSchool()));
361363
FteCalculationResult result = fteCalculatorChainProcessor.processFteCalculator(studentData);
362364

363365
// Then
@@ -390,6 +392,7 @@ void testProcessFteCalculator_DistrictDoubleReported_GivenMergedStudent_ReturnsZ
390392

391393
this.studentData.getSchool().setSchoolId(sdcSchoolCollectionEntityOrig.getSchoolID().toString());
392394
this.studentData.getSchool().setDistrictId(String.valueOf(districtID));
395+
this.studentData.getSchool().setIndependentAuthorityId(null);
393396
SdcSchoolCollectionStudentEntity sdcSchoolCollectionStudentEntity = createMockSchoolStudentForSagaEntity(sdcSchoolCollectionEntityOrig);
394397

395398
sdcSchoolCollectionStudentEntity.setEnrolledGradeCode("08");
@@ -400,7 +403,7 @@ void testProcessFteCalculator_DistrictDoubleReported_GivenMergedStudent_ReturnsZ
400403
var oldCollection = createMockCollectionEntity();
401404
var oldSnapDate = LocalDate.of(LocalDateTime.now().minusYears(1).getYear(), Month.SEPTEMBER, 29);
402405
oldCollection.setSnapshotDate(oldSnapDate);
403-
var oldSdcCollection = createMockSdcSchoolCollectionEntity(oldCollection, null);
406+
var oldSdcCollection = createMockSdcSchoolCollectionEntity(oldCollection, sdcSchoolCollectionEntityOrig.getSchoolID());
404407
collectionRepository.save(oldCollection);
405408
var oldDistrictColl = sdcDistrictCollectionRepository.save(createMockSdcDistrictCollectionEntity(oldCollection, districtID));
406409
oldSdcCollection.setSdcDistrictCollectionID(oldDistrictColl.getSdcDistrictCollectionID());
@@ -420,6 +423,7 @@ void testProcessFteCalculator_DistrictDoubleReported_GivenMergedStudent_ReturnsZ
420423
penMatchResult.getMatchingRecords().get(0).setStudentID(oneYearAgoCollectionStudent.getAssignedStudentId().toString());
421424
when(this.restUtils.getPenMatchResult(any(),any(), any())).thenReturn(penMatchResult);
422425
when(this.restUtils.getMergedStudentIds(any(), any())).thenReturn(List.of(studentMerge));
426+
when(restUtils.getAllSchoolTombstones()).thenReturn(List.of(this.studentData.getSchool()));
423427
FteCalculationResult result = fteCalculatorChainProcessor.processFteCalculator(studentData);
424428

425429
// Then

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/calculator/FteCalculatorUtilsTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package ca.bc.gov.educ.studentdatacollection.api.calculator;
22

3+
import ca.bc.gov.educ.studentdatacollection.api.BaseStudentDataCollectionAPITest;
34
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
45
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.FacilityTypeCodes;
56
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolGradeCodes;
@@ -791,19 +792,33 @@ void studentPreviouslyReportedInIndependentAuthority_GivenDifferentSchoolCategor
791792
@Test
792793
void studentPreviouslyReportedInIndependentAuthority_SchoolIsNull_ReturnsFalse() {
793794
// Given
795+
UUID schoolId = UUID.randomUUID();
796+
final SchoolTombstone schoolTombstone = new SchoolTombstone();
797+
schoolTombstone.setSchoolId(schoolId.toString());
798+
schoolTombstone.setDistrictId(UUID.randomUUID().toString());
799+
schoolTombstone.setIndependentAuthorityId(UUID.randomUUID().toString());
800+
schoolTombstone.setDisplayName("Marco's school");
801+
schoolTombstone.setMincode("03636018");
802+
schoolTombstone.setSchoolNumber("36018");
803+
schoolTombstone.setOpenedDate("1964-09-01T00:00:00");
804+
schoolTombstone.setSchoolCategoryCode("PUBLIC");
805+
schoolTombstone.setSchoolReportingRequirementCode("REGULAR");
806+
schoolTombstone.setFacilityTypeCode("STANDARD");
807+
794808
StudentRuleData sdcStudentSagaData = new StudentRuleData();
809+
sdcStudentSagaData.setSchool(schoolTombstone);
795810
SdcSchoolCollectionStudentEntity student = new SdcSchoolCollectionStudentEntity();
796811
CollectionEntity collection = createMockCollectionEntity();
797812
collection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode());
798-
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, null);
813+
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, schoolId);
799814
student.setSdcSchoolCollection(sdcSchoolCollectionEntity);
800815
student.setEnrolledGradeCode(SchoolGradeCodes.GRADE09.getCode());
801816
student.setCreateDate(LocalDateTime.now());
802817
student.setAssignedStudentId(UUID.randomUUID());
803818
sdcStudentSagaData.setSdcSchoolCollectionStudentEntity(student);
804819
sdcStudentSagaData.setHistoricStudentIds(List.of(UUID.fromString(getStudentMergeResult().getStudentID()), student.getAssignedStudentId()));
805820

806-
when(restUtils.getSchoolIDsByIndependentAuthorityID(anyString())).thenReturn(Optional.of(Collections.singletonList(UUID.randomUUID())));
821+
when(restUtils.getSchoolIDsByIndependentAuthorityID(anyString())).thenReturn(Optional.of(List.of(schoolId)));
807822
when(sdcSchoolCollectionRepository.findSeptemberCollectionsForSchoolsForFiscalYearToCurrentCollection(anyList(), any(LocalDate.class), any(LocalDate.class))).thenReturn(Collections.emptyList());
808823
when(sdcSchoolCollectionRepository.findFebruaryCollectionsForSchoolsForFiscalYearToCurrentCollection(anyList(), any(LocalDate.class), any(LocalDate.class))).thenReturn(Collections.emptyList());
809824
when(sdcSchoolCollectionStudentRepository.countAllByAssignedStudentIdInAndSdcSchoolCollection_SdcSchoolCollectionIDInExcludingHomeschool(anyList(), anyList())).thenReturn(1L);

0 commit comments

Comments
 (0)