Skip to content

Commit d5c7e2f

Browse files
committed
refactor: RecommendedPost 생성자 변경
#1397
1 parent 0c80f77 commit d5c7e2f

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ public RecommendedPostService(final RecommendedPostRepository recommendedPostRep
2828
@Transactional
2929
public Long create(final Long keywordId, final RecommendedRequest request) {
3030
final Keyword keyword = findKeywordOrThrow(keywordId);
31-
32-
final RecommendedPost post = new RecommendedPost(request.getUrl());
33-
post.addKeyword(keyword);
31+
final RecommendedPost post = new RecommendedPost(request.getUrl(), keyword);
3432

3533
return recommendedPostRepository.save(post).getId();
3634
}

backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public class RecommendedPost {
3131
@JoinColumn(nullable = false)
3232
private Keyword keyword;
3333

34-
public RecommendedPost(final String url) {
35-
this(null, url, null);
34+
public RecommendedPost(final String url, final Keyword keyword) {
35+
this(null, url, keyword);
3636
}
3737

3838
public void updateUrl(final String url) {

backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ void remove() {
2727
@DisplayName("소속 키워드를 추가한다")
2828
void addKeyword() {
2929
//given
30-
final RecommendedPost post = new RecommendedPost("http://연어");
3130
final Keyword keyword = Keyword.createKeyword("name", "description", 1, 1, 1L, null);
31+
final RecommendedPost post = new RecommendedPost("http://연어", keyword);
3232

3333
//when
3434
post.addKeyword(keyword);

0 commit comments

Comments
 (0)