-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Comment 이미지 없으면 null 반환 (#111)
- Loading branch information
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ void writeComment() { | |
// then | ||
assertThat(response) | ||
.extracting("content", "userName", "imageUrls") | ||
.contains("의견 남기기", "[email protected]", List.of("")); | ||
.contains("의견 남기기", "[email protected]", List.of()); | ||
} | ||
|
||
@Test | ||
|
@@ -580,6 +580,49 @@ void findAllCommentsWithImage() { | |
); | ||
} | ||
|
||
@Test | ||
@DisplayName("의견을 조회할 때 이미지도 같이 조회 된다.(2)") | ||
void findAllCommentsWithImage2() { | ||
// given | ||
User user = userRepository.save(createUser()); | ||
Book book = bookRepository.save(createBook()); | ||
TalkRoom talkRoom = talkRoomRepository.save(createTalkRoom(book, user)); | ||
|
||
createTalkRoomRole(talkRoom); | ||
|
||
List<Comment> comments = IntStream.range(1, 6) | ||
.mapToObj(i -> Comment.builder() | ||
.talkRoom(talkRoom) | ||
.user(user) | ||
.content("의견 " + i) | ||
.registeredDateTime(LocalDateTime.now()) | ||
.build()) | ||
.toList(); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
commentRepository.save(comments.get(i)); | ||
} | ||
|
||
CommentImage images = CommentImage.createImages(comments.get(0), "이미지 1"); | ||
|
||
commentImageRepository.save(images); | ||
|
||
// when | ||
PageResponse<CommentFindAllResponse> result = commentService.findAllComments(talkRoom.getId()); | ||
|
||
// then | ||
assertThat(result.getTotalCount()).isEqualTo(5L); | ||
assertThat(result.getQueryResponse()).hasSize(5) | ||
.extracting("content", "commentImages") | ||
.containsExactly( | ||
tuple("의견 5", List.of()), | ||
tuple("의견 4", List.of()), | ||
tuple("의견 3", List.of()), | ||
tuple("의견 2", List.of()), | ||
tuple("의견 1", List.of("이미지 1")) | ||
); | ||
} | ||
|
||
private static Comment createComment(User user, TalkRoom talkRoom) { | ||
return Comment.builder() | ||
.content("의견") | ||
|