|
8 | 8 | import java.util.List;
|
9 | 9 | import net.pengcook.authentication.domain.UserInfo;
|
10 | 10 | import net.pengcook.comment.dto.CommentOfRecipeResponse;
|
| 11 | +import net.pengcook.comment.dto.CommentOfUserResponse; |
11 | 12 | import net.pengcook.comment.dto.CreateCommentRequest;
|
12 | 13 | import net.pengcook.comment.exception.NotFoundException;
|
13 | 14 | import net.pengcook.comment.exception.UnauthorizedDeletionException;
|
@@ -81,7 +82,8 @@ void deleteComment() {
|
81 | 82 |
|
82 | 83 | assertAll(
|
83 | 84 | () -> assertThat(commentRepository.count()).isEqualTo(INITIAL_COMMENT_COUNT - 1),
|
84 |
| - () -> assertThat(recipeRepository.findById(recipeId).orElseThrow().getCommentCount()).isEqualTo(before - 1) |
| 85 | + () -> assertThat(recipeRepository.findById(recipeId).orElseThrow().getCommentCount()).isEqualTo( |
| 86 | + before - 1) |
85 | 87 | );
|
86 | 88 | }
|
87 | 89 |
|
@@ -120,4 +122,18 @@ void deleteCommentsByUser() {
|
120 | 122 |
|
121 | 123 | assertThat(commentRepository.count()).isEqualTo(INITIAL_COMMENT_COUNT - 2);
|
122 | 124 | }
|
| 125 | + |
| 126 | + @Test |
| 127 | + @DisplayName("특정 사용자의 댓글을 조회한다.") |
| 128 | + void readCommentsOfUser() { |
| 129 | + UserInfo userInfo = new UserInfo(2, "loki@pengcook.net"); |
| 130 | + List<CommentOfUserResponse> expect = List.of( |
| 131 | + new CommentOfUserResponse(1L, 1L, "김밥", LocalDateTime.of(2024, 1, 1, 0, 0, 0), "great"), |
| 132 | + new CommentOfUserResponse(3L, 2L, "김치찌개", LocalDateTime.of(2024, 5, 5, 0, 0, 0), "good") |
| 133 | + ); |
| 134 | + |
| 135 | + List<CommentOfUserResponse> actual = commentService.readCommentsOfUser(userInfo); |
| 136 | + |
| 137 | + assertThat(actual).containsExactlyInAnyOrderElementsOf(expect); |
| 138 | + } |
123 | 139 | }
|
0 commit comments