diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailCategoryResult.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailCategoryResult.java index e66aeec0..811189e1 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailCategoryResult.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailCategoryResult.java @@ -14,6 +14,7 @@ public class DetailCategoryResult { private final String detailCategoryName; private boolean isCompleted; + private final boolean isSatisfiedMandatory; private final int totalCredits; private int takenCredits; private final List takenMandatoryLectures = new ArrayList<>(); @@ -22,28 +23,33 @@ public class DetailCategoryResult { private final List haveToElectiveLectures = new ArrayList<>(); @Builder - private DetailCategoryResult(String detailCategoryName, boolean isCompleted, int totalCredits, int takenCredits) { + private DetailCategoryResult(String detailCategoryName, boolean isCompleted, boolean isSatisfiedMandatory, + int totalCredits, int takenCredits) { this.detailCategoryName = detailCategoryName; this.isCompleted = isCompleted; + this.isSatisfiedMandatory = isSatisfiedMandatory; this.totalCredits = totalCredits; this.takenCredits = takenCredits; } - public static DetailCategoryResult create(String detailCategoryName, int totalCredits) { + public static DetailCategoryResult create(String detailCategoryName, boolean isSatisfiedMandatory, + int totalCredits) { return DetailCategoryResult.builder() .detailCategoryName(detailCategoryName) .isCompleted(false) + .isSatisfiedMandatory(isSatisfiedMandatory) .totalCredits(totalCredits) .takenCredits(0) .build(); } - public void calculateBasicAcademicCulture(Set taken, Set basicAcademicalLectures) { + public void calculate(Set taken, Set basicAcademicalLectures) { addTakenLectures(taken); if(!checkCompleted()) { addMandatoryLectures(taken, basicAcademicalLectures); } } + private void addTakenLectures(Set taken) { taken.forEach(lecture -> { takenMandatoryLectures.add(lecture); @@ -57,7 +63,7 @@ private void addMandatoryLectures(Set taken, Set basicAcademic } private boolean checkCompleted() { - isCompleted = totalCredits <= takenCredits; + isCompleted = totalCredits <= takenCredits && isSatisfiedMandatory; return isCompleted; } } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailGraduationResult.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailGraduationResult.java index fd2b32a0..6cccabdd 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailGraduationResult.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/model/DetailGraduationResult.java @@ -26,7 +26,7 @@ private DetailGraduationResult(String categoryName, boolean isCompleted, int tot public static DetailGraduationResult create(GraduationCategory graduationCategory, int totalCredit, List detailCategoryResults) { return DetailGraduationResult.builder() - .categoryName(graduationCategory.name()) + .categoryName(graduationCategory.getName()) .isCompleted(checkIsCompleted(detailCategoryResults)) .totalCredit(totalCredit) .takenCredit(calculateTakenCredit(detailCategoryResults)) @@ -47,6 +47,8 @@ private static boolean checkIsCompleted(List detailCategor } private static int calculateTakenCredit(List detailCategoryResults) { - return detailCategoryResults.stream().mapToInt(DetailCategoryResult::getTakenCredits).sum(); + return detailCategoryResults.stream() + .mapToInt(DetailCategoryResult::getTakenCredits) + .sum(); } } diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BasicAcademicalManager.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BasicAcademicalManager.java similarity index 96% rename from src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BasicAcademicalManager.java rename to src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BasicAcademicalManager.java index 0878909a..09de68c4 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BasicAcademicalManager.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BasicAcademicalManager.java @@ -1,4 +1,4 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BusinessBasicAcademicalManager.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BusinessBasicAcademicalManager.java similarity index 94% rename from src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BusinessBasicAcademicalManager.java rename to src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BusinessBasicAcademicalManager.java index 95c15312..3cc1a950 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BusinessBasicAcademicalManager.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BusinessBasicAcademicalManager.java @@ -1,4 +1,4 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.BASIC_ACADEMICAL_CULTURE; @@ -39,7 +39,7 @@ public DetailGraduationResult createDetailGraduationResult(StudentInformation st Set graduationLectures, int basicAcademicalCredit) { Set basicAcademicalLectures = convertToLectureSet(graduationLectures); DetailCategoryResult detailCategoryResult = DetailCategoryResult.create( - BASIC_ACADEMICAL_CULTURE.name(), basicAcademicalCredit); + BASIC_ACADEMICAL_CULTURE.getName(), true, basicAcademicalCredit); Set removedTakenLecture = new HashSet<>(); Set taken = new HashSet<>(); @@ -53,7 +53,7 @@ public DetailGraduationResult createDetailGraduationResult(StudentInformation st taken.add(takenLecture.getLecture()); }); - detailCategoryResult.calculateBasicAcademicCulture(taken, basicAcademicalLectures); + detailCategoryResult.calculate(taken, basicAcademicalLectures); takenLectures.removeAll(removedTakenLecture); return DetailGraduationResult.create(BASIC_ACADEMICAL_CULTURE, basicAcademicalCredit, diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/DefaultBasicAcademicalManager.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/DefaultBasicAcademicalManager.java similarity index 91% rename from src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/DefaultBasicAcademicalManager.java rename to src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/DefaultBasicAcademicalManager.java index ba3dc746..dabc9285 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/DefaultBasicAcademicalManager.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/DefaultBasicAcademicalManager.java @@ -1,4 +1,4 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.BASIC_ACADEMICAL_CULTURE; @@ -28,7 +28,7 @@ public DetailGraduationResult createDetailGraduationResult(StudentInformation st Set graduationLectures, int basicAcademicalCredit) { DetailCategoryResult detailCategoryResult = DetailCategoryResult.create( - BASIC_ACADEMICAL_CULTURE.name(), basicAcademicalCredit); + BASIC_ACADEMICAL_CULTURE.getName(), true, basicAcademicalCredit); Set basicAcademicalLectures = convertToLectureSet(graduationLectures); @@ -42,7 +42,7 @@ public DetailGraduationResult createDetailGraduationResult(StudentInformation st taken.add(takenLecture.getLecture()); }); - detailCategoryResult.calculateBasicAcademicCulture(taken, basicAcademicalLectures); + detailCategoryResult.calculate(taken, basicAcademicalLectures); takenLectures.removeAll(removedTakenLecture); return DetailGraduationResult.create(BASIC_ACADEMICAL_CULTURE, basicAcademicalCredit, diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/SocialScienceBasicAcademicManager.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/SocialScienceBasicAcademicManager.java similarity index 93% rename from src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/SocialScienceBasicAcademicManager.java rename to src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/SocialScienceBasicAcademicManager.java index 4e4072d2..ddabe25d 100644 --- a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/SocialScienceBasicAcademicManager.java +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/SocialScienceBasicAcademicManager.java @@ -1,4 +1,4 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.BASIC_ACADEMICAL_CULTURE; @@ -39,7 +39,7 @@ public DetailGraduationResult createDetailGraduationResult(StudentInformation st Set basicAcademicalLectures = convertToLectureSet(graduationLectures); DetailCategoryResult detailCategoryResult = DetailCategoryResult.create( - BASIC_ACADEMICAL_CULTURE.name(), basicAcademicalCredit); + BASIC_ACADEMICAL_CULTURE.getName(), true, basicAcademicalCredit); Set removedTakenLecture = new HashSet<>(); Set taken = new HashSet<>(); @@ -52,7 +52,7 @@ public DetailGraduationResult createDetailGraduationResult(StudentInformation st taken.add(takenLecture.getLecture()); }); - detailCategoryResult.calculateBasicAcademicCulture(taken, basicAcademicalLectures); + detailCategoryResult.calculate(taken, basicAcademicalLectures); takenLectures.removeAll(removedTakenLecture); return DetailGraduationResult.create(BASIC_ACADEMICAL_CULTURE, 12, List.of(detailCategoryResult)); diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManager.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManager.java new file mode 100644 index 00000000..1b4f70a5 --- /dev/null +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManager.java @@ -0,0 +1,52 @@ +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.commonculture; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCulture; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; +import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture; + +class CommonCultureDetailCategoryManager { + + private static final List MANDATORY_LECTURE_CODE_LIST = List.of("KMA02100", "KMA00100", "KMA00101"); + + public DetailCategoryResult generate(Set takenLectures, + Set graduationLectures, CommonCultureCategory category) { + DetailCategoryResult commonCultureDetailCategoryResult = DetailCategoryResult.create( + category.getName(), checkMandatorySatisfaction(takenLectures, category), category.getTotalCredit()); + Set taken = new HashSet<>(); + + Set graduationCommonCultureLectures = categorizeCommonCultures( + graduationLectures, category); + + takenLectures.stream() + .filter(takenLecture -> graduationCommonCultureLectures.contains(takenLecture.getLecture())) + .forEach(takenLecture -> taken.add(takenLecture.getLecture())); + + commonCultureDetailCategoryResult.calculate(taken, graduationCommonCultureLectures); + + return commonCultureDetailCategoryResult; + } + + private boolean checkMandatorySatisfaction(Set takenLectures, CommonCultureCategory category) { + if (category == CommonCultureCategory.CHRISTIAN_A) { + return takenLectures.stream() + .anyMatch( + takenLecture -> MANDATORY_LECTURE_CODE_LIST.contains(takenLecture.getLecture().getLectureCode())); + } + return true; + } + + private Set categorizeCommonCultures(Set graduationLectures, + CommonCultureCategory category) { + return graduationLectures.stream() + .filter(commonCulture -> commonCulture.getCommonCultureCategory() == category) + .map(CommonCulture::getLecture) + .collect(Collectors.toSet()); + } +} diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManager.java b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManager.java new file mode 100644 index 00000000..fe563877 --- /dev/null +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManager.java @@ -0,0 +1,36 @@ +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.commonculture; + +import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.*; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult; +import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailGraduationResult; +import com.plzgraduate.myongjigraduatebe.graduation.domain.service.GraduationManager; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCulture; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory; +import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture; +import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentInformation; + +public class CommonCultureGraduationManager implements GraduationManager { + + @Override + public DetailGraduationResult createDetailGraduationResult(StudentInformation studentInformation, + Set takenLectures, + Set graduationLectures, int commonCultureGraduationTotalCredit) { + CommonCultureDetailCategoryManager commonCultureDetailCategoryManager = new CommonCultureDetailCategoryManager(); + List commonCultureDetailCategoryResults = Arrays.stream(CommonCultureCategory.values()) + .filter( + commonCultureCategory -> commonCultureCategory.isContainsEntryYear(studentInformation.getEntryYear())) + .map(commonCultureCategory -> commonCultureDetailCategoryManager.generate(takenLectures, + graduationLectures, commonCultureCategory)) + .collect(Collectors.toList()); + + return DetailGraduationResult.create(COMMON_CULTURE, commonCultureGraduationTotalCredit, + commonCultureDetailCategoryResults); + } + +} diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCulture.java b/src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCulture.java new file mode 100644 index 00000000..2469b283 --- /dev/null +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCulture.java @@ -0,0 +1,23 @@ +package com.plzgraduate.myongjigraduatebe.lecture.domain.model; + +import lombok.Builder; +import lombok.Getter; + +@Getter +public class CommonCulture { + + private Lecture lecture; + private CommonCultureCategory commonCultureCategory; + + @Builder + private CommonCulture(Lecture lecture, CommonCultureCategory commonCultureCategory) { + this.lecture = lecture; + this.commonCultureCategory = commonCultureCategory; + } + + public static CommonCulture of(Lecture lecture, CommonCultureCategory category) { + return CommonCulture.builder() + .lecture(lecture) + .commonCultureCategory(category).build(); + } +} diff --git a/src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCultureCategory.java b/src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCultureCategory.java new file mode 100644 index 00000000..5149ffc5 --- /dev/null +++ b/src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCultureCategory.java @@ -0,0 +1,25 @@ +package com.plzgraduate.myongjigraduatebe.lecture.domain.model; + +import java.util.List; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum CommonCultureCategory { + CHRISTIAN_A("기독교", 4, List.of(16, 17, 18, 19)), + CHRISTIAN_B("기독교",4, List.of(20, 21, 22, 23)), + EXPRESSION("사고와 표현", 3, List.of(16, 17, 18, 19, 20 ,21, 22, 23)), + CAREER("진로", 2, List.of(18, 19, 20, 21, 22)), + DIGITAL_LITERACY("진로와디지털리터러시", 2, List.of(23)); + + private final String name; + private final int totalCredit; + private final List containsEntryYears; + + public boolean isContainsEntryYear(int entryYear) { + return containsEntryYears.contains(entryYear); + } + +} diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/BasicAcademicalLectureFixture.java b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/BasicAcademicalLectureFixture.java index 00631d96..4ab4094d 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/BasicAcademicalLectureFixture.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/BasicAcademicalLectureFixture.java @@ -1,14 +1,9 @@ package com.plzgraduate.myongjigraduatebe.fixture; -import static org.assertj.core.api.Assertions.*; - import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - import com.plzgraduate.myongjigraduatebe.lecture.domain.model.BasicAcademicalCulture; import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureCategoryFixture.java b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureCategoryFixture.java new file mode 100644 index 00000000..dc0aa44f --- /dev/null +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureCategoryFixture.java @@ -0,0 +1,31 @@ +package com.plzgraduate.myongjigraduatebe.fixture; + +import static com.plzgraduate.myongjigraduatebe.fixture.CommonCultureFixture.*; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.*; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; + + +public class CommonCultureCategoryFixture implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) throws Exception { + return Stream.of( + Arguments.arguments(CHRISTIAN_A, 공통교양_16_17()), + Arguments.arguments(CHRISTIAN_A, 공통교양_18_19()), + Arguments.arguments(CHRISTIAN_B, 공통교양_20_21_22()), + Arguments.arguments(CHRISTIAN_B, 공통교양_23()), + Arguments.arguments(EXPRESSION, 공통교양_16_17()), + Arguments.arguments(EXPRESSION, 공통교양_18_19()), + Arguments.arguments(EXPRESSION, 공통교양_20_21_22()), + Arguments.arguments(EXPRESSION, 공통교양_23()), + Arguments.arguments(CAREER, 공통교양_18_19()), + Arguments.arguments(CAREER, 공통교양_20_21_22()), + Arguments.arguments(DIGITAL_LITERACY, 공통교양_23()) + ); + } +} diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureFixture.java b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureFixture.java new file mode 100644 index 00000000..52851afc --- /dev/null +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureFixture.java @@ -0,0 +1,87 @@ +package com.plzgraduate.myongjigraduatebe.fixture; + +import static com.plzgraduate.myongjigraduatebe.fixture.UserFixture.*; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.CAREER; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.CHRISTIAN_A; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.CHRISTIAN_B; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.DIGITAL_LITERACY; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.EXPRESSION; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; + +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCulture; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; + +public class CommonCultureFixture implements ArgumentsProvider { + + public static final Map mockLectureMap = LectureFixture.getMockLectureMap(); + + @Override + public Stream provideArguments(ExtensionContext context) throws Exception { + return Stream.of( + Arguments.arguments(영문학과_16학번(), 공통교양_16_17()), + Arguments.arguments(영문학과_18학번(), 공통교양_18_19()), + Arguments.arguments(행정학과_21학번(), 공통교양_20_21_22()), + Arguments.arguments(경영학과_23학번(), 공통교양_23()) + ); + } + + public static Set 공통교양_16_17() { + Set lectureSet = new HashSet<>(); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02100"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA00100"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA00101"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02102"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02103"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02122"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02104"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02105"), EXPRESSION)); + return lectureSet; + } + + public static Set 공통교양_18_19() { + Set lectureSet = new HashSet<>(); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02100"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA00100"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA00101"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02102"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02103"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02122"), CHRISTIAN_A)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02104"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02105"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02137"), CAREER)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02141"), CAREER)); + return lectureSet; + } + + public static Set 공통교양_20_21_22() { + Set lectureSet = new HashSet<>(); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA00101"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02102"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02103"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02122"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02104"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02105"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02141"), CAREER)); + return lectureSet; + } + + public static Set 공통교양_23() { + Set lectureSet = new HashSet<>(); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA00101"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02102"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02103"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02122"), CHRISTIAN_B)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02104"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02105"), EXPRESSION)); + lectureSet.add(CommonCulture.of(mockLectureMap.get("KMA02141"), DIGITAL_LITERACY)); + return lectureSet; + } +} diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/LectureFixture.java b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/LectureFixture.java index 807049b1..8d3d6f81 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/LectureFixture.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/LectureFixture.java @@ -1,7 +1,5 @@ package com.plzgraduate.myongjigraduatebe.fixture; -import static org.assertj.core.api.Assertions.*; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -46,10 +44,8 @@ private static void setUpMockLectureMap() { Lecture lecture = Lecture.of(lectureCode, name, credit, isRevoked, duplicateCode); mockLectureMap.put(lectureCode, lecture); } - } catch (IOException e) { e.printStackTrace(); } - } } diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/UserFixture.java b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/UserFixture.java index cec48f6f..2f99afe1 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/UserFixture.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/fixture/UserFixture.java @@ -7,6 +7,11 @@ public class UserFixture { + public static User 영문학과_16학번() { + StudentInformation studentInformation = StudentInformation.of(16, "영어영문학과", StudentCategory.NORMAL); + return User.create("mj01", "1234", EnglishLevel.ENG12, "김영문", 60161001, studentInformation); + } + public static User 영문학과_18학번() { StudentInformation studentInformation = StudentInformation.of(18, "영어영문학과", StudentCategory.NORMAL); return User.create("mj01", "1234", EnglishLevel.ENG12, "김영문", 60181001, studentInformation); @@ -32,4 +37,9 @@ public class UserFixture { return User.create("mj22", "1234", EnglishLevel.ENG34, "김경영", 60221022, studentInformation); } + public static User 경영학과_23학번() { + StudentInformation studentInformation = StudentInformation.of(23, "경영학과", StudentCategory.NORMAL); + return User.create("mj22", "1234", EnglishLevel.ENG34, "김경영", 60231022, studentInformation); + } + } diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BusinessBasicAcademicalManagerTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BusinessBasicAcademicalManagerTest.java similarity index 93% rename from src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BusinessBasicAcademicalManagerTest.java rename to src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BusinessBasicAcademicalManagerTest.java index aae0814b..a3ddec71 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/BusinessBasicAcademicalManagerTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/BusinessBasicAcademicalManagerTest.java @@ -1,14 +1,12 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.filter; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -59,11 +57,11 @@ class 경영학과_학문기초교양 { //then assertThat(detailGraduationResult) .extracting("categoryName", "isCompleted", "totalCredit", "takenCredit") - .contains("BASIC_ACADEMICAL_CULTURE", true, 6, 6); + .contains("학문기초교양", true, 6, 6); assertThat(detailCategoryResult) .extracting("detailCategoryName", "isCompleted", "totalCredits", "takenCredits") - .contains("BASIC_ACADEMICAL_CULTURE", true, 6, 6); + .contains("학문기초교양", true, 6, 6); assertThat(detailCategoryResult.getTakenMandatoryLectures()).hasSize(2); assertThat(detailCategoryResult.getHaveToMandatoryLectures()).isEmpty(); @@ -92,11 +90,11 @@ class 경영학과_학문기초교양 { //then assertThat(detailGraduationResult) .extracting("categoryName", "isCompleted", "totalCredit", "takenCredit") - .contains("BASIC_ACADEMICAL_CULTURE", false, 3, 6); + .contains("학문기초교양", false, 3, 6); assertThat(detailCategoryResult) .extracting("detailCategoryName", "isCompleted", "totalCredits", "takenCredits") - .contains("BASIC_ACADEMICAL_CULTURE", false, 3, 6); + .contains("학문기초교양", false, 3, 6); assertThat(detailCategoryResult.getTakenMandatoryLectures()).hasSize(1); assertThat(detailCategoryResult.getHaveToMandatoryLectures()).hasSize(1); diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/DefaultBasicAcademicalManagerTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/DefaultBasicAcademicalManagerTest.java similarity index 94% rename from src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/DefaultBasicAcademicalManagerTest.java rename to src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/DefaultBasicAcademicalManagerTest.java index 8491288f..ca88ba20 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/DefaultBasicAcademicalManagerTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/DefaultBasicAcademicalManagerTest.java @@ -1,4 +1,4 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import static org.assertj.core.api.Assertions.*; @@ -56,11 +56,11 @@ class 인문대_학문기초교양 { //then assertThat(detailGraduationResult) .extracting("categoryName", "isCompleted", "totalCredit", "takenCredit") - .contains("BASIC_ACADEMICAL_CULTURE", true, 12, 15); + .contains("학문기초교양", true, 12, 15); assertThat(detailCategoryResult) .extracting("detailCategoryName", "isCompleted", "totalCredits", "takenCredits") - .contains("BASIC_ACADEMICAL_CULTURE", true, 12, 15); + .contains("학문기초교양", true, 12, 15); assertThat(detailCategoryResult.getTakenMandatoryLectures()).hasSize(5); assertThat(detailCategoryResult.getHaveToMandatoryLectures()).isEmpty(); @@ -87,11 +87,11 @@ class 인문대_학문기초교양 { //then assertThat(detailGraduationResult) .extracting("categoryName", "isCompleted", "totalCredit", "takenCredit") - .contains("BASIC_ACADEMICAL_CULTURE", false, 12, 9); + .contains("학문기초교양", false, 12, 9); assertThat(detailCategoryResult) .extracting("detailCategoryName", "isCompleted", "totalCredits", "takenCredits") - .contains("BASIC_ACADEMICAL_CULTURE", false, 12, 9); + .contains("학문기초교양", false, 12, 9); assertThat(detailCategoryResult.getTakenMandatoryLectures()).hasSize(3); assertThat(detailCategoryResult.getHaveToMandatoryLectures()).hasSize(10); diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/SocialScienceBasicAcademicManagerTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/SocialScienceBasicAcademicManagerTest.java similarity index 94% rename from src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/SocialScienceBasicAcademicManagerTest.java rename to src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/SocialScienceBasicAcademicManagerTest.java index be6442e4..0643a47c 100644 --- a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicculture/SocialScienceBasicAcademicManagerTest.java +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/basicacademicalculture/SocialScienceBasicAcademicManagerTest.java @@ -1,4 +1,4 @@ -package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicculture; +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.basicacademicalculture; import static org.assertj.core.api.Assertions.assertThat; @@ -55,11 +55,11 @@ class 이십삼년도_이후_교과목_포함 { //then assertThat(detailGraduationResult) .extracting("categoryName", "isCompleted", "totalCredit", "takenCredit") - .contains("BASIC_ACADEMICAL_CULTURE", true, 12, 12); + .contains("학문기초교양", true, 12, 12); assertThat(detailCategoryResult) .extracting("detailCategoryName", "isCompleted", "totalCredits", "takenCredits") - .contains("BASIC_ACADEMICAL_CULTURE", true, 12, 12); + .contains("학문기초교양", true, 12, 12); assertThat(detailCategoryResult.getTakenMandatoryLectures()).hasSize(4); assertThat(detailCategoryResult.getHaveToMandatoryLectures()).isEmpty(); @@ -87,11 +87,11 @@ class 이십삼년도_이후_교과목_포함 { //then assertThat(detailGraduationResult) .extracting("categoryName", "isCompleted", "totalCredit", "takenCredit") - .contains("BASIC_ACADEMICAL_CULTURE", false, 12, 6); + .contains("학문기초교양", false, 12, 6); assertThat(detailCategoryResult) .extracting("detailCategoryName", "isCompleted", "totalCredits", "takenCredits") - .contains("BASIC_ACADEMICAL_CULTURE", false, 12, 6); + .contains("학문기초교양", false, 12, 6); assertThat(detailCategoryResult.getTakenMandatoryLectures()).hasSize(2); assertThat(detailCategoryResult.getHaveToMandatoryLectures()).hasSize(17); diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManagerTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManagerTest.java new file mode 100644 index 00000000..ee0cb3f7 --- /dev/null +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManagerTest.java @@ -0,0 +1,124 @@ +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.commonculture; + +import static com.plzgraduate.myongjigraduatebe.fixture.CommonCultureFixture.*; +import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory.*; +import static org.assertj.core.api.Assertions.*; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ArgumentsSource; + +import com.plzgraduate.myongjigraduatebe.fixture.CommonCultureCategoryFixture; +import com.plzgraduate.myongjigraduatebe.fixture.LectureFixture; +import com.plzgraduate.myongjigraduatebe.fixture.UserFixture; +import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailCategoryResult; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCulture; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCultureCategory; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; +import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.Semester; +import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture; +import com.plzgraduate.myongjigraduatebe.user.domain.model.User; + +@DisplayName("각 공통교양 세부 카테고리 별 카테고리 이름, 총 학점, 이수 여부를 포함한 카테고리 졸업 결과를 생성한다.") +class CommonCultureDetailCategoryManagerTest { + + Map mockLectureMap = LectureFixture.getMockLectureMap(); + CommonCultureDetailCategoryManager manager = new CommonCultureDetailCategoryManager(); + + @DisplayName("각 카테고리의 해당하는 과목의 이수 학점을 만족한 경우 이수 완료의 카테고리 졸업 결과를 생성한다.") + @ParameterizedTest + @ArgumentsSource(CommonCultureCategoryFixture.class) + void generateCompletedCommonCultureDetailCategory(CommonCultureCategory commonCultureCategory, + Set graduationLectures) { + //given + User user = UserFixture.경영학과_19학번(); + Set takenLectures = new HashSet<>((Set.of( + TakenLecture.of(user, mockLectureMap.get("KMA00101"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02102"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02122"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02104"), 2023, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02141"), 2023, Semester.FIRST) + ))); + String commonCultureCategoryName = commonCultureCategory.getName(); + int categoryTotalCredit = commonCultureCategory.getTotalCredit(); + + //when + DetailCategoryResult detailCategoryResult = manager.generate(takenLectures, graduationLectures, + commonCultureCategory); + + //then + assertThat(detailCategoryResult) + .extracting("detailCategoryName", "isCompleted", "totalCredits") + .contains(commonCultureCategoryName, true, categoryTotalCredit); + } + + @DisplayName("각 카테고리의 해당하는 과목의 이수 학점을 만족하지 못한 경우 이수 미 완료의 카테고리 졸업 결과를 생성한다.") + @ParameterizedTest + @ArgumentsSource(CommonCultureCategoryFixture.class) + void generateUnCompletedCommonCultureDetailCategory(CommonCultureCategory commonCultureCategory, + Set graduationLectures) { + //given + Set takenLectures = new HashSet<>(); + String commonCultureCategoryName = commonCultureCategory.getName(); + int categoryTotalCredit = commonCultureCategory.getTotalCredit(); + + //when + DetailCategoryResult detailCategoryResult = manager.generate(takenLectures, graduationLectures, + commonCultureCategory); + + //then + assertThat(detailCategoryResult) + .extracting("detailCategoryName", "isCompleted", "totalCredits") + .contains(commonCultureCategoryName, false, categoryTotalCredit); + } + + @DisplayName("16~19 학번의 기독교 카테고리는 필수 과목을 수강해야 이수 완료의 카테고리 졸업 결과를 생성할 수 있다.") + @Test + void generateMandatorySatisfactionCommonCultureDetailCategory() { + //given + User user = UserFixture.경영학과_19학번(); + Set takenLectures = new HashSet<>((Set.of( + TakenLecture.of(user, mockLectureMap.get("KMA00101"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02102"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02122"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02104"), 2023, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02141"), 2023, Semester.FIRST) + ))); + Set graduationLectures = 공통교양_16_17(); // == 공통교양_18_19 + + //when + DetailCategoryResult detailCategoryResult = manager.generate(takenLectures, graduationLectures, CHRISTIAN_A); + + //then + assertThat(detailCategoryResult) + .extracting("detailCategoryName", "isCompleted", "isSatisfiedMandatory", "totalCredits") + .contains(CHRISTIAN_A.getName(), true, true, CHRISTIAN_A.getTotalCredit()); + } + + @DisplayName("16~19 학번의 기독교 카테고리는 필수 과목을 수강하지 않으면 수강 학점이 카테고리의 총 학점 이상이어도 이수 미완료 졸업 결과를 생성한다.") + @Test + void generateMandatoryUnSatisfactionCommonCultureDetailCategory() { + //given + User user = UserFixture.경영학과_19학번(); + Set takenLectures = new HashSet<>((Set.of( + TakenLecture.of(user, mockLectureMap.get("KMA02102"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02122"), 2023, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02103"), 2023, Semester.FIRST) + ))); + Set graduationLectures = 공통교양_16_17(); // == 공통교양_18_19 + + //when + DetailCategoryResult detailCategoryResult = manager.generate(takenLectures, graduationLectures, CHRISTIAN_A); + + //then + assertThat(detailCategoryResult) + .extracting("detailCategoryName", "isCompleted", "isSatisfiedMandatory", "totalCredits") + .contains(CHRISTIAN_A.getName(), false, false, CHRISTIAN_A.getTotalCredit()); + } + +} diff --git a/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManagerTest.java b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManagerTest.java new file mode 100644 index 00000000..8e9f773d --- /dev/null +++ b/src/test/java/com/plzgraduate/myongjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManagerTest.java @@ -0,0 +1,75 @@ +package com.plzgraduate.myongjigraduatebe.graduation.domain.service.commonculture; + + +import static org.assertj.core.api.Assertions.*; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ArgumentsSource; + +import com.plzgraduate.myongjigraduatebe.fixture.CommonCultureFixture; +import com.plzgraduate.myongjigraduatebe.fixture.LectureFixture; +import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailGraduationResult; +import com.plzgraduate.myongjigraduatebe.graduation.domain.service.GraduationManager; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CommonCulture; +import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; +import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.Semester; +import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture; +import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentInformation; +import com.plzgraduate.myongjigraduatebe.user.domain.model.User; + +@DisplayName("각 공통교양 세부 카테고리 졸업 결과를 포함한 공통교양 전체 졸업 결과를 생성한다.") +class CommonCultureGraduationManagerTest { + + Map mockLectureMap = LectureFixture.getMockLectureMap(); + GraduationManager graduationManager = new CommonCultureGraduationManager(); + + @DisplayName("모든 공통교양 세부 카테고리가 이수 완료일 경우 이수 완료 공통교양 전체 졸업 결과를 생성한다.") + @ParameterizedTest + @ArgumentsSource(CommonCultureFixture.class) + void generateCompletedDetailGraduationResult(User user, Set graduationLectures) { + //given + StudentInformation studentInformation = user.getStudentInformation(); + Set takenLectures = new HashSet<>((Set.of( + TakenLecture.of(user, mockLectureMap.get("KMA00101"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02102"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02122"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02104"), 2023, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02141"), 2023, Semester.FIRST) + ))); + + //when + DetailGraduationResult detailGraduationResult = graduationManager.createDetailGraduationResult( + studentInformation, takenLectures, graduationLectures, 17); + //then + assertThat(detailGraduationResult) + .extracting("categoryName", "isCompleted") + .contains("공통교양", true); + } + + @DisplayName("모든 공통교양 세부 카테고리가 이수 완료가 아닐 경우 이수 미 완료 공통교양 전체 졸업 결과를 생성한다.") + @ParameterizedTest + @ArgumentsSource(CommonCultureFixture.class) + void generateUnCompletedDetailGraduationResult(User user, Set graduationLectures) { + //given + StudentInformation studentInformation = user.getStudentInformation(); + Set takenLectures = new HashSet<>((Set.of( + TakenLecture.of(user, mockLectureMap.get("KMA02122"), 2019, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02104"), 2023, Semester.FIRST), + TakenLecture.of(user, mockLectureMap.get("KMA02141"), 2023, Semester.FIRST) + ))); + + //when + DetailGraduationResult detailGraduationResult = graduationManager.createDetailGraduationResult( + studentInformation, takenLectures, graduationLectures, 17); + //then + assertThat(detailGraduationResult) + .extracting("categoryName", "isCompleted") + .contains("공통교양", false); + } + +} diff --git a/src/test/resources/lecture.csv b/src/test/resources/lecture.csv index e6b560ed..53644005 100644 --- a/src/test/resources/lecture.csv +++ b/src/test/resources/lecture.csv @@ -1,3 +1,23 @@ +KMA02100, 성경개론, 2, 1, null +KMA00100, 성서의이해, 2, 1, KMA02100 +KMA00101, 성서와인간이해, 2, 0, KMA00100 +KMA02101, 채플, 0, 0, null +KMA02102, 현대사회와기독교윤리, 2, 0, null +KMA02103, 종교와과학, 2, 0, null +KMA02122, 기독교와문화, 2, 0, null +KMA02104, 글쓰기, 3, 0, null +KMA02105, 발표와토의, 3, 0, null +KMA02106, 영어1, 2, 0, null +KMA02107, 영어2, 2, 0, null +KMA02123, 영어3, 2, 0, null +KMA02124, 영어4, 2, 0, null +KMA02108, 영어회화1, 1, 0, null +KMA02109, 영어회화2, 1, 0, null +KMA02125, 영어회화3, 1, 0, null +KMA02126, 영어회화4, 1, 0, null +KMA02137, 4차산업혁명시대의진로선택, 2, 1, null +KMA02141, 4차산업혁명과미래사회진로선택, 2, 0, KMA02137 +KMA02157, 디지털리터러시의이해, 2, 0, null KMB02127, 한국문화와문자생활, 3, 0, null KMB02119, 영어와영미문화, 3, 1, null KMB02120, 아랍의언어와문화, 3, 0, null