From e06b3517e4beb08e1edf2363c05897e069a774b4 Mon Sep 17 00:00:00 2001 From: nuyh Date: Thu, 3 Aug 2023 17:38:52 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20RecommendedPost=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1397 --- .../prolog/roadmap/application/RecommendedPostService.java | 4 +--- .../java/wooteco/prolog/roadmap/domain/RecommendedPost.java | 4 ++-- .../wooteco/prolog/roadmap/domain/RecommendedPostTest.java | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java index fb34a6d81..e4e24d95f 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java @@ -28,9 +28,7 @@ public RecommendedPostService(final RecommendedPostRepository recommendedPostRep @Transactional public Long create(final Long keywordId, final RecommendedRequest request) { final Keyword keyword = findKeywordOrThrow(keywordId); - - final RecommendedPost post = new RecommendedPost(request.getUrl()); - post.addKeyword(keyword); + final RecommendedPost post = new RecommendedPost(request.getUrl(), keyword); return recommendedPostRepository.save(post).getId(); } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java index 026c69324..51c9b3f6b 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java @@ -31,8 +31,8 @@ public class RecommendedPost { @JoinColumn(nullable = false) private Keyword keyword; - public RecommendedPost(final String url) { - this(null, url, null); + public RecommendedPost(final String url, final Keyword keyword) { + this(null, url, keyword); } public void updateUrl(final String url) { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java b/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java index 3d74f08e0..3d6909d82 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java @@ -27,8 +27,8 @@ void remove() { @DisplayName("소속 키워드를 추가한다") void addKeyword() { //given - final RecommendedPost post = new RecommendedPost("http://연어"); final Keyword keyword = Keyword.createKeyword("name", "description", 1, 1, 1L, null); + final RecommendedPost post = new RecommendedPost("http://연어", keyword); //when post.addKeyword(keyword);