Skip to content

Commit 0055d6e

Browse files
committed
Feat: 멘토링 관련 fixture 생성
1 parent a65be91 commit 0055d6e

File tree

9 files changed

+223
-4
lines changed

9 files changed

+223
-4
lines changed

back/src/test/java/com/back/domain/mentoring/mentoring/controller/MentoringControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.back.domain.mentoring.slot.entity.MentorSlot;
1313
import com.back.domain.mentoring.slot.repository.MentorSlotRepository;
1414
import com.back.fixture.MemberTestFixture;
15-
import com.back.fixture.MentoringTestFixture;
15+
import com.back.fixture.mentoring.MentoringTestFixture;
1616
import com.back.global.exception.ServiceException;
1717
import com.back.standard.util.Ut;
1818
import jakarta.servlet.http.Cookie;

back/src/test/java/com/back/domain/mentoring/reservation/controller/ReservationControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.back.domain.mentoring.reservation.repository.ReservationRepository;
1111
import com.back.domain.mentoring.slot.entity.MentorSlot;
1212
import com.back.fixture.MemberTestFixture;
13-
import com.back.fixture.MentoringTestFixture;
13+
import com.back.fixture.mentoring.MentoringTestFixture;
1414
import com.back.global.exception.ServiceException;
1515
import jakarta.servlet.http.Cookie;
1616
import org.junit.jupiter.api.BeforeEach;

back/src/test/java/com/back/domain/mentoring/slot/controller/MentorSlotControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.back.domain.mentoring.slot.error.MentorSlotErrorCode;
1212
import com.back.domain.mentoring.slot.repository.MentorSlotRepository;
1313
import com.back.fixture.MemberTestFixture;
14-
import com.back.fixture.MentoringTestFixture;
14+
import com.back.fixture.mentoring.MentoringTestFixture;
1515
import com.back.global.exception.ServiceException;
1616
import jakarta.servlet.http.Cookie;
1717
import org.junit.jupiter.api.BeforeEach;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.back.fixture;
2+
3+
import com.back.domain.member.member.entity.Member;
4+
import com.back.domain.member.mentee.entity.Mentee;
5+
import org.springframework.test.util.ReflectionTestUtils;
6+
7+
public class MenteeFixture {
8+
9+
private static final Long DEFAULT_JOB_ID = 1L;
10+
11+
public static Mentee create(Member member) {
12+
return Mentee.builder()
13+
.member(member)
14+
.jobId(DEFAULT_JOB_ID)
15+
.build();
16+
}
17+
18+
public static Mentee create(Long id, Member member) {
19+
Mentee mentee = Mentee.builder()
20+
.member(member)
21+
.jobId(DEFAULT_JOB_ID)
22+
.build();
23+
24+
ReflectionTestUtils.setField(mentee, "id", id);
25+
return mentee;
26+
}
27+
28+
public static Mentee create(Long id, Member member, Long jobId) {
29+
Mentee mentee = Mentee.builder()
30+
.member(member)
31+
.jobId(jobId)
32+
.build();
33+
34+
ReflectionTestUtils.setField(mentee, "id", id);
35+
return mentee;
36+
}
37+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.back.fixture;
2+
3+
import com.back.domain.member.member.entity.Member;
4+
import com.back.domain.member.mentor.entity.Mentor;
5+
import org.springframework.test.util.ReflectionTestUtils;
6+
7+
public class MentorFixture {
8+
9+
private static final Long DEFAULT_JOB_ID = 1L;
10+
private static final Double DEFAULT_RATE = 4.5;
11+
private static final Integer DEFAULT_CAREER_YEARS = 5;
12+
13+
public static Mentor create(Member member) {
14+
return Mentor.builder()
15+
.member(member)
16+
.jobId(DEFAULT_JOB_ID)
17+
.rate(DEFAULT_RATE)
18+
.careerYears(DEFAULT_CAREER_YEARS)
19+
.build();
20+
}
21+
22+
public static Mentor create(Long id, Member member) {
23+
Mentor mentor = Mentor.builder()
24+
.member(member)
25+
.jobId(DEFAULT_JOB_ID)
26+
.rate(DEFAULT_RATE)
27+
.careerYears(DEFAULT_CAREER_YEARS)
28+
.build();
29+
30+
ReflectionTestUtils.setField(mentor, "id", id);
31+
return mentor;
32+
}
33+
34+
public static Mentor create(Long id, Member member, Long jobId, Double rate, Integer careerYears) {
35+
Mentor mentor = Mentor.builder()
36+
.member(member)
37+
.jobId(jobId)
38+
.rate(rate)
39+
.careerYears(careerYears)
40+
.build();
41+
42+
ReflectionTestUtils.setField(mentor, "id", id);
43+
return mentor;
44+
}
45+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.back.fixture.mentoring;
2+
3+
import com.back.domain.member.mentor.entity.Mentor;
4+
import com.back.domain.mentoring.slot.entity.MentorSlot;
5+
import org.springframework.test.util.ReflectionTestUtils;
6+
7+
import java.time.LocalDateTime;
8+
9+
public class MentorSlotFixture {
10+
11+
private static final LocalDateTime DEFAULT_START_TIME = LocalDateTime.of(2025, 10, 1, 14, 0);
12+
private static final LocalDateTime DEFAULT_END_TIME = LocalDateTime.of(2025, 10, 1, 16, 0);
13+
14+
public static MentorSlot create(Mentor mentor) {
15+
return MentorSlot.builder()
16+
.mentor(mentor)
17+
.startDateTime(DEFAULT_START_TIME)
18+
.endDateTime(DEFAULT_END_TIME)
19+
.build();
20+
}
21+
22+
public static MentorSlot create(Mentor mentor, LocalDateTime startDateTime, LocalDateTime endDateTime) {
23+
return MentorSlot.builder()
24+
.mentor(mentor)
25+
.startDateTime(DEFAULT_START_TIME)
26+
.endDateTime(DEFAULT_END_TIME)
27+
.build();
28+
}
29+
30+
public static MentorSlot create(Long id, Mentor mentor) {
31+
MentorSlot slot = MentorSlot.builder()
32+
.mentor(mentor)
33+
.startDateTime(DEFAULT_START_TIME)
34+
.endDateTime(DEFAULT_END_TIME)
35+
.build();
36+
37+
ReflectionTestUtils.setField(slot, "id", id);
38+
return slot;
39+
}
40+
41+
public static MentorSlot create(Long id, Mentor mentor, LocalDateTime startDateTime, LocalDateTime endDateTime) {
42+
MentorSlot slot = MentorSlot.builder()
43+
.mentor(mentor)
44+
.startDateTime(startDateTime)
45+
.endDateTime(endDateTime)
46+
.build();
47+
48+
ReflectionTestUtils.setField(slot, "id", id);
49+
return slot;
50+
}
51+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.back.fixture.mentoring;
2+
3+
import com.back.domain.member.mentor.entity.Mentor;
4+
import com.back.domain.mentoring.mentoring.entity.Mentoring;
5+
import org.springframework.test.util.ReflectionTestUtils;
6+
7+
import java.util.List;
8+
9+
public class MentoringFixture {
10+
11+
private static final String DEFAULT_TITLE = "테스트 멘토링";
12+
private static final String DEFAULT_BIO = "테스트 설명";
13+
private static final List<String> DEFAULT_TAGS = List.of("Spring", "Java");
14+
private static final String DEFAULT_THUMB = "https://example.com/thumb.jpg";
15+
16+
public static Mentoring create(Mentor mentor) {
17+
return Mentoring.builder()
18+
.mentor(mentor)
19+
.title(DEFAULT_TITLE)
20+
.bio(DEFAULT_BIO)
21+
.tags(DEFAULT_TAGS)
22+
.thumb(DEFAULT_THUMB)
23+
.build();
24+
}
25+
26+
public static Mentoring create(Long id, Mentor mentor) {
27+
Mentoring mentoring = Mentoring.builder()
28+
.mentor(mentor)
29+
.title(DEFAULT_TITLE)
30+
.bio(DEFAULT_BIO)
31+
.tags(DEFAULT_TAGS)
32+
.thumb(DEFAULT_THUMB)
33+
.build();
34+
35+
ReflectionTestUtils.setField(mentoring, "id", id);
36+
return mentoring;
37+
}
38+
39+
public static Mentoring create(Long id, Mentor mentor, String title, String bio, List<String> tags) {
40+
Mentoring mentoring = Mentoring.builder()
41+
.mentor(mentor)
42+
.title(title)
43+
.bio(bio)
44+
.tags(tags)
45+
.thumb(DEFAULT_THUMB)
46+
.build();
47+
48+
if (id != null) {
49+
ReflectionTestUtils.setField(mentoring, "id", id);
50+
}
51+
return mentoring;
52+
}
53+
}

back/src/test/java/com/back/fixture/MentoringTestFixture.java renamed to back/src/test/java/com/back/fixture/mentoring/MentoringTestFixture.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.back.fixture;
1+
package com.back.fixture.mentoring;
22

33
import com.back.domain.member.mentee.entity.Mentee;
44
import com.back.domain.member.mentor.entity.Mentor;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.back.fixture.mentoring;
2+
3+
import com.back.domain.member.mentee.entity.Mentee;
4+
import com.back.domain.mentoring.mentoring.entity.Mentoring;
5+
import com.back.domain.mentoring.reservation.entity.Reservation;
6+
import com.back.domain.mentoring.slot.entity.MentorSlot;
7+
import org.springframework.test.util.ReflectionTestUtils;
8+
9+
public class ReservationFixture {
10+
11+
private static final String DEFAULT_PRE_QUESTION = "테스트 사전 질문입니다.";
12+
13+
public static Reservation create(Mentoring mentoring, Mentee mentee, MentorSlot mentorSlot) {
14+
return Reservation.builder()
15+
.mentoring(mentoring)
16+
.mentee(mentee)
17+
.mentorSlot(mentorSlot)
18+
.preQuestion(DEFAULT_PRE_QUESTION)
19+
.build();
20+
}
21+
22+
public static Reservation create(Long id, Mentoring mentoring, Mentee mentee, MentorSlot mentorSlot) {
23+
Reservation reservation = Reservation.builder()
24+
.mentoring(mentoring)
25+
.mentee(mentee)
26+
.mentorSlot(mentorSlot)
27+
.preQuestion(DEFAULT_PRE_QUESTION)
28+
.build();
29+
30+
ReflectionTestUtils.setField(reservation, "id", id);
31+
return reservation;
32+
}
33+
}

0 commit comments

Comments
 (0)