Skip to content

Commit

Permalink
test: 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Soundbar91 committed Dec 21, 2024
1 parent caa6f54 commit 6f65812
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void setup() {
Lecture 건축구조의_이해_및_실습 = lectureFixture.건축구조의_이해_및_실습(semester.getSemester());
Lecture HRD_개론 = lectureFixture.HRD_개론(semester.getSemester());

timetableV2Fixture.시간표6(user, semester, 건축구조의_이해_및_실습, HRD_개론);
timetableV2Fixture.시간표6(user, semester, 건축구조의_이해_및_실습, HRD_개론, null, null);

mockMvc.perform(
get("/timetables")
Expand Down Expand Up @@ -324,8 +324,8 @@ void setup() {
Semester semester2 = semesterFixture.semester("20201");
Lecture HRD_개론 = lectureFixture.HRD_개론(semester1.getSemester());
Lecture 건축구조의_이해_및_실습 = lectureFixture.건축구조의_이해_및_실습(semester2.getSemester());
timetableV2Fixture.시간표6(user, semester1, HRD_개론, null);
timetableV2Fixture.시간표6(user, semester2, 건축구조의_이해_및_실습, null);
timetableV2Fixture.시간표6(user, semester1, HRD_개론, null, null, null);
timetableV2Fixture.시간표6(user, semester2, 건축구조의_이해_및_실습, null, null, null);

mockMvc.perform(
get("/semesters/check")
Expand Down Expand Up @@ -553,7 +553,7 @@ void setup() {
Lecture 건축구조의_이해_및_실습 = lectureFixture.건축구조의_이해_및_실습(semester.getSemester());
Lecture HRD_개론 = lectureFixture.HRD_개론(semester.getSemester());

timetableV2Fixture.시간표6(user, semester, 건축구조의_이해_및_실습, HRD_개론);
timetableV2Fixture.시간표6(user, semester, 건축구조의_이해_및_실습, HRD_개론, null, null);

mockMvc.perform(
delete("/timetable")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import org.springframework.transaction.annotation.Transactional;

import in.koreatech.koin.AcceptanceTest;
import in.koreatech.koin.domain.graduation.model.CourseType;
import in.koreatech.koin.domain.timetable.model.Lecture;
import in.koreatech.koin.domain.timetable.model.Semester;
import in.koreatech.koin.domain.timetableV2.model.TimetableFrame;
import in.koreatech.koin.domain.timetableV2.repository.TimetableFrameRepositoryV2;
import in.koreatech.koin.domain.timetableV2.repository.TimetableLectureRepositoryV2;
import in.koreatech.koin.domain.user.model.User;
import in.koreatech.koin.fixture.CourseTypeFixture;
import in.koreatech.koin.fixture.LectureFixture;
import in.koreatech.koin.fixture.SemesterFixture;
import in.koreatech.koin.fixture.TimeTableV2Fixture;
Expand Down Expand Up @@ -48,6 +50,9 @@ public class TimetableFrameApiTest extends AcceptanceTest {
@Autowired
private TimetableLectureRepositoryV2 timetableLectureRepositoryV2;

@Autowired
private CourseTypeFixture courseTypeFixture;

private User user;
private String token;
private Semester semester;
Expand Down Expand Up @@ -165,8 +170,8 @@ void setup() {
@Test
void 강의를_담고_있는_특정_시간표_frame을_삭제한다() throws Exception {
Lecture lecture = lectureFixture.HRD_개론(semester.getSemester());

TimetableFrame frame1 = timetableV2Fixture.시간표5(user, semester, lecture);
CourseType courseType = courseTypeFixture.HRD_필수();
TimetableFrame frame1 = timetableV2Fixture.시간표5(user, semester, lecture, courseType);

mockMvc.perform(
delete("/v2/timetables/frame")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import org.springframework.transaction.annotation.Transactional;

import in.koreatech.koin.AcceptanceTest;
import in.koreatech.koin.domain.graduation.model.CourseType;
import in.koreatech.koin.domain.timetable.model.Lecture;
import in.koreatech.koin.domain.timetable.model.Semester;
import in.koreatech.koin.domain.timetableV2.model.TimetableFrame;
import in.koreatech.koin.domain.timetableV2.model.TimetableLecture;
import in.koreatech.koin.domain.user.model.User;
import in.koreatech.koin.fixture.CourseTypeFixture;
import in.koreatech.koin.fixture.LectureFixture;
import in.koreatech.koin.fixture.SemesterFixture;
import in.koreatech.koin.fixture.TimeTableV2Fixture;
Expand All @@ -42,6 +44,9 @@ public class TimetableLectureApiTest extends AcceptanceTest {
@Autowired
private LectureFixture lectureFixture;

@Autowired
private CourseTypeFixture courseTypeFixture;

private User user;
private String token;
private Semester semester;
Expand Down Expand Up @@ -75,7 +80,7 @@ void setup() {
],
"professor" : "서정빈",
"grades": "2",
"memo" : "메모"
"memo" : "메모",
},
{
"class_title": "커스텀생성2",
Expand Down Expand Up @@ -117,7 +122,8 @@ void setup() {
"lecture_class": null,
"target": null,
"professor": "서정빈",
"department": null
"department": null,
"course_type": null
},
{
"id": 2,
Expand All @@ -137,7 +143,8 @@ void setup() {
"lecture_class": null,
"target": null,
"professor": "감사 서정빈",
"department": null
"department": null,
"course_type": null
}
],
"grades": 3,
Expand Down Expand Up @@ -211,7 +218,8 @@ void setup() {
"lecture_class": null,
"target": null,
"professor": "서정빈",
"department": null
"department": null,
"course_type": null
},
{
"id": 2,
Expand All @@ -231,7 +239,8 @@ void setup() {
"lecture_class": null,
"target": null,
"professor": "알바 서정빈",
"department": null
"department": null,
"course_type": null
}
],
"grades": 0,
Expand All @@ -245,7 +254,10 @@ void setup() {
Lecture 건축구조의_이해_및_실습 = lectureFixture.건축구조의_이해_및_실습(semester.getSemester());
Lecture HRD_개론 = lectureFixture.HRD_개론(semester.getSemester());

TimetableFrame frame = timetableV2Fixture.시간표6(user, semester, 건축구조의_이해_및_실습, HRD_개론);
CourseType 전공_필수 = courseTypeFixture.전공_필수();
CourseType HRD_필수 = courseTypeFixture.HRD_필수();

TimetableFrame frame = timetableV2Fixture.시간표6(user, semester, 건축구조의_이해_및_실습, HRD_개론, 전공_필수, HRD_필수);

mockMvc.perform(
get("/v2/timetables/lecture")
Expand Down Expand Up @@ -276,7 +288,8 @@ void setup() {
"lecture_class": "01",
"target": "디자 1 건축",
"professor": "황현식",
"department": "디자인ㆍ건축공학부"
"department": "디자인ㆍ건축공학부",
"course_type": "전공 필수"
},
{
"id": 2,
Expand All @@ -296,7 +309,8 @@ void setup() {
"lecture_class": "06",
"target": "기공1",
"professor": "박한수,최준호",
"department": "기계공학부"
"department": "기계공학부",
"course_type": "MSC 필수"
}
],
"grades": 6,
Expand All @@ -309,7 +323,10 @@ void setup() {
void 시간표에서_특정_강의를_삭제한다() throws Exception {
Lecture lecture1 = lectureFixture.HRD_개론("20192");
Lecture lecture2 = lectureFixture.영어청해("20192");
TimetableFrame frame = timetableV2Fixture.시간표4(user, semester, lecture1, lecture2);
CourseType courseType1 = courseTypeFixture.HRD_필수();
CourseType courseType2 = courseTypeFixture.교양_필수();

TimetableFrame frame = timetableV2Fixture.시간표4(user, semester, lecture1, lecture2, courseType1, courseType2);

Integer lectureId = lecture1.getId();

Expand All @@ -326,7 +343,10 @@ void setup() {
void 시간표에서_특정_강의를_삭제한다_V2() throws Exception {
Lecture lecture1 = lectureFixture.HRD_개론("20192");
Lecture lecture2 = lectureFixture.영어청해("20192");
TimetableFrame frame = timetableV2Fixture.시간표4(user, semester, lecture1, lecture2);
CourseType courseType1 = courseTypeFixture.HRD_필수();
CourseType courseType2 = courseTypeFixture.교양_필수();

TimetableFrame frame = timetableV2Fixture.시간표4(user, semester, lecture1, lecture2, courseType1, courseType2);

Integer frameId = frame.getId();
Integer lectureId = lecture1.getId();
Expand All @@ -343,7 +363,10 @@ void setup() {
void 시간표에서_여러개의_강의를_한번에_삭제한다_V2() throws Exception {
Lecture lecture1 = lectureFixture.HRD_개론("20192");
Lecture lecture2 = lectureFixture.영어청해("20192");
TimetableFrame frame = timetableV2Fixture.시간표4(user, semester, lecture1, lecture2);
CourseType courseType1 = courseTypeFixture.HRD_필수();
CourseType courseType2 = courseTypeFixture.교양_필수();

TimetableFrame frame = timetableV2Fixture.시간표4(user, semester, lecture1, lecture2, courseType1, courseType2);

List<Integer> timetableLectureIds = frame.getTimetableLectures().stream()
.map(TimetableLecture::getId)
Expand All @@ -364,7 +387,9 @@ void setup() {
void 시간표에서_삭제된_강의를_복구한다_V2() throws Exception {
Lecture 건축구조의_이해_및_실습 = lectureFixture.건축구조의_이해_및_실습(semester.getSemester());
Lecture HRD_개론 = lectureFixture.HRD_개론(semester.getSemester());
TimetableFrame frame = timetableV2Fixture.시간표8(user, semester, 건축구조의_이해_및_실습, HRD_개론);
CourseType courseType1 = courseTypeFixture.전공_필수();
CourseType courseType2 = courseTypeFixture.교양_필수();
TimetableFrame frame = timetableV2Fixture.시간표8(user, semester, 건축구조의_이해_및_실습, HRD_개론, courseType1, courseType2);

List<Integer> timetableLecturesId = frame.getTimetableLectures().stream()
.map(TimetableLecture::getId)
Expand Down Expand Up @@ -401,7 +426,8 @@ void setup() {
"lecture_class": "01",
"target": "디자 1 건축",
"professor": "황현식",
"department": "디자인ㆍ건축공학부"
"department": "디자인ㆍ건축공학부",
"course_type": "전공 필수"
},
{
"id": 2,
Expand All @@ -421,7 +447,8 @@ void setup() {
"lecture_class": "06",
"target": "기공1",
"professor": "박한수,최준호",
"department": "기계공학부"
"department": "기계공학부",
"course_type": "MSC 필수"
}
],
"grades": 6,
Expand All @@ -434,7 +461,9 @@ void setup() {
void 삭제된_시간표프레임과_그에_해당하는_강의를_복구한다_V2() throws Exception {
Lecture 건축구조의_이해_및_실습 = lectureFixture.건축구조의_이해_및_실습(semester.getSemester());
Lecture HRD_개론 = lectureFixture.HRD_개론(semester.getSemester());
TimetableFrame frame = timetableV2Fixture.시간표7(user, semester, 건축구조의_이해_및_실습, HRD_개론);
CourseType courseType1 = courseTypeFixture.전공_필수();
CourseType courseType2 = courseTypeFixture.교양_필수();
TimetableFrame frame = timetableV2Fixture.시간표7(user, semester, 건축구조의_이해_및_실습, HRD_개론, courseType1, courseType2);

mockMvc.perform(
post("/v2/timetables/frame/rollback")
Expand Down Expand Up @@ -465,7 +494,8 @@ void setup() {
"lecture_class": "01",
"target": "디자 1 건축",
"professor": "황현식",
"department": "디자인ㆍ건축공학부"
"department": "디자인ㆍ건축공학부",
"course_type": "전공 필수"
},
{
"id": 2,
Expand All @@ -485,7 +515,8 @@ void setup() {
"lecture_class": "06",
"target": "기공1",
"professor": "박한수,최준호",
"department": "기계공학부"
"department": "기계공학부",
"course_type": "MSC 필수"
}
],
"grades": 6,
Expand Down
41 changes: 41 additions & 0 deletions src/test/java/in/koreatech/koin/fixture/CourseTypeFixture.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package in.koreatech.koin.fixture;

import org.springframework.stereotype.Component;

import in.koreatech.koin.domain.graduation.model.CourseType;
import in.koreatech.koin.domain.graduation.repository.CourseTypeRepository;

@Component
@SuppressWarnings("NonAsciiCharacters")
public class CourseTypeFixture {

private final CourseTypeRepository courseTypeRepository;

public CourseTypeFixture(CourseTypeRepository courseTypeRepository) {
this.courseTypeRepository = courseTypeRepository;
}

public CourseType 전공_필수() {
return courseTypeRepository.save(
CourseType.builder()
.name("전공 필수")
.build()
);
}

public CourseType HRD_필수() {
return courseTypeRepository.save(
CourseType.builder()
.name("MSC 필수")
.build()
);
}

public CourseType 교양_필수() {
return courseTypeRepository.save(
CourseType.builder()
.name("교양 필수")
.build()
);
}
}
Loading

0 comments on commit 6f65812

Please sign in to comment.