Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-1604: task is complete. #310

Merged
merged 2 commits into from
Jan 30, 2024
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 @@ -58,4 +58,6 @@ public class GradCourse {
// career life connections
private String careerLifeConnections;

// indigenous-focused
private String indigenousFocused;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class CourseProcess {
private static final String CPCOW_STR = "CPCOW";
private static final String CPSSA_STR = "CPSSA";

private static final List<String> RECENT_GRAD_PROGRAMS = Arrays.asList("2023", "2018");

private static final String ERR_MSG_FORMAT = "For {} : {}";

private static final List<CourseRequirementDTO> REMOVAL_LIST = new ArrayList<>();
Expand Down Expand Up @@ -187,6 +189,7 @@ public GradCourse convertCourseRequirement(GradCourse courseRequirement, Convers
processConsEd(courseRequirement, summary);
processFineArts(courseRequirement, summary);
processCareerLifeConnections(courseRequirement, summary);
handleExtras(courseRequirement, summary);
return courseRequirement;
}

Expand All @@ -205,10 +208,9 @@ private void processEnglish(GradCourse gradCourse, ConversionCourseSummaryDTO su

private void processEnglish10(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (StringUtils.isNotBlank(gradCourse.getEnglish10()) && StringUtils.equals(gradCourse.getEnglish10(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(),
"101"), summary);
gradCourse.getCourseLevel(), "101"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "701"), summary);
Expand All @@ -221,7 +223,7 @@ private void processEnglish10(GradCourse gradCourse, ConversionCourseSummaryDTO
private void handleFrenchLanguageCourseForEnglish10(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (hasFrenchLanguageCourse(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), summary.getAccessToken())) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "302"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -234,7 +236,7 @@ private void handleFrenchLanguageCourseForEnglish10(GradCourse gradCourse, Conve
private void handleBlankLanguageCourseForEnglish10(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (hasBlankLanguageCourse(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), summary.getAccessToken())) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "400"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -246,7 +248,7 @@ private void handleBlankLanguageCourseForEnglish10(GradCourse gradCourse, Conver

private void processEnglish11(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (StringUtils.isNotBlank(gradCourse.getEnglish11()) && StringUtils.equals(gradCourse.getEnglish11(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "102"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -266,7 +268,7 @@ private void processEnglish11(GradCourse gradCourse, ConversionCourseSummaryDTO

private void handleFrenchLanguageCourseForEnglish11(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (hasFrenchLanguageCourse(gradCourse.getCourseCode(), gradCourse.getCourseLevel(), summary.getAccessToken())) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "301"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -282,7 +284,7 @@ private void handleFrenchLanguageCourseForEnglish11(GradCourse gradCourse, Conve

private void handleBlankLanguageCourseForEnglish11(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (hasBlankLanguageCourse(gradCourse.getCourseCode(), gradCourse.getCourseLevel(), summary.getAccessToken())) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "401"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -294,7 +296,7 @@ private void handleBlankLanguageCourseForEnglish11(GradCourse gradCourse, Conver

private void processEnglish12(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (StringUtils.isNotBlank(gradCourse.getEnglish12()) && StringUtils.equals(gradCourse.getEnglish12(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "103"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -317,7 +319,7 @@ private void processEnglish12(GradCourse gradCourse, ConversionCourseSummaryDTO

private void handleFrenchLanguageCourseForEnglish12(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (hasFrenchLanguageCourse(gradCourse.getCourseCode(), gradCourse.getCourseLevel(), summary.getAccessToken())) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "300"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -332,7 +334,7 @@ private void handleFrenchLanguageCourseForEnglish12(GradCourse gradCourse, Conve

private void handleBlankLanguageCourseForEnglish12(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
if (hasBlankLanguageCourse(gradCourse.getCourseCode(), gradCourse.getCourseLevel(), summary.getAccessToken())) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "402"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -345,7 +347,7 @@ private void handleBlankLanguageCourseForEnglish12(GradCourse gradCourse, Conver
private void processSocials(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// socials10
if (StringUtils.isNotBlank(gradCourse.getSocials10()) && StringUtils.equals(gradCourse.getSocials10(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "104"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -355,7 +357,7 @@ private void processSocials(GradCourse gradCourse, ConversionCourseSummaryDTO su
}
// socials
if (StringUtils.isNotBlank(gradCourse.getSocials()) && StringUtils.equals(gradCourse.getSocials(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "105"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -377,7 +379,7 @@ private void processSocials(GradCourse gradCourse, ConversionCourseSummaryDTO su
private void processMath(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// math10
if (StringUtils.isNotBlank(gradCourse.getMath10()) && StringUtils.equals(gradCourse.getMath10(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "106"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -387,7 +389,7 @@ private void processMath(GradCourse gradCourse, ConversionCourseSummaryDTO summa
}
// math
if (StringUtils.isNotBlank(gradCourse.getMath()) && StringUtils.equals(gradCourse.getMath(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "107"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -409,7 +411,7 @@ private void processMath(GradCourse gradCourse, ConversionCourseSummaryDTO summa
private void processScience(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// science10
if (StringUtils.isNotBlank(gradCourse.getScience10()) && StringUtils.equals(gradCourse.getScience10(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "108"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -419,7 +421,7 @@ private void processScience(GradCourse gradCourse, ConversionCourseSummaryDTO su
}
// science
if (StringUtils.isNotBlank(gradCourse.getScience()) && StringUtils.equals(gradCourse.getScience(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "109"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -438,7 +440,7 @@ private void processScience(GradCourse gradCourse, ConversionCourseSummaryDTO su
private void processCareerPersonal(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// careerPersonal10
if (isCareerPersonal10(gradCourse)) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "112"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand Down Expand Up @@ -473,7 +475,7 @@ private boolean isCareerPersonal12(GradCourse gradCourse) {
private void processPhysEd(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// physEd10
if (StringUtils.isNotBlank(gradCourse.getPhysEd10()) && StringUtils.equals(gradCourse.getPhysEd10(), "Y")) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "110"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand All @@ -486,7 +488,7 @@ private void processPhysEd(GradCourse gradCourse, ConversionCourseSummaryDTO sum
private void processAppliedSkills(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// appliedSkills
if (isAppliedSkills(gradCourse)) {
if (StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "111"), summary);
} else if (StringUtils.equals(gradCourse.getGradReqtYear(), "2004")) {
Expand Down Expand Up @@ -541,7 +543,7 @@ private boolean isAppliedSkills(GradCourse gradCourse) {

private void processCareerLifeConnections(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// careerLifeConnections
if (isCareerLifeConnections(gradCourse) && StringUtils.equals(gradCourse.getGradReqtYear(), "2018")) {
if (isCareerLifeConnections(gradCourse) && isRecentGradProgram(gradCourse.getGradReqtYear())) {
createCourseRequirement(populate(gradCourse.getCourseCode(),
gradCourse.getCourseLevel(), "113"), summary);
}
Expand Down Expand Up @@ -1205,7 +1207,7 @@ private CourseRequirement createCourseRequirement(CourseRequirement courseRequir
ConversionAlert error = new ConversionAlert();
error.setLevel(ConversionAlert.AlertLevelEnum.ERROR);
error.setItem(courseRequirement.getCourseCode() + "/" + courseRequirement.getCourseLevel() + ", rule[" + courseRequirement.getRuleCode().getCourseRequirementCode() + "]");
error.setReason("GRAD Course API is failed to check Course Requirement exits!");
error.setReason("GRAD Course API is failed to check Course Requirement exists!");
summary.getErrors().add(error);
logger.error(ERR_MSG_FORMAT, error.getItem(), error.getReason());
return null;
Expand Down Expand Up @@ -1273,4 +1275,16 @@ public List<StudentCourse> getStudentCourses(String pen, String accessToken) {
return this.restUtils.getStudentCoursesByPen(pen, accessToken);
}

private void handleExtras(GradCourse gradCourse, ConversionCourseSummaryDTO summary) {
// Indigenous Focused for 2023 GRAD Program
if ("2023".equalsIgnoreCase(gradCourse.getGradReqtYear())
&& StringUtils.isNotBlank(gradCourse.getIndigenousFocused()) && StringUtils.equals(gradCourse.getIndigenousFocused(), "Y")) {
createCourseRequirement(populate(gradCourse.getCourseCode(), gradCourse.getCourseLevel(), "119"), summary);
}
}

private boolean isRecentGradProgram(String gradReqtYear) {
return RECENT_GRAD_PROGRAMS.contains(gradReqtYear);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ public void testConvertCourseRequirement_forEnglish10_2018() {
assertThat(summary.getAddedCountForCourseRequirement()).isEqualTo(1L);
}

@Test
public void testConvertCourseRequirement_forEnglish10_2023() {
ConversionCourseSummaryDTO summary = new ConversionCourseSummaryDTO();
summary.setAccessToken("123");

GradCourse traxCourse = prepareCourseRequirementData("2023", "ENG", "10", "101", null, false);
traxCourse.setEnglish10("Y");
traxCourse.setIndigenousFocused("Y");

when(this.restUtils.checkFrenchLanguageCourse("ENG", "10", "123")).thenReturn(false);
when(this.restUtils.checkBlankLanguageCourse("ENG", "10", "123")).thenReturn(false);

courseProcess.convertCourseRequirement(traxCourse, summary);
assertThat(summary.getAddedCountForCourseRequirement()).isEqualTo(2L); // "101" & "119" should be created.
}

@Test
public void testConvertCourseRequirement_forEnglish10_2004() {
ConversionCourseSummaryDTO summary = new ConversionCourseSummaryDTO();
Expand Down
Loading