Skip to content

Commit

Permalink
refactor: RecommendedPost 생성자 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Aug 3, 2023
1 parent 9e88478 commit e06b351
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e06b351

Please sign in to comment.