Skip to content

Commit f94d8c3

Browse files
committed
refactor: 멘티가 거절된 멘토링 조회하지 못하도록
1 parent a3588c9 commit f94d8c3

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/main/java/com/example/solidconnection/mentor/service/MentoringQueryService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.example.solidconnection.common.VerifyStatus;
66
import com.example.solidconnection.common.dto.SliceResponse;
77
import com.example.solidconnection.common.exception.CustomException;
8+
import com.example.solidconnection.common.exception.ErrorCode;
89
import com.example.solidconnection.mentor.domain.Mentor;
910
import com.example.solidconnection.mentor.domain.Mentoring;
1011
import com.example.solidconnection.mentor.dto.MentoringForMenteeResponse;
@@ -37,6 +38,9 @@ public class MentoringQueryService {
3738
public SliceResponse<MentoringForMenteeResponse> getMentoringsForMentee(
3839
long siteUserId, VerifyStatus verifyStatus, Pageable pageable
3940
) {
41+
if (verifyStatus == VerifyStatus.REJECTED) {
42+
throw new CustomException(ErrorCode.UNAUTHORIZED_MENTORING, "거절된 멘토링은 조회할 수 없습니다.");
43+
}
4044
Slice<Mentoring> mentoringSlice = mentoringRepository.findAllByMenteeIdAndVerifyStatus(siteUserId, verifyStatus, pageable);
4145
List<Mentoring> mentorings = mentoringSlice.toList();
4246

src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.example.solidconnection.mentor.service;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.assertThatCode;
45
import static org.assertj.core.api.AssertionsForClassTypes.tuple;
56

67
import com.example.solidconnection.common.VerifyStatus;
78
import com.example.solidconnection.common.dto.SliceResponse;
9+
import com.example.solidconnection.common.exception.CustomException;
10+
import com.example.solidconnection.common.exception.ErrorCode;
811
import com.example.solidconnection.mentor.domain.Mentor;
912
import com.example.solidconnection.mentor.domain.Mentoring;
1013
import com.example.solidconnection.mentor.dto.MentoringForMenteeResponse;
@@ -105,6 +108,7 @@ class 멘토의_멘토링_목록_조회_테스트 {
105108
// given
106109
Mentoring mentoring1 = mentoringFixture.대기중_멘토링(mentor1.getId(), menteeUser1.getId());
107110
Mentoring mentoring2 = mentoringFixture.승인된_멘토링(mentor1.getId(), menteeUser2.getId());
111+
108112
// when
109113
SliceResponse<MentoringForMentorResponse> response = mentoringQueryService.getMentoringsForMentor(mentorUser1.getId(), pageable);
110114

@@ -130,6 +134,17 @@ class 멘토의_멘토링_목록_조회_테스트 {
130134
@Nested
131135
class 멘티의_멘토링_목록_조회_테스트 {
132136

137+
@Test
138+
void 거절된_멘토링_목록을_조회하면_예외가_발생한다() {
139+
// given
140+
mentoringFixture.거절된_멘토링(mentor1.getId(), menteeUser1.getId());
141+
142+
// when & then
143+
assertThatCode(() -> mentoringQueryService.getMentoringsForMentee(menteeUser1.getId(), VerifyStatus.REJECTED, pageable))
144+
.isInstanceOf(CustomException.class)
145+
.hasMessageContaining(ErrorCode.UNAUTHORIZED_MENTORING.getMessage());
146+
}
147+
133148
@Test
134149
void 승인된_멘토링_목록을_조회한다() {
135150
// given

0 commit comments

Comments
 (0)