diff --git a/src/test/java/com/chooz/commentLike/application/CommentLikeCommandServiceTest.java b/src/test/java/com/chooz/commentLike/application/CommentLikeCommandServiceTest.java index f697a1d..8494f6d 100644 --- a/src/test/java/com/chooz/commentLike/application/CommentLikeCommandServiceTest.java +++ b/src/test/java/com/chooz/commentLike/application/CommentLikeCommandServiceTest.java @@ -34,6 +34,8 @@ class CommentLikeCommandServiceTest extends IntegrationTest { void createCommentLike() { //given, when CommentLike commentLike = createAndGetSavedCommentLike(); + int count = commentLikeRepository.countByCommentId(commentLike.getCommentId()); + //then assertThat(commentLike).isNotNull(); } @@ -46,7 +48,7 @@ void deleteCommentLike() { // when commentLikeService.deleteCommentLike(commentLike.getCommentId(),commentLike.getId(), commentLike.getUserId()); - + int count = commentLikeRepository.countByCommentId(commentLike.getCommentId()); // then assertThat(commentLikeRepository.existsById(commentLike.getId())).isFalse(); } diff --git a/src/test/java/com/chooz/commentLike/presentation/CommentLikeControllerTest.java b/src/test/java/com/chooz/commentLike/presentation/CommentLikeControllerTest.java index 7133a51..bd7b85e 100644 --- a/src/test/java/com/chooz/commentLike/presentation/CommentLikeControllerTest.java +++ b/src/test/java/com/chooz/commentLike/presentation/CommentLikeControllerTest.java @@ -9,7 +9,6 @@ import org.springframework.restdocs.payload.JsonFieldType; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; @@ -47,7 +46,7 @@ void createCommentLike() throws Exception { .description("댓글좋아요 ID"), fieldWithPath("likeCount") .type(JsonFieldType.NUMBER) - .description("댓글좋아요 ID") + .description("댓글좋아요 수") ) )); } @@ -58,7 +57,7 @@ void createCommentLike() throws Exception { void deleteCommentLike() throws Exception { //given CommentLikeIdResponse commentLikeIdResponse = - new CommentLikeIdResponse(commentLikeId, 10); + new CommentLikeIdResponse(null, 10); given(commentLikeService.deleteCommentLike(commentId, commentLikeId, userId)) .willReturn(commentLikeIdResponse); //when then @@ -73,10 +72,11 @@ void deleteCommentLike() throws Exception { responseFields( fieldWithPath("commentLikeId") .type(JsonFieldType.NUMBER) - .description("댓글좋아요 ID"), + .description("댓글좋아요 ID") + .optional(), fieldWithPath("likeCount") .type(JsonFieldType.NUMBER) - .description("댓글좋아요 ID") + .description("댓글좋아요 수") ) )); }