-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: DetailCategoryResult 계산 메서드 명 수정 * chore: lecture fixture 소스 추가 * refactor: 공통교양 도메인 구성 * test: 공통교양 test fixture 생성 * test: CommonCultureDetailCategoryManager 테스트 작성 * feat: CommonCultureDetailCategoryManager 구현 * style: stream 코드 가독성 개선 * test: 공통 교양 test fixture 세분화 * test: 유저 test fixture 추가 * test: CommonCultureGraduationManager 테스트 작성 * test: CommonCultureGraduationManager 구현 * refactor: 불필요 임포트 제거 * refactor: 졸업 카테고리 이름 설정 방식 수정 * chore: lecture fixture 디지털리터러시의이해 과목 추가 * style: 코딩 컨벤션 준수 * chore: 오타 수정 * refactor: 세부 졸업 카테고리 완료 로직 수정 * test: 공통교양 세부 카테고리(16~19 기독교) 졸업 결과 생성 시 필수 과목 체크 로직 테스트 작성 * feat: 공통교양 세부 카테고리(16~19 기독교) 졸업 결과 생성 시 필수 과목 체크 로직 추가 * style: 불필요 임포트 및 공백 제거 * refactor: 패키지명 오타 수정
- Loading branch information
Showing
21 changed files
with
522 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ademicculture/BasicAcademicalManager.java → ...emicalculture/BasicAcademicalManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...raduatebe/graduation/domain/service/commonculture/CommonCultureDetailCategoryManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> MANDATORY_LECTURE_CODE_LIST = List.of("KMA02100", "KMA00100", "KMA00101"); | ||
|
||
public DetailCategoryResult generate(Set<TakenLecture> takenLectures, | ||
Set<CommonCulture> graduationLectures, CommonCultureCategory category) { | ||
DetailCategoryResult commonCultureDetailCategoryResult = DetailCategoryResult.create( | ||
category.getName(), checkMandatorySatisfaction(takenLectures, category), category.getTotalCredit()); | ||
Set<Lecture> taken = new HashSet<>(); | ||
|
||
Set<Lecture> 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<TakenLecture> 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<Lecture> categorizeCommonCultures(Set<CommonCulture> graduationLectures, | ||
CommonCultureCategory category) { | ||
return graduationLectures.stream() | ||
.filter(commonCulture -> commonCulture.getCommonCultureCategory() == category) | ||
.map(CommonCulture::getLecture) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...gjigraduatebe/graduation/domain/service/commonculture/CommonCultureGraduationManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CommonCulture> { | ||
|
||
@Override | ||
public DetailGraduationResult createDetailGraduationResult(StudentInformation studentInformation, | ||
Set<TakenLecture> takenLectures, | ||
Set<CommonCulture> graduationLectures, int commonCultureGraduationTotalCredit) { | ||
CommonCultureDetailCategoryManager commonCultureDetailCategoryManager = new CommonCultureDetailCategoryManager(); | ||
List<DetailCategoryResult> 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); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCulture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...in/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CommonCultureCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> containsEntryYears; | ||
|
||
public boolean isContainsEntryYear(int entryYear) { | ||
return containsEntryYears.contains(entryYear); | ||
} | ||
|
||
} |
5 changes: 0 additions & 5 deletions
5
src/test/java/com/plzgraduate/myongjigraduatebe/fixture/BasicAcademicalLectureFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CommonCultureCategoryFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<? extends Arguments> 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()) | ||
); | ||
} | ||
} |
Oops, something went wrong.