@@ -53,7 +53,6 @@ class MentorQueryServiceTest {
5353 private UniversityFixture universityFixture ;
5454
5555 private University university ;
56- private String region = "아시아" ;
5756
5857 @ BeforeEach
5958 void setUp () {
@@ -124,7 +123,7 @@ class 멘토_단일_조회_실패 {
124123 }
125124
126125 @ Nested
127- class 멘토_미리보기_목록_조회 {
126+ class 멘토_미리보기_목록_정보_조회 {
128127
129128 private static final int NO_NEXT_PAGE_NUMBER = -1 ;
130129
@@ -150,7 +149,7 @@ void setUp() {
150149 Channel channel2 = channelFixture .채널 (2 , mentor2 );
151150
152151 // when
153- SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews (region , currentUser .getId (), PageRequest .of (0 , 10 ));
152+ SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews ("" , currentUser .getId (), PageRequest .of (0 , 10 ));
154153
155154 // then
156155 Map <Long , MentorPreviewResponse > mentorPreviewMap = response .content ().stream ()
@@ -173,38 +172,70 @@ void setUp() {
173172 }
174173
175174 @ Test
176- void 멘토들에_대한_나의_멘토링_지원_여부를_조회한다 () {
175+ void 다음_페이지_번호를_응답한다 () {
177176 // given
178- mentoringFixture .대기중_멘토링 (mentor1 .getId (), currentUser .getId ());
179-
180- // when
181- SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews (region , currentUser .getId (), PageRequest .of (0 , 10 ));
177+ SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews ("" , currentUser .getId (), PageRequest .of (0 , 1 ));
182178
183179 // then
184- Map <Long , MentorPreviewResponse > mentorPreviewMap = response .content ().stream ()
185- .collect (Collectors .toMap (MentorPreviewResponse ::id , Function .identity ()));
186- assertAll (
187- () -> assertThat (mentorPreviewMap .get (mentor1 .getId ()).isApplied ()).isTrue (),
188- () -> assertThat (mentorPreviewMap .get (mentor2 .getId ()).isApplied ()).isFalse ()
189- );
180+ assertThat (response .nextPageNumber ()).isEqualTo (2 );
190181 }
191182
192183 @ Test
193- void 다음_페이지_번호를_응답한다 () {
184+ void 다음_페이지가_없으면_페이지_없음을_의미하는_값을_응답한다 () {
194185 // given
195- SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews (region , currentUser .getId (), PageRequest .of (0 , 1 ));
186+ SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews ("" , currentUser .getId (), PageRequest .of (0 , 10 ));
196187
197188 // then
198- assertThat (response .nextPageNumber ()).isEqualTo (2 );
189+ assertThat (response .nextPageNumber ()).isEqualTo (NO_NEXT_PAGE_NUMBER );
190+ }
191+ }
192+
193+ @ Nested
194+ class 멘토_미리보기_목록_필터링 {
195+
196+ private Mentor asiaMentor , europeMentor ;
197+ private SiteUser currentUser ;
198+ private University asiaUniversity , europeUniversity ;
199+
200+ @ BeforeEach
201+ void setUp () {
202+ currentUser = siteUserFixture .사용자 (1 , "사용자1" );
203+ SiteUser mentorUser1 = siteUserFixture .사용자 (2 , "멘토1" );
204+ SiteUser mentorUser2 = siteUserFixture .사용자 (3 , "멘토2" );
205+ asiaUniversity = universityFixture .메이지_대학 ();
206+ europeUniversity = universityFixture .린츠_카톨릭_대학 ();
207+ asiaMentor = mentorFixture .멘토 (mentorUser1 .getId (), asiaUniversity .getId ());
208+ europeMentor = mentorFixture .멘토 (mentorUser2 .getId (), europeUniversity .getId ());
199209 }
200210
201211 @ Test
202- void 다음_페이지가_없으면_페이지_없음을_의미하는_값을_응답한다 () {
203- // given
204- SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews (region , currentUser .getId (), PageRequest .of (0 , 10 ));
212+ void 권역으로_멘토_목록을_필터링한다 () {
213+ // when
214+ SliceResponse <MentorPreviewResponse > asiaFilteredResponse = mentorQueryService .getMentorPreviews (
215+ asiaUniversity .getRegion ().getKoreanName (), currentUser .getId (), PageRequest .of (0 , 10 ));
216+ SliceResponse <MentorPreviewResponse > europeFilteredResponse = mentorQueryService .getMentorPreviews (
217+ europeUniversity .getRegion ().getKoreanName (), currentUser .getId (), PageRequest .of (0 , 10 ));
205218
206219 // then
207- assertThat (response .nextPageNumber ()).isEqualTo (NO_NEXT_PAGE_NUMBER );
220+ assertAll (
221+ () -> assertThat (asiaFilteredResponse .content ()).hasSize (1 )
222+ .extracting (MentorPreviewResponse ::id )
223+ .containsExactly (asiaMentor .getId ()),
224+ () -> assertThat (europeFilteredResponse .content ()).hasSize (1 )
225+ .extracting (MentorPreviewResponse ::id )
226+ .containsExactly (europeMentor .getId ())
227+ );
228+ }
229+
230+ @ Test
231+ void 권역을_지정하지_않으면_전체_멘토_목록을_조회한다 () {
232+ // when
233+ SliceResponse <MentorPreviewResponse > response = mentorQueryService .getMentorPreviews ("" , currentUser .getId (), PageRequest .of (0 , 10 ));
234+
235+ // then
236+ assertThat (response .content ()).hasSize (2 )
237+ .extracting (MentorPreviewResponse ::id )
238+ .containsExactlyInAnyOrder (asiaMentor .getId (), europeMentor .getId ());
208239 }
209240 }
210241}
0 commit comments