-
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: 누락 로직 추가 * chore: 핵심교양 데이터 추가 * test: 핵심교양 fixture 작성 * test: 핵심교양 세부 카테고리 결과 테스트 작성 * feat: 핵심교양 세부 카테고리 결과 반환 구현 * test: 불필요 import 제거 * test: fixture 클래스명 변경 * test: 핵심교양 세부 졸업 결과 테스트 작성 * test: 핵심교양 세부 졸업 결과 반환 구현 * refactor: 세부 카테고리 잔여 학점 관련 필드 추가 * test: 핵심교양 - 과학과기술 예외사항 로직 테스트 작성 * feat: 핵심교양 - 과학과기술 예외사항 로직 구현 * test: 핵심교양 문화와예술 예외사항 로직 테스트 작성 * test: 핵심교양 문화와예술 예외사항 로직 구현 * refactor: DetailCategoryResult leftCredit 계산 로직 수정
- Loading branch information
Showing
16 changed files
with
613 additions
and
26 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
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
79 changes: 79 additions & 0 deletions
79
...gjigraduatebe/graduation/domain/service/coreculture/CoreCultureDetailCategoryManager.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,79 @@ | ||
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.coreculture; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.Semester.*; | ||
|
||
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.CoreCulture; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.Lecture; | ||
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentInformation; | ||
|
||
public class CoreCultureDetailCategoryManager { | ||
|
||
private static final List<String> ICT_DEPARTMENTS = List.of( | ||
"응용소프트웨어학과", | ||
"데이터테크놀로지학과", | ||
"디지털콘텐츠디자인학과"); | ||
private static final Lecture 과학과기술_예외_과목 = Lecture.from("KMA02136"); | ||
private static final Set<Lecture> 문화와예술_예외_과목 = Set.of( | ||
Lecture.from("KMA02155"), | ||
Lecture.from("KMA02156")); | ||
|
||
public DetailCategoryResult generate(StudentInformation studentInformation, Set<TakenLecture> takenLectures, | ||
Set<CoreCulture> graduationLectures, CoreCultureCategory category) { | ||
Set<Lecture> graduationCoreCultureLectures = categorizeCommonCultures(graduationLectures, category); | ||
Set<TakenLecture> finishedTakenLecture = new HashSet<>(); | ||
Set<Lecture> taken = new HashSet<>(); | ||
|
||
takenLectures.stream() | ||
.filter(takenLecture -> graduationCoreCultureLectures.contains(takenLecture.getLecture())) | ||
.forEach(takenLecture -> { | ||
finishedTakenLecture.add(takenLecture); | ||
taken.add(takenLecture.getLecture()); | ||
}); | ||
takenLectures.removeAll(finishedTakenLecture); | ||
|
||
DetailCategoryResult commonCultureDetailCategoryResult = DetailCategoryResult.create( | ||
category.getName(), true, category.getTotalCredit()); | ||
calculateFreeElectiveLeftCredit(studentInformation, taken, commonCultureDetailCategoryResult); | ||
calculateNormalLeftCredit(taken, finishedTakenLecture, commonCultureDetailCategoryResult); | ||
commonCultureDetailCategoryResult.calculate(taken, graduationCoreCultureLectures); | ||
|
||
return commonCultureDetailCategoryResult; | ||
} | ||
|
||
private Set<Lecture> categorizeCommonCultures(Set<CoreCulture> graduationLectures, | ||
CoreCultureCategory category) { | ||
return graduationLectures.stream() | ||
.filter(coreCulture -> coreCulture.getCoreCultureCategory() == category) | ||
.map(CoreCulture::getLecture) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
private void calculateFreeElectiveLeftCredit(StudentInformation studentInformation, Set<Lecture> taken, | ||
DetailCategoryResult commonCultureDetailCategoryResult) { | ||
if (ICT_DEPARTMENTS.contains(studentInformation.getDepartment()) && (taken.contains(과학과기술_예외_과목))) { | ||
taken.remove(과학과기술_예외_과목); | ||
int exceptionLectureCredit = 3; | ||
commonCultureDetailCategoryResult.addFreeElectiveLeftCredit(exceptionLectureCredit); | ||
} | ||
} | ||
|
||
private void calculateNormalLeftCredit(Set<Lecture> taken, Set<TakenLecture> finishedTakenLecture, | ||
DetailCategoryResult commonCultureDetailCategoryResult) { | ||
int normalLeftCredit = finishedTakenLecture.stream() | ||
.filter(takenLecture -> 문화와예술_예외_과목.contains(takenLecture.getLecture()) | ||
&& takenLecture.getYear() == 2022 | ||
&& takenLecture.getSemester() == FIRST) | ||
.mapToInt(takenLecture -> takenLecture.getLecture().getCredit()) | ||
.sum(); | ||
taken.removeAll(문화와예술_예외_과목); | ||
commonCultureDetailCategoryResult.addNormalLeftCredit(normalLeftCredit); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...myongjigraduatebe/graduation/domain/service/coreculture/CoreCultureGraduationManager.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.graduation.domain.service.coreculture; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory.CORE_CULTURE; | ||
|
||
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.CoreCulture; | ||
import com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory; | ||
import com.plzgraduate.myongjigraduatebe.takenlecture.domain.model.TakenLecture; | ||
import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentInformation; | ||
|
||
public class CoreCultureGraduationManager implements GraduationManager<CoreCulture> { | ||
@Override | ||
public DetailGraduationResult createDetailGraduationResult(StudentInformation studentInformation, | ||
Set<TakenLecture> takenLectures, Set<CoreCulture> graduationLectures, int coreCultureGraduationTotalCredit) { | ||
CoreCultureDetailCategoryManager coreCultureDetailCategoryManager = new CoreCultureDetailCategoryManager(); | ||
List<DetailCategoryResult> coreCultureDetailCategoryResults = Arrays.stream(CoreCultureCategory.values()) | ||
.map(coreCultureCategory -> coreCultureDetailCategoryManager.generate(studentInformation, takenLectures, | ||
graduationLectures, coreCultureCategory)) | ||
.collect(Collectors.toList()); | ||
|
||
return DetailGraduationResult.create(CORE_CULTURE, coreCultureGraduationTotalCredit, | ||
coreCultureDetailCategoryResults); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CoreCulture.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 CoreCulture { | ||
|
||
private Lecture lecture; | ||
private CoreCultureCategory coreCultureCategory; | ||
|
||
@Builder | ||
private CoreCulture(Lecture lecture, CoreCultureCategory coreCultureCategory) { | ||
this.lecture = lecture; | ||
this.coreCultureCategory = coreCultureCategory; | ||
} | ||
|
||
public static CoreCulture of(Lecture lecture, CoreCultureCategory category) { | ||
return CoreCulture.builder() | ||
.lecture(lecture) | ||
.coreCultureCategory(category).build(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...main/java/com/plzgraduate/myongjigraduatebe/lecture/domain/model/CoreCultureCategory.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,18 @@ | ||
package com.plzgraduate.myongjigraduatebe.lecture.domain.model; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum CoreCultureCategory { | ||
|
||
HISTORY_PHILOSOPHY("역사와철학", 3), | ||
SOCIETY_COMMUNITY("사회와공동체", 3), | ||
CULTURE_ART("문화와예술", 3), | ||
SCIENCE_TECHNOLOGY("과학과기술", 3); | ||
|
||
private final String name; | ||
private final int totalCredit; | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
src/test/java/com/plzgraduate/myongjigraduatebe/fixture/CoreCultureCategoryFixture.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,28 @@ | ||
package com.plzgraduate.myongjigraduatebe.fixture; | ||
|
||
import static com.plzgraduate.myongjigraduatebe.fixture.CoreCultureFixture.핵심교양_과학과기술; | ||
import static com.plzgraduate.myongjigraduatebe.fixture.CoreCultureFixture.핵심교양_문화와예술; | ||
import static com.plzgraduate.myongjigraduatebe.fixture.CoreCultureFixture.핵심교양_사회와공동체; | ||
import static com.plzgraduate.myongjigraduatebe.fixture.CoreCultureFixture.핵심교양_역사와철학; | ||
import static com.plzgraduate.myongjigraduatebe.lecture.domain.model.CoreCultureCategory.*; | ||
|
||
import java.util.Map; | ||
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 CoreCultureCategoryFixture implements ArgumentsProvider { | ||
|
||
@Override | ||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception { | ||
return Stream.of( | ||
Arguments.arguments(HISTORY_PHILOSOPHY,핵심교양_역사와철학()), | ||
Arguments.arguments(SOCIETY_COMMUNITY, 핵심교양_사회와공동체()), | ||
Arguments.arguments(CULTURE_ART, 핵심교양_문화와예술()), | ||
Arguments.arguments(SCIENCE_TECHNOLOGY, 핵심교양_과학과기술()) | ||
); | ||
} | ||
} |
Oops, something went wrong.