Skip to content

Commit

Permalink
Merge pull request #466 from bcgov/fix/v77v78
Browse files Browse the repository at this point in the history
fix: v77 v78 - for when user is neither school aged or adult
  • Loading branch information
mightycox authored Feb 20, 2024
2 parents 58f9925 + 4ccf03b commit 6b7ae53
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(Student
List<String> studentPrograms = validationRulesService.splitString(student.getEnrolledProgramCodes());

log.debug("SchoolAgedELLRule-V78: Invalid age for English Language Learning for sdcSchoolCollectionStudentID:: {}", studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
if (EnrolledProgramCodes.getELLCodes().stream().anyMatch(studentPrograms::contains)
&& DOBUtil.isAdult(student.getDob())) {
if (EnrolledProgramCodes.getELLCodes().stream().anyMatch(studentPrograms::contains) && DOBUtil.isAdult(student.getDob())
|| (EnrolledProgramCodes.getELLCodes().stream().anyMatch(studentPrograms::contains) && !DOBUtil.isAdult(student.getDob()) && !DOBUtil.isSchoolAged(student.getDob()))) {
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.ENROLLED_PROGRAM_CODE, StudentValidationIssueTypeCode.SCHOOL_AGED_ELL));
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.DOB, StudentValidationIssueTypeCode.SCHOOL_AGED_ELL));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(Student
List<String> studentPrograms = validationRulesService.splitString(student.getEnrolledProgramCodes());

log.debug("AdultIndigenousFundingRule-V77: Invalid age for Indigenous Support Programs for sdcSchoolCollectionStudentID:: {}", studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
if (EnrolledProgramCodes.getIndigenousProgramCodes().stream().anyMatch(studentPrograms::contains)
&& DOBUtil.isAdult(student.getDob())) {
if (EnrolledProgramCodes.getIndigenousProgramCodes().stream().anyMatch(studentPrograms::contains) && DOBUtil.isAdult(student.getDob())
|| (EnrolledProgramCodes.getIndigenousProgramCodes().stream().anyMatch(studentPrograms::contains) && !DOBUtil.isAdult(student.getDob()) && !DOBUtil.isSchoolAged(student.getDob()))) {
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.ENROLLED_PROGRAM_CODE, StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT));
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.DOB, StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,11 @@ void testSchoolAgedIndigenousSupportRule() {
var collection = collectionRepository.save(createMockCollectionEntity());
var sdcSchoolCollectionEntity = sdcSchoolCollectionRepository.save(createMockSdcSchoolCollectionEntity(collection, null, null));
val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
val entity2 = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
entity.setEnrolledProgramCodes("33");
entity.setDob("19890101");
entity2.setEnrolledProgramCodes("33");
entity2.setDob("20230101");

val validationError = rulesProcessor.processRules(createMockStudentRuleData(entity, createMockSchool()));
val error1 = validationError.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT.getCode())
Expand All @@ -868,15 +871,26 @@ void testSchoolAgedIndigenousSupportRule() {
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.DOB.getCode()));
assertThat(error1).isTrue();
assertThat(error2).isTrue();

val validationError2 = rulesProcessor.processRules(createMockStudentRuleData(entity2, createMockSchool()));
val error21 = validationError2.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.ENROLLED_PROGRAM_CODE.getCode()));
val error22 = validationError2.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_INDIGENOUS_SUPPORT.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.DOB.getCode()));
assertThat(error21).isTrue();
assertThat(error22).isTrue();
}

@Test
void testSchoolAgedELLRule() {
var collection = collectionRepository.save(createMockCollectionEntity());
var sdcSchoolCollectionEntity = sdcSchoolCollectionRepository.save(createMockSdcSchoolCollectionEntity(collection, null, null));
val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
val entity2 = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
entity.setEnrolledProgramCodes("17");
entity.setDob("19890101");
entity2.setEnrolledProgramCodes("17");
entity2.setDob("20230101");

val validationError = rulesProcessor.processRules(createMockStudentRuleData(entity, createMockSchool()));
val error1 = validationError.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_ELL.getCode())
Expand All @@ -885,6 +899,14 @@ void testSchoolAgedELLRule() {
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.DOB.getCode()));
assertThat(error1).isTrue();
assertThat(error2).isTrue();

val validationError2 = rulesProcessor.processRules(createMockStudentRuleData(entity2, createMockSchool()));
val error21 = validationError2.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_ELL.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.ENROLLED_PROGRAM_CODE.getCode()));
val error22 = validationError2.stream().anyMatch(val -> val.getValidationIssueCode().equals(StudentValidationIssueTypeCode.SCHOOL_AGED_ELL.getCode())
&& val.getValidationIssueFieldCode().equals(StudentValidationFieldCode.DOB.getCode()));
assertThat(error21).isTrue();
assertThat(error22).isTrue();
}

@Test
Expand Down

0 comments on commit 6b7ae53

Please sign in to comment.