@@ -126,70 +126,7 @@ void shouldThrowExceptionWhenUserNotFound() {
126126 assertThrows (UserNotFoundException .class , () -> userService .getUserById (userId ));
127127 verify (userRepository ).findById (userId );
128128 }
129-
130- @ Test
131- @ DisplayName ("닉네임으로 유저를 검색하고 팔로워 수 높은 순으로 정렬해야 한다" )
132- void shouldSearchUsersByNicknameAndSortByFollowerCount () {
133- // given
134- String nickname = "test" ;
135- Long cursorId = null ;
136- int size = 10 ;
137-
138- // 테스트용 유저 목록 생성
139- User user1 = UserFixture .createUserWithId (1L , "User1" , "test1" );
140- User user2 = UserFixture .createUserWithId (2L , "User2" , "test2" );
141- User user3 = UserFixture .createUserWithId (3L , "User3" , "test3" );
142-
143- List <User > users = List .of (user1 , user2 , user3 );
144- Slice <User > userSlice = new SliceImpl <>(users , PageRequest .of (0 , size ), false );
145-
146- // Mock 설정
147- when (userRepository .searchUsersByCursor (
148- eq (nickname ),
149- eq (Long .MAX_VALUE ),
150- ArgumentMatchers .any (PageRequest .class )))
151- .thenReturn (userSlice );
152-
153- // 각 유저의 팔로워/팔로잉 수 설정
154- when (followRepository .countByTargetId (1L )).thenReturn (10L );
155- when (followRepository .countByInitiatorId (1L )).thenReturn (5L );
156-
157- when (followRepository .countByTargetId (2L )).thenReturn (20L );
158- when (followRepository .countByInitiatorId (2L )).thenReturn (15L );
159-
160- when (followRepository .countByTargetId (3L )).thenReturn (30L );
161- when (followRepository .countByInitiatorId (3L )).thenReturn (25L );
162-
163- // when
164- PageResponse <UserProfileResponseDto > result = userService .searchUsersByCursor (nickname , cursorId , size );
165-
166- // then
167- assertNotNull (result );
168- assertEquals (3 , result .list ().size ());
169-
170- // 팔로워 수 확인
171- assertEquals (10L , result .list ().get (0 ).followers ());
172- assertEquals (20L , result .list ().get (1 ).followers ());
173- assertEquals (30L , result .list ().get (2 ).followers ());
174-
175- // 팔로잉 수 확인
176- assertEquals (5L , result .list ().get (0 ).followings ());
177- assertEquals (15L , result .list ().get (1 ).followings ());
178- assertEquals (25L , result .list ().get (2 ).followings ());
179-
180- // 다음 커서 확인
181- assertEquals (3L , result .pageInfo ().nextCursor ());
182-
183- // 메서드 호출 확인
184- verify (userRepository ).searchUsersByCursor (
185- eq (nickname ),
186- eq (Long .MAX_VALUE ),
187- ArgumentMatchers .any (PageRequest .class ));
188-
189- verify (followRepository , times (3 )).countByTargetId (anyLong ());
190- verify (followRepository , times (3 )).countByInitiatorId (anyLong ());
191- }
192-
129+
193130 @ Test
194131 @ DisplayName ("검색 결과가 없으면 빈 리스트를 반환해야 한다" )
195132 void shouldReturnEmptyListWhenNoSearchResults () {
0 commit comments