|
6 | 6 |
|
7 | 7 | import java.util.List; |
8 | 8 | import java.util.Optional; |
| 9 | +import java.util.stream.IntStream; |
9 | 10 |
|
10 | 11 | import org.junit.jupiter.api.DisplayName; |
11 | 12 | import org.junit.jupiter.api.Test; |
@@ -149,26 +150,26 @@ void getCommentsList_In_DiaryDetail_Success() { |
149 | 150 | int size = 5; |
150 | 151 | Long cursorCommentId = null; |
151 | 152 |
|
152 | | - List<Comment> commentList = CommentFixture.createCommentsListFixture(size + 1); // hasNext 판별 위해 +1 |
| 153 | + List<CommentResponseDto> dtoList = CommentFixture.createCommentDtos(size + 1); |
| 154 | + |
153 | 155 | Pageable pageable = PageRequest.of(0, size); |
154 | | - boolean hasNext = commentList.size() > size; |
| 156 | + boolean hasNext = dtoList.size() > size; |
| 157 | + List<CommentResponseDto> sliced = hasNext ? dtoList.subList(0, size) : dtoList; |
155 | 158 |
|
156 | | - List<Comment> sliced = hasNext ? commentList.subList(0, size) : commentList; |
| 159 | + Slice<CommentResponseDto> slice = new SliceImpl<>(sliced, pageable, hasNext); |
157 | 160 |
|
158 | | - Slice<Comment> slice = new SliceImpl<>(sliced, pageable, hasNext); |
159 | | - given(commentRepository.findByDiaryIdWithCursor(diaryId, cursorCommentId, pageable)) |
| 161 | + given(commentRepository.findWithUserByDiaryId(diaryId, cursorCommentId, pageable)) |
160 | 162 | .willReturn(slice); |
161 | 163 |
|
162 | 164 | // when |
163 | | - PageResponse<CommentResponseDto> response = commentService.getCommentListByDiary(diaryId, cursorCommentId, |
164 | | - size); |
| 165 | + PageResponse<CommentResponseDto> response = commentService.getCommentListByDiary(diaryId, cursorCommentId, size); |
165 | 166 |
|
166 | 167 | // then |
167 | 168 | assertThat(response.list()).hasSize(sliced.size()); |
168 | 169 | assertThat(response.pageInfo().hasNext()).isEqualTo(hasNext); |
169 | | - assertThat(response.pageInfo().nextCursor()).isEqualTo(hasNext ? sliced.getLast().getCommentId() : null); |
| 170 | + assertThat(response.pageInfo().nextCursor()).isEqualTo(hasNext ? sliced.getLast().commentId() : null); |
170 | 171 |
|
171 | | - verify(commentRepository).findByDiaryIdWithCursor(diaryId, cursorCommentId, pageable); |
| 172 | + verify(commentRepository).findWithUserByDiaryId(diaryId, cursorCommentId, pageable); |
172 | 173 | } |
173 | 174 |
|
174 | 175 | } |
0 commit comments