2929import java .time .LocalDateTime ;
3030import java .util .List ;
3131import java .util .Optional ;
32+ import java .util .Set ;
3233
3334import static org .assertj .core .api .Assertions .assertThat ;
3435import static org .assertj .core .api .Assertions .assertThatThrownBy ;
36+ import static org .mockito .ArgumentMatchers .anyList ;
3537import static org .mockito .BDDMockito .given ;
3638import static org .mockito .Mockito .mock ;
3739
@@ -92,11 +94,10 @@ void getJuniorDashboard_Success() {
9294 settledOrder .updateStatus (OrderStatus .SETTLED );
9395 ReflectionTestUtils .setField (settledOrder , "id" , 3L );
9496
95- given (orderRepository .findByJunior_IdOrderByCreatedAtDesc (1L ))
97+ given (orderRepository .findByJuniorIdWithSenior (1L ))
9698 .willReturn (List .of (settledOrder , paidOrder , pendingOrder ));
97- given (reviewFeedbackRepository .existsByOrderId (1L )).willReturn (false );
98- given (reviewFeedbackRepository .existsByOrderId (2L )).willReturn (false );
99- given (reviewFeedbackRepository .existsByOrderId (3L )).willReturn (true );
99+ given (reviewFeedbackRepository .findReviewedOrderIds (anyList ()))
100+ .willReturn (Set .of (3L ));
100101
101102 // when
102103 JuniorDashboardDto result = dashboardService .getJuniorDashboard (email );
@@ -127,7 +128,7 @@ void getJuniorDashboard_Success_NoOrders() {
127128 given (junior .getId ()).willReturn (1L );
128129 given (junior .getNickname ()).willReturn ("코딩초보" );
129130 given (memberRepository .findByEmail (email )).willReturn (Optional .of (junior ));
130- given (orderRepository .findByJunior_IdOrderByCreatedAtDesc (1L )).willReturn (List .of ());
131+ given (orderRepository .findByJuniorIdWithSenior (1L )).willReturn (List .of ());
131132
132133 // when
133134 JuniorDashboardDto result = dashboardService .getJuniorDashboard (email );
@@ -203,10 +204,10 @@ void getSeniorDashboard_Success() {
203204 paidOrder .updateStatus (OrderStatus .PAID );
204205 ReflectionTestUtils .setField (paidOrder , "id" , 2L );
205206
206- given (orderRepository .findBySenior_IdOrderByCreatedAtDesc (2L ))
207+ given (orderRepository .findBySeniorIdWithJunior (2L ))
207208 .willReturn (List .of (settledOrder , paidOrder ));
208- given (reviewFeedbackRepository .existsByOrderId ( 1L )). willReturn ( true );
209- given ( reviewFeedbackRepository . existsByOrderId ( 2L )). willReturn ( false );
209+ given (reviewFeedbackRepository .findReviewedOrderIds ( anyList ()))
210+ . willReturn ( Set . of ( 1L ) );
210211
211212 // 별점 분포용 전체 후기
212213 ReviewFeedback review5 = mock (ReviewFeedback .class );
@@ -227,7 +228,7 @@ void getSeniorDashboard_Success() {
227228 given (top3Review .getComment ()).willReturn ("정말 도움이 됐어요!" );
228229 given (top3Review .getCreatedAt ()).willReturn (LocalDateTime .of (2025 , 4 , 1 , 12 , 0 ));
229230
230- given (reviewFeedbackRepository .findTop3BySeniorProfile_IdOrderByCreatedAtDesc (10L ))
231+ given (reviewFeedbackRepository .findTop3WithJuniorBySeniorProfileId (10L , PageRequest . of ( 0 , 3 ) ))
231232 .willReturn (List .of (top3Review ));
232233
233234 // when
@@ -279,9 +280,9 @@ void getSeniorDashboard_Success_NoReviews() {
279280 given (profile .getSkills ()).willReturn (List .of ());
280281 given (seniorProfileRepository .findByMemberId (2L )).willReturn (Optional .of (profile ));
281282
282- given (orderRepository .findBySenior_IdOrderByCreatedAtDesc (2L )).willReturn (List .of ());
283+ given (orderRepository .findBySeniorIdWithJunior (2L )).willReturn (List .of ());
283284 given (reviewFeedbackRepository .findBySeniorProfile_Id (10L )).willReturn (List .of ());
284- given (reviewFeedbackRepository .findTop3BySeniorProfile_IdOrderByCreatedAtDesc (10L )).willReturn (List .of ());
285+ given (reviewFeedbackRepository .findTop3WithJuniorBySeniorProfileId (10L , PageRequest . of ( 0 , 3 ) )).willReturn (List .of ());
285286
286287 // when
287288 SeniorDashBoardDto result = dashboardService .getSeniorDashboard (email );
@@ -362,7 +363,7 @@ void getSeniorReviews_Success() {
362363
363364 PageRequest pageable = PageRequest .of (0 , 10 );
364365 Page <ReviewFeedback > reviewPage = new PageImpl <>(List .of (review1 , review2 ), pageable , 2 );
365- given (reviewFeedbackRepository .findBySeniorProfile_IdOrderByCreatedAtDesc (10L , pageable ))
366+ given (reviewFeedbackRepository .findWithJuniorBySeniorProfileId (10L , pageable ))
366367 .willReturn (reviewPage );
367368
368369 // when
@@ -405,7 +406,7 @@ void getSeniorReviews_Success_NoReviews() {
405406
406407 PageRequest pageable = PageRequest .of (0 , 10 );
407408 Page <ReviewFeedback > emptyPage = new PageImpl <>(List .of (), pageable , 0 );
408- given (reviewFeedbackRepository .findBySeniorProfile_IdOrderByCreatedAtDesc (10L , pageable ))
409+ given (reviewFeedbackRepository .findWithJuniorBySeniorProfileId (10L , pageable ))
409410 .willReturn (emptyPage );
410411
411412 // when
0 commit comments