From 865606ca68bed327969a01d0496e2911eba34105 Mon Sep 17 00:00:00 2001 From: Rebwon Date: Mon, 11 Oct 2021 16:08:22 +0900 Subject: [PATCH] Refactor code - remove unnecessary test code - remove comment domain service update assert statement --- .../MybatisArticleRepositoryTests.java | 34 -------------- .../comment/domain/CommentProcessorTest.java | 8 +--- .../MybatisCommentRepositoryTest.java | 44 ------------------- 3 files changed, 2 insertions(+), 84 deletions(-) delete mode 100644 src/test/java/com/yam/app/article/infrastructure/MybatisArticleRepositoryTests.java delete mode 100644 src/test/java/com/yam/app/comment/infrastructure/MybatisCommentRepositoryTest.java diff --git a/src/test/java/com/yam/app/article/infrastructure/MybatisArticleRepositoryTests.java b/src/test/java/com/yam/app/article/infrastructure/MybatisArticleRepositoryTests.java deleted file mode 100644 index 48391c8..0000000 --- a/src/test/java/com/yam/app/article/infrastructure/MybatisArticleRepositoryTests.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.yam.app.article.infrastructure; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.yam.app.article.domain.Article; -import com.yam.app.article.domain.ArticleReader; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -@Disabled -final class MybatisArticleRepositoryTests { - - @Autowired - private ArticleReader articleReader; - - @Test - void articleReader_find_by_title() { - Article article = articleReader.findByTitle("sample-title"); - - assertThat(article).isNotNull(); - } - - @Test - void articleReader_find_by_id() { - Article article = articleReader.findById(1L).get(); - - assertThat(article.getTags().size()).isEqualTo(3); - } -} diff --git a/src/test/java/com/yam/app/comment/domain/CommentProcessorTest.java b/src/test/java/com/yam/app/comment/domain/CommentProcessorTest.java index 89b9501..fbe35f0 100644 --- a/src/test/java/com/yam/app/comment/domain/CommentProcessorTest.java +++ b/src/test/java/com/yam/app/comment/domain/CommentProcessorTest.java @@ -47,15 +47,11 @@ final class CommentProcessorTest { DynamicTest.dynamicTest("댓글 수정에 성공한다.", () -> { // Act - var modifiedAt = fakeCommentRepository.findById(commentId).get() - .getModifiedAt(); - processor.update("new content", commentId, memberId); - var comment = fakeCommentRepository.findById(commentId).get(); + var updateComment = fakeCommentRepository.findById(commentId).get(); // Assert - assertThat(comment.getContent()).isEqualTo("new content"); - assertThat(comment.getModifiedAt().isAfter(modifiedAt)).isTrue(); + assertThat(updateComment.getContent()).isEqualTo("new content"); }), DynamicTest.dynamicTest("댓글 작성시 유효한 게시글이 존재하지 않는 경우 예외를 반환한다.", () -> { diff --git a/src/test/java/com/yam/app/comment/infrastructure/MybatisCommentRepositoryTest.java b/src/test/java/com/yam/app/comment/infrastructure/MybatisCommentRepositoryTest.java deleted file mode 100644 index 886a10b..0000000 --- a/src/test/java/com/yam/app/comment/infrastructure/MybatisCommentRepositoryTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.yam.app.comment.infrastructure; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import com.yam.app.comment.domain.CommentReader; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -@Disabled -final class MybatisCommentRepositoryTest { - - @Autowired - CommentReader commentReader; - - @Test - void findById() { - var comment = commentReader.findById(1L); - if (comment.isPresent()) { - assertThat(comment.get()).isNotNull(); - } else { - fail("Comment Could not find"); - } - - } - - @Test - void findByArticleId() { - var comments = commentReader.findByArticleId(1L); - assertThat(comments).extracting("articleId", Long.class) - .containsOnly(1L); - } - - @Test - void existsById() { - var isPresent = commentReader.existsById(1L); - assertThat(isPresent).isTrue(); - } -}