Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public enum ProgramEligibilityIssueCode {
NOT_ENROLLED_ELL("NTENRELL", "The student is not enrolled in the ELL program.", ProgramEligibilityTypeCode.ELL),
NO_INDIGENOUS_ANCESTRY("NOANCESTRY", "Student must be school-aged and self-identify as having Indigenous Ancestry to be eligible for funding for Indigenous Support Programs.", ProgramEligibilityTypeCode.IND_SUPPORT),
ELL_INDY_SCHOOL("ELLINDYERR", "Students reported by Independent Schools are not eligible for English Language Learning funding.", ProgramEligibilityTypeCode.ELL),
INDIGENOUS_INDY_SCHOOL("INDYERR", "Students reported by Independent Schools are not eligible for Indigenous Support Program funding.", ProgramEligibilityTypeCode.IND_SUPPORT);

INDIGENOUS_INDY_SCHOOL("INDYERR", "Students reported by Independent Schools are not eligible for Indigenous Support Program funding.", ProgramEligibilityTypeCode.IND_SUPPORT),
CROSS_ENROLL("CROSSENROLL", "8/9 Cross-enrollment students are not eligibile for program funding.", ProgramEligibilityTypeCode.BASE);

@Getter
private final String code;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ca.bc.gov.educ.studentdatacollection.api.rules.programelegibility.impl;

import ca.bc.gov.educ.studentdatacollection.api.calculator.FteCalculatorUtils;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.FacilityTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.ProgramEligibilityIssueCode;
import ca.bc.gov.educ.studentdatacollection.api.rules.ProgramEligibilityBaseRule;
import ca.bc.gov.educ.studentdatacollection.api.struct.StudentRuleData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
@Slf4j
@Order(9)
public class CrossEnrollmentRule implements ProgramEligibilityBaseRule {

@Override
public boolean shouldExecute(StudentRuleData studentRuleData, List<ProgramEligibilityIssueCode> list) {
log.debug("In shouldExecute of ProgramEligibilityBaseRule - CrossEnrollmentRule: for collectionType {} and sdcSchoolCollectionStudentID :: {}" , FteCalculatorUtils.getCollectionTypeCode(studentRuleData),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

log.debug("In shouldExecute of ProgramEligibilityBaseRule - CrossEnrollmentRule: Condition returned - {} for sdcSchoolCollectionStudentID :: {}" ,
studentRuleData.getSchool().getFacilityTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollection().getCollectionEntity().getCollectionTypeCode(),
studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
return !studentRuleData.getSchool().getFacilityTypeCode().equals(FacilityTypeCodes.SUMMER.getCode()) && studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollection().getCollectionEntity().getCollectionTypeCode().equals(CollectionTypeCodes.JULY.getTypeCode());
}

@Override
public List<ProgramEligibilityIssueCode> executeValidation(StudentRuleData studentRuleData) {
log.debug("In executeValidation of ProgramEligibilityBaseRule - CrossEnrollmentRule for sdcSchoolCollectionStudentID ::" + studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());

List<ProgramEligibilityIssueCode> errors = new ArrayList<>();
errors.add(ProgramEligibilityIssueCode.CROSS_ENROLL);
return errors;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,39 @@ void testZeroCoursesSchoolAgeRule() {
errors = rulesProcessor.processRules(createMockStudentRuleData(student, school));
assertThat(errors).doesNotContain(ProgramEligibilityIssueCode.ZERO_COURSES_SCHOOL_AGE);
}

@Test
void testCrossEnrollmentRule() {
CollectionEntity collection = createMockCollectionEntity();
collection.setCollectionTypeCode(CollectionTypeCodes.JULY.getTypeCode());
collectionRepository.save(collection);
SdcSchoolCollectionEntity schoolCollection = sdcSchoolCollectionRepository.save(createMockSdcSchoolCollectionEntity(collection, null));
SdcSchoolCollectionStudentEntity schoolStudentEntity = this.createMockSchoolStudentEntity(schoolCollection);
PenMatchResult penMatchResult = getPenMatchResult();
when(this.restUtils.getPenMatchResult(any(), any(), any())).thenReturn(penMatchResult);

SchoolTombstone standardSchool = createMockSchool();
standardSchool.setFacilityTypeCode(FacilityTypeCodes.SUMMER.getCode());

List<ProgramEligibilityIssueCode> listWithoutError = rulesProcessor.processRules(
createMockStudentRuleData(
schoolStudentEntity,
standardSchool
)
);
assertThat(listWithoutError)
.isNotEmpty()
.doesNotContain(ProgramEligibilityIssueCode.CROSS_ENROLL);

SchoolTombstone summerSchool = createMockSchool();
summerSchool.setFacilityTypeCode(FacilityTypeCodes.STANDARD.getCode());

List<ProgramEligibilityIssueCode> listWithError = rulesProcessor.processRules(
createMockStudentRuleData(
schoolStudentEntity,
summerSchool
)
);
assertThat(listWithError).contains(ProgramEligibilityIssueCode.CROSS_ENROLL);
}
}
Loading