Skip to content

Commit

Permalink
test: 경영학과 수정 케이스 테스트 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
stophwan committed Jun 11, 2024
1 parent ccf7220 commit 623c623
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

public class InternationalTradeFixture {
public static final Map<String, Lecture> mockLectureMap = LectureFixture.getMockLectureMap();


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.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 com.plzgraduate.myongjigraduatebe.fixture.LectureFixture;
import com.plzgraduate.myongjigraduatebe.fixture.UserFixture;
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.takenlecture.domain.model.TakenLectureInventory;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;

class OptionalMandatoryMandatoryMajorHandlerTest {

private static final User user = UserFixture.경영학과_19학번_ENG12();
private static final MajorGraduationCategory majorGraduationCategory = MajorGraduationCategory.PRIMARY;
private static final Map<String, Lecture> mockLectureMap = LectureFixture.getMockLectureMap();

@DisplayName("3개 중에 1개를 수강할 경우 세부조건을 달성한다.")
@Test
void 세개중한과목_수강() {

//given
Set<Lecture> mandatoryLectures = new HashSet<>(Set.of(
mockLectureMap.get("HBX01128"), //국제통상원론
mockLectureMap.get("HBX01127"), //국제경영학
mockLectureMap.get("HBY01103"), //경영정보(구)
mockLectureMap.get("HBX01125"), //경영정보(신)
mockLectureMap.get("HBX01105"), //재무관리원론
mockLectureMap.get("HBX01113") //인적자원관리
));
Set<Lecture> electiveLectures = new HashSet<>();
Set<TakenLecture> takenLectures = Set.of(
TakenLecture.of(user, mockLectureMap.get("HBX01128"), 2020, Semester.FIRST), //국제통상원론
TakenLecture.of(user, mockLectureMap.get("HBX01105"), 2020, Semester.SECOND), //재무관리원론
TakenLecture.of(user, mockLectureMap.get("HBX01113"), 2020, Semester.SECOND) //인적자원관리
);
TakenLectureInventory takenLectureInventory = TakenLectureInventory.from(takenLectures);

//when
MandatoryMajorSpecialCaseHandler exceptionHandler = new OptionalMandatoryMandatoryMajorHandler();
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = exceptionHandler.getMandatorySpecialCaseInformation(
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
boolean checkMandatoryCondition = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
int removedMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();

//then
assertThat(checkMandatoryCondition).isTrue();
assertThat(removedMandatoryTotalCredit).isZero();
assertThat(mandatoryLectures).hasSize(3);
assertThat(electiveLectures).hasSize(3);
}

@DisplayName("3개 중에 0개를 수강할 경우 세부조건을 달성하지 못한다.")
@Test
void 전공선택과목_미수강() {

//given
Set<Lecture> mandatoryLectures = new HashSet<>(Set.of(
mockLectureMap.get("HBX01128"), //국제통상원론
mockLectureMap.get("HBX01127"), //국제경영학
mockLectureMap.get("HBY01103"), //경영정보(구)
mockLectureMap.get("HBX01125"), //경영정보(신)
mockLectureMap.get("HBX01105"), //재무관리원론
mockLectureMap.get("HBX01113") //인적자원관리
));
Set<Lecture> electiveLectures = new HashSet<>();
Set<TakenLecture> takenLectures = Set.of(
TakenLecture.of(user, mockLectureMap.get("HBX01105"), 2020, Semester.SECOND), //재무관리원론
TakenLecture.of(user, mockLectureMap.get("HBX01113"), 2020, Semester.SECOND) //인적자원관리
);
TakenLectureInventory takenLectureInventory = TakenLectureInventory.from(takenLectures);

//when
MandatoryMajorSpecialCaseHandler exceptionHandler = new OptionalMandatoryMandatoryMajorHandler();
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = exceptionHandler.getMandatorySpecialCaseInformation(
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
boolean checkMandatoryCondition = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
int removedMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();

//then
assertThat(checkMandatoryCondition).isFalse();
assertThat(removedMandatoryTotalCredit).isEqualTo(6);
assertThat(mandatoryLectures).hasSize(6);
assertThat(electiveLectures).hasSize(0);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major.exception;
package com.plzgraduate.myongjigraduatebe.graduation.domain.service.major;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -23,6 +23,7 @@
@DisplayName("21학번 이전 철학과 학생의 경우 폐지된 전공필수의 대체 과목을 인정한다.")
class ReplaceMandatoryMajorHandlerTest {
private static final User user = UserFixture.철학과_20학번();
private static final MajorGraduationCategory majorGraduationCategory = MajorGraduationCategory.PRIMARY;
private static final Map<String, Lecture> mockLectureMap = LectureFixture.getMockLectureMap();

@DisplayName("답사1와 답사2를 수강했을 경우 세부조건을 달성한다.")
Expand Down Expand Up @@ -50,8 +51,7 @@ class ReplaceMandatoryMajorHandlerTest {
//when
MandatoryMajorSpecialCaseHandler exceptionHandler = new ReplaceMandatoryMandatoryMajorHandler();
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = exceptionHandler.getMandatorySpecialCaseInformation(
takenLectureInventory,
mandatoryLectures, electiveLectures);
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
boolean checkMandatoryCondition = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
int removedMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();

Expand Down Expand Up @@ -86,8 +86,7 @@ class ReplaceMandatoryMajorHandlerTest {
//when
MandatoryMajorSpecialCaseHandler exceptionHandler = new ReplaceMandatoryMandatoryMajorHandler();
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = exceptionHandler.getMandatorySpecialCaseInformation(
takenLectureInventory,
mandatoryLectures, electiveLectures);
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
boolean checkMandatoryCondition = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
int removedMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();

Expand Down Expand Up @@ -118,8 +117,7 @@ class ReplaceMandatoryMajorHandlerTest {
//when
MandatoryMajorSpecialCaseHandler exceptionHandler = new ReplaceMandatoryMandatoryMajorHandler();
MandatorySpecialCaseInformation mandatorySpecialCaseInformation = exceptionHandler.getMandatorySpecialCaseInformation(
takenLectureInventory,
mandatoryLectures, electiveLectures);
user, majorGraduationCategory, takenLectureInventory, mandatoryLectures, electiveLectures);
boolean checkMandatoryCondition = mandatorySpecialCaseInformation.isCompleteMandatorySpecialCase();
int removedMandatoryTotalCredit = mandatorySpecialCaseInformation.getRemovedMandatoryTotalCredit();

Expand Down

0 comments on commit 623c623

Please sign in to comment.