diff --git a/src/main/java/com/mallang/post/application/DraftService.java b/src/main/java/com/mallang/post/application/DraftService.java index 152ecb37..e38f2ec1 100644 --- a/src/main/java/com/mallang/post/application/DraftService.java +++ b/src/main/java/com/mallang/post/application/DraftService.java @@ -40,8 +40,7 @@ public void update(UpdateDraftCommand command) { draft.validateWriter(member); draft.update( command.title(), - command.intro(), command.bodyText(), - command.postThumbnailImageName(), + command.bodyText(), postCategory, command.tags() ); diff --git a/src/main/java/com/mallang/post/application/command/CreateDraftCommand.java b/src/main/java/com/mallang/post/application/command/CreateDraftCommand.java index bc0cf14b..4ba9554a 100644 --- a/src/main/java/com/mallang/post/application/command/CreateDraftCommand.java +++ b/src/main/java/com/mallang/post/application/command/CreateDraftCommand.java @@ -13,9 +13,7 @@ public record CreateDraftCommand( Long memberId, String blogName, String title, - String intro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable Long categoryId, List tags ) { @@ -23,9 +21,7 @@ public Draft toDraft(Member member, Blog blog, @Nullable PostCategory postCatego return Draft.builder() .blog(blog) .title(title) - .intro(intro) .bodyText(bodyText) - .postThumbnailImageName(postThumbnailImageName) .category(postCategory) .tags(tags) .writer(member) diff --git a/src/main/java/com/mallang/post/application/command/UpdateDraftCommand.java b/src/main/java/com/mallang/post/application/command/UpdateDraftCommand.java index f0f7133c..407eac1c 100644 --- a/src/main/java/com/mallang/post/application/command/UpdateDraftCommand.java +++ b/src/main/java/com/mallang/post/application/command/UpdateDraftCommand.java @@ -9,9 +9,7 @@ public record UpdateDraftCommand( Long memberId, Long draftId, String title, - String intro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable Long categoryId, List tags ) { diff --git a/src/main/java/com/mallang/post/domain/Post.java b/src/main/java/com/mallang/post/domain/Post.java index 56d1828a..fb298045 100644 --- a/src/main/java/com/mallang/post/domain/Post.java +++ b/src/main/java/com/mallang/post/domain/Post.java @@ -11,6 +11,7 @@ import com.mallang.post.exception.PostLikeCountNegativeException; import jakarta.annotation.Nullable; import jakarta.persistence.AssociationOverride; +import jakarta.persistence.Column; import jakarta.persistence.Embedded; import jakarta.persistence.EmbeddedId; import jakarta.persistence.Entity; @@ -43,6 +44,12 @@ public class Post extends CommonRootEntity { @AssociationOverride(name = "tags", joinTable = @JoinTable(name = "post_tags")) private PostContent content; + @Embedded + private PostIntro postIntro; + + @Column(nullable = true) + private String postThumbnailImageName; + private int likeCount = 0; @Builder @@ -62,7 +69,9 @@ public Post( this.id = id; this.blog = blog; this.visibilityPolish = new PostVisibilityPolicy(visibility, password); - this.content = new PostContent(title, intro, bodyText, postThumbnailImageName, category, tags, writer); + this.content = new PostContent(title, bodyText, category, tags, writer); + this.postThumbnailImageName = postThumbnailImageName; + setPostIntro(intro, bodyText); blog.validateOwner(writer); } @@ -77,7 +86,17 @@ public void update( List tags ) { this.visibilityPolish = new PostVisibilityPolicy(visibility, password); - this.content = new PostContent(title, intro, bodyText, postThumbnailImageName, category, tags, getWriter()); + this.content = new PostContent(title, bodyText, category, tags, getWriter()); + this.postThumbnailImageName = postThumbnailImageName; + setPostIntro(intro, bodyText); + } + + private void setPostIntro(String postIntro, String bodyText) { + if (postIntro == null || postIntro.isBlank()) { + this.postIntro = new PostIntro(bodyText.substring(0, Math.min(150, bodyText.length()))); + return; + } + this.postIntro = new PostIntro(postIntro); } public void delete() { @@ -130,16 +149,12 @@ public String getBodyText() { return content.getBodyText(); } - public String getPostThumbnailImageName() { - return content.getPostThumbnailImageName(); - } - public PostCategory getCategory() { return content.getCategory(); } public String getPostIntro() { - return content.getPostIntro(); + return this.postIntro.getIntro(); } public List getTags() { diff --git a/src/main/java/com/mallang/post/domain/PostContent.java b/src/main/java/com/mallang/post/domain/PostContent.java index b36db7f8..f6a8bb1c 100644 --- a/src/main/java/com/mallang/post/domain/PostContent.java +++ b/src/main/java/com/mallang/post/domain/PostContent.java @@ -9,7 +9,6 @@ import jakarta.persistence.Column; import jakarta.persistence.ElementCollection; import jakarta.persistence.Embeddable; -import jakarta.persistence.Embedded; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import java.util.ArrayList; @@ -30,12 +29,6 @@ public class PostContent { @Column(nullable = false, columnDefinition = "TEXT") private String bodyText; - @Column(nullable = true) - private String postThumbnailImageName; - - @Embedded - private PostIntro postIntro; - @ManyToOne(fetch = LAZY) @JoinColumn(name = "category_id", nullable = true) private PostCategory category; @@ -50,30 +43,18 @@ public class PostContent { @Builder public PostContent( String title, - String postIntro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable PostCategory category, List tags, Member writer ) { this.title = title; this.bodyText = bodyText; - this.postThumbnailImageName = postThumbnailImageName; this.writer = writer; - setPostIntro(postIntro, bodyText); setPostCategory(category); setTags(tags); } - private void setPostIntro(String postIntro, String bodyText) { - if (postIntro == null || postIntro.isBlank()) { - this.postIntro = new PostIntro(bodyText.substring(0, Math.min(150, bodyText.length()))); - return; - } - this.postIntro = new PostIntro(postIntro); - } - private void setPostCategory(@Nullable PostCategory category) { if (category == null) { this.category = null; @@ -108,19 +89,13 @@ public boolean isWriter(Member member) { public PostContent removeCategory() { return new PostContent( getTitle(), - getPostIntro(), getBodyText(), - getPostThumbnailImageName(), null, getTags(), getWriter() ); } - public String getPostIntro() { - return postIntro.getIntro(); - } - public List getTags() { return tags.stream() .map(Tag::getContent) diff --git a/src/main/java/com/mallang/post/domain/draft/Draft.java b/src/main/java/com/mallang/post/domain/draft/Draft.java index 27101839..d6a5df00 100644 --- a/src/main/java/com/mallang/post/domain/draft/Draft.java +++ b/src/main/java/com/mallang/post/domain/draft/Draft.java @@ -53,27 +53,23 @@ public class Draft extends CommonRootEntity { public Draft( Blog blog, String title, - String intro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable PostCategory category, List tags, Member writer ) { this.blog = blog; - this.content = new PostContent(title, intro, bodyText, postThumbnailImageName, category, tags, writer); + this.content = new PostContent(title, bodyText, category, tags, writer); blog.validateOwner(writer); } public void update( String title, - String intro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable PostCategory category, List tags ) { - this.content = new PostContent(title, intro, bodyText, postThumbnailImageName, category, tags, getWriter()); + this.content = new PostContent(title, bodyText, category, tags, getWriter()); } public void removeCategory() { @@ -94,18 +90,10 @@ public String getBodyText() { return content.getBodyText(); } - public String getPostThumbnailImageName() { - return content.getPostThumbnailImageName(); - } - public PostCategory getCategory() { return content.getCategory(); } - public String getPostIntro() { - return content.getPostIntro(); - } - public List getTags() { return content.getTags(); } diff --git a/src/main/java/com/mallang/post/presentation/request/CreateDraftRequest.java b/src/main/java/com/mallang/post/presentation/request/CreateDraftRequest.java index 61cd7927..3b2f5d3f 100644 --- a/src/main/java/com/mallang/post/presentation/request/CreateDraftRequest.java +++ b/src/main/java/com/mallang/post/presentation/request/CreateDraftRequest.java @@ -7,9 +7,7 @@ public record CreateDraftRequest( String blogName, String title, - @Nullable String intro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable Long categoryId, List tags ) { @@ -19,8 +17,6 @@ public CreateDraftCommand toCommand(Long memberId) { .blogName(blogName) .title(title) .bodyText(bodyText) - .postThumbnailImageName(postThumbnailImageName) - .intro(intro) .categoryId(categoryId) .tags(tags) .build(); diff --git a/src/main/java/com/mallang/post/presentation/request/UpdateDraftRequest.java b/src/main/java/com/mallang/post/presentation/request/UpdateDraftRequest.java index 3b90a81f..2b320ec5 100644 --- a/src/main/java/com/mallang/post/presentation/request/UpdateDraftRequest.java +++ b/src/main/java/com/mallang/post/presentation/request/UpdateDraftRequest.java @@ -6,9 +6,7 @@ public record UpdateDraftRequest( String title, - @Nullable String intro, String bodyText, - @Nullable String postThumbnailImageName, @Nullable Long categoryId, List tags ) { @@ -18,8 +16,6 @@ public UpdateDraftCommand toCommand(Long memberId, Long draftId) { .draftId(draftId) .title(title) .bodyText(bodyText) - .postThumbnailImageName(postThumbnailImageName) - .intro(intro) .categoryId(categoryId) .tags(tags) .build(); diff --git a/src/main/java/com/mallang/post/query/response/DraftDetailResponse.java b/src/main/java/com/mallang/post/query/response/DraftDetailResponse.java index fa114dca..d1a64c71 100644 --- a/src/main/java/com/mallang/post/query/response/DraftDetailResponse.java +++ b/src/main/java/com/mallang/post/query/response/DraftDetailResponse.java @@ -3,14 +3,12 @@ import com.mallang.post.domain.PostCategory; import com.mallang.post.domain.PostContent; import com.mallang.post.domain.draft.Draft; -import jakarta.annotation.Nullable; import java.util.List; public record DraftDetailResponse( Long draftId, String title, String bodyText, - @Nullable String postThumbnailImageName, CategoryResponse category, TagResponses tags ) { @@ -19,7 +17,6 @@ public static DraftDetailResponse from(Draft draft) { draft.getId(), draft.getTitle(), draft.getBodyText(), - draft.getPostThumbnailImageName(), CategoryResponse.from(draft.getContent()), TagResponses.from(draft.getContent()) ); diff --git a/src/test/java/com/mallang/acceptance/post/DraftAcceptanceTest.java b/src/test/java/com/mallang/acceptance/post/DraftAcceptanceTest.java index 9d90426d..9a49bdb7 100644 --- a/src/test/java/com/mallang/acceptance/post/DraftAcceptanceTest.java +++ b/src/test/java/com/mallang/acceptance/post/DraftAcceptanceTest.java @@ -57,8 +57,7 @@ protected void setUp() { 임시_글_생성_요청 = new CreateDraftRequest( 말랑_블로그_이름, "첫 임시_글", - "첫 임시_글 인트로", "첫 임시_글이네요.", - "임시_글 썸네일 이름", + "첫 임시_글이네요.", Spring_카테고리_ID, List.of("태그1", "태그2") ); @@ -82,8 +81,7 @@ class 임시_글_저장_API { CreateDraftRequest createDraftRequest = new CreateDraftRequest( 말랑_블로그_이름, "첫 임시_글", - "첫 임시_글 인트로", "첫 임시_글이네요.", - "임시_글 썸네일 이름", + "첫 임시_글이네요.", Spring_카테고리_ID, List.of("태그1", "태그2") ); @@ -105,8 +103,7 @@ class 임시_글_수정_API { var 임시_글_ID = ID를_추출한다(임시_글_생성_요청(말랑_세션_ID, 임시_글_생성_요청)); UpdateDraftRequest 임시_글_수정_요청 = new UpdateDraftRequest( "업데이트 제목", - "업데이트 인트로", "업데이트 내용", - "업데이트 임시_글 썸네일 이름", + "업데이트 내용", Spring_카테고리_ID, List.of("태그1", "태그2") ); @@ -124,8 +121,7 @@ class 임시_글_수정_API { var 임시_글_ID = ID를_추출한다(임시_글_생성_요청(말랑_세션_ID, 임시_글_생성_요청)); UpdateDraftRequest 임시_글_수정_요청 = new UpdateDraftRequest( "업데이트 제목", - "업데이트 인트로", "업데이트 내용", - "업데이트 임시_글 썸네일 이름", + "업데이트 내용", Spring_카테고리_ID, List.of("태그1", "태그2") ); @@ -175,16 +171,14 @@ class 임시_글_목록_조회_API { CreateDraftRequest 임시_글_1_생성_요청 = new CreateDraftRequest( 말랑_블로그_이름, "임시 글 1", - "첫 임시 글 인트로", "첫 임시 글이네요.", - "임시 글 썸네일 이름", + "첫 임시 글이네요.", Spring_카테고리_ID, List.of("태그1", "태그2") ); CreateDraftRequest 임시_글_2_생성_요청 = new CreateDraftRequest( 말랑_블로그_이름, "임시 글 2", - "임시 글 2 인트로", "두번째", - "임시 글 썸네일 이름", + "두번째", null, Collections.emptyList() ); diff --git a/src/test/java/com/mallang/acceptance/post/PostManageAcceptanceTest.java b/src/test/java/com/mallang/acceptance/post/PostManageAcceptanceTest.java index 7e569cbd..dc109b24 100644 --- a/src/test/java/com/mallang/acceptance/post/PostManageAcceptanceTest.java +++ b/src/test/java/com/mallang/acceptance/post/PostManageAcceptanceTest.java @@ -106,8 +106,7 @@ void setUp() { var 임시_글_생성_요청 = new CreateDraftRequest( 말랑_블로그_이름, "첫 임시_글", - "첫 임시_글 인트로", "첫 임시_글이네요.", - "임시_글 썸네일 이름", + "첫 임시_글이네요.", Spring_카테고리_ID, List.of("태그1", "태그2") ); diff --git a/src/test/java/com/mallang/post/application/DraftServiceTest.java b/src/test/java/com/mallang/post/application/DraftServiceTest.java index 560ffac7..5afbc377 100644 --- a/src/test/java/com/mallang/post/application/DraftServiceTest.java +++ b/src/test/java/com/mallang/post/application/DraftServiceTest.java @@ -57,7 +57,6 @@ class 임시_글_저장_시 { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .categoryId(categoryId) .tags(List.of("tag1", "tag2", "tag3")) .build(); @@ -77,7 +76,6 @@ class 임시_글_저장_시 { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .build(); // when @@ -96,14 +94,12 @@ class 임시_글_저장_시 { .memberId(memberId) .blogName(otherBlogName) .title("임시_글 1") - .intro("intro") .bodyText("bodyText") .build(); CreateDraftCommand command2 = CreateDraftCommand.builder() .memberId(otherMemberId) .blogName(blogName) .title("임시_글 1") - .intro("intro") .bodyText("bodyText") .build(); @@ -124,7 +120,6 @@ class 임시_글_저장_시 { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .categoryId(1000L) .build(); @@ -152,7 +147,6 @@ class 임시_글_저장_시 { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .categoryId(categoryId) .build(); @@ -175,7 +169,6 @@ void setUp() { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .tags(List.of("tag1", "tag2", "tag3")) .categoryId(categoryId) .build(); @@ -189,8 +182,7 @@ void setUp() { memberId, 임시_글_ID, "수정제목", - "수정인트로", "수정내용", - "수정썸네일", + "수정내용", null, List.of("태그2") ); @@ -203,8 +195,6 @@ void setUp() { Draft draft = draftRepository.getById(임시_글_ID); assertThat(draft.getTitle()).isEqualTo("수정제목"); assertThat(draft.getBodyText()).isEqualTo("수정내용"); - assertThat(draft.getPostThumbnailImageName()).isEqualTo("수정썸네일"); - assertThat(draft.getPostIntro()).isEqualTo("수정인트로"); assertThat(draft.getCategory()).isNull(); assertThat(draft.getTags()).containsExactly("태그2"); }); @@ -216,9 +206,10 @@ void setUp() { Long otherMemberId = 회원을_저장한다("동훈"); UpdateDraftCommand command = new UpdateDraftCommand( otherMemberId, 임시_글_ID, - "수정제목", "수정인트로", "수정내용", + "수정제목", + "수정내용", null, - null, emptyList() + emptyList() ); // when & then @@ -242,7 +233,6 @@ void setUp() { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .tags(List.of("tag1", "tag2", "tag3")) .build(); 임시_글_ID = draftService.create(command); diff --git a/src/test/java/com/mallang/post/application/PostServiceTest.java b/src/test/java/com/mallang/post/application/PostServiceTest.java index 8a445b01..24a37182 100644 --- a/src/test/java/com/mallang/post/application/PostServiceTest.java +++ b/src/test/java/com/mallang/post/application/PostServiceTest.java @@ -214,7 +214,6 @@ void setUp() { .blogName(blogName) .title("임시_글 1") .bodyText("bodyText") - .intro("intro") .tags(List.of("tag1")) .build(); draftId = draftService.create(createDraftCommand); diff --git a/src/test/java/com/mallang/post/domain/PostContentTest.java b/src/test/java/com/mallang/post/domain/PostContentTest.java index c5463250..271662e6 100644 --- a/src/test/java/com/mallang/post/domain/PostContentTest.java +++ b/src/test/java/com/mallang/post/domain/PostContentTest.java @@ -31,34 +31,6 @@ class PostContentTest { private final PostCategory jpaPostCategory = 하위_카테고리("JPA", mallang, blog, springPostCategory); private final PostCategory otherPostCategory = 루트_카테고리("Spring", otherMember, otherBlog); - @Test - void 인트로가_없으면_본문에서_가져와_설정된다() { - // when - PostContent postContent = PostContent.builder() - .title("제목") - .bodyText("내용") - .writer(mallang) - .build(); - - // then - String postIntro = postContent.getPostIntro(); - assertThat(postIntro).isEqualTo("내용"); - } - - @Test - void 인트로가_없을때_본문이_150자_이상이면_150자만_인트로로_설정된다() { - // when - PostContent postContent = PostContent.builder() - .title("제목") - .bodyText("1".repeat(151)) - .writer(mallang) - .build(); - - // then - String postIntro = postContent.getPostIntro(); - assertThat(postIntro.length()).isEqualTo(150); - } - @Test void 카테고리를_없앨_수_있다() { // given @@ -66,7 +38,6 @@ class PostContentTest { .title("제목") .bodyText("내용") .writer(mallang) - .postIntro("intro") .category(springPostCategory) .build(); @@ -91,7 +62,6 @@ class 생성_시 { PostContent.builder() .writer(mallang) .category(otherPostCategory) - .postIntro("intro") .build(); }).isInstanceOf(NoAuthorityPostCategoryException.class); } @@ -101,7 +71,6 @@ class 생성_시 { // given PostContent taggedPost = PostContent.builder() .title("제목") - .postIntro("intro") .bodyText("내용") .writer(mallang) .tags(List.of("tag1", "tag2")) @@ -117,7 +86,6 @@ class 생성_시 { // given PostContent taggedPost = PostContent.builder() .title("제목") - .postIntro("intro") .bodyText("내용") .writer(mallang) .build(); @@ -132,7 +100,6 @@ class 생성_시 { assertThatThrownBy(() -> PostContent.builder() .title("제목") - .postIntro("intro") .bodyText("내용") .writer(mallang) .tags(List.of("태그1", "태그1")) @@ -145,7 +112,6 @@ class 생성_시 { // when PostContent postContent = PostContent.builder() .title("제목") - .postIntro("intro") .bodyText("내용") .writer(mallang) .category(jpaPostCategory) @@ -154,35 +120,6 @@ class 생성_시 { // then assertThat(postContent.getCategory().getName()).isEqualTo("JPA"); } - - @Test - void 썸네일_사진_설정이_가능하다() { - // given - PostContent postContent = PostContent.builder() - .title("제목") - .postIntro("intro") - .bodyText("내용") - .postThumbnailImageName("thumbnail") - .writer(mallang) - .build(); - - // when & then - assertThat(postContent.getPostThumbnailImageName()).isEqualTo("thumbnail"); - } - - @Test - void 썸네일은_없어도_된다() { - // given - PostContent postContent = PostContent.builder() - .title("제목") - .postIntro("intro") - .bodyText("내용") - .writer(mallang) - .build(); - - // when & then - assertThat(postContent.getPostThumbnailImageName()).isNull(); - } } @Test @@ -190,7 +127,6 @@ class 생성_시 { // given PostContent postContent = PostContent.builder() .title("제목") - .postIntro("intro") .bodyText("내용") .writer(mallang) .tags(List.of("태그1")) diff --git a/src/test/java/com/mallang/post/domain/PostTest.java b/src/test/java/com/mallang/post/domain/PostTest.java index 53eb93cd..b7dc196c 100644 --- a/src/test/java/com/mallang/post/domain/PostTest.java +++ b/src/test/java/com/mallang/post/domain/PostTest.java @@ -218,6 +218,36 @@ class 생성_시 { // when & then assertThat(post.getPostThumbnailImageName()).isNull(); } + + @Test + void 인트로가_없으면_본문에서_가져와_설정된다() { + // when + Post post = Post.builder() + .blog(blog) + .title("제목") + .bodyText("내용") + .writer(mallang) + .build(); + + // then + String postIntro = post.getPostIntro(); + assertThat(postIntro).isEqualTo("내용"); + } + + @Test + void 인트로가_없을때_본문이_150자_이상이면_150자만_인트로로_설정된다() { + // when + Post post = Post.builder() + .blog(blog) + .title("제목") + .bodyText("1".repeat(151)) + .writer(mallang) + .build(); + + // then + String postIntro = post.getPostIntro(); + assertThat(postIntro.length()).isEqualTo(150); + } } @Nested diff --git a/src/test/java/com/mallang/post/domain/draft/DraftTest.java b/src/test/java/com/mallang/post/domain/draft/DraftTest.java index f48bcb3e..09829db0 100644 --- a/src/test/java/com/mallang/post/domain/draft/DraftTest.java +++ b/src/test/java/com/mallang/post/domain/draft/DraftTest.java @@ -43,13 +43,11 @@ class DraftTest { Draft draft1 = Draft.builder() .blog(blog) .writer(mallang) - .intro("intro") .title("1234") .build(); Draft draft2 = Draft.builder() .blog(blog) .writer(mallang) - .intro("intro") .title("5678") .build(); ReflectionTestUtils.setField(draft1, "id", 1L); @@ -71,7 +69,6 @@ class DraftTest { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") .writer(mallang) .category(springPostCategory) .build(); @@ -93,14 +90,12 @@ class 생성_시 { Draft.builder() .blog(otherBlog) .writer(mallang) - .intro("intro") .build(); }).isInstanceOf(NoAuthorityBlogException.class); assertThatThrownBy(() -> { Draft.builder() .blog(blog) .writer(otherMember) - .intro("intro") .build(); }).isInstanceOf(NoAuthorityBlogException.class); } @@ -112,7 +107,6 @@ class 생성_시 { Draft.builder() .blog(blog) .writer(mallang) - .intro("intro") .category(otherPostCategory) .build(); }).isInstanceOf(NoAuthorityPostCategoryException.class); @@ -125,8 +119,6 @@ class 생성_시 { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") - .postThumbnailImageName("thumbnail") .writer(mallang) .tags(List.of("tag1", "tag2")) .build(); @@ -135,7 +127,6 @@ class 생성_시 { assertThat(taggedDraft.getBlog()).isEqualTo(blog); assertThat(taggedDraft.getTitle()).isEqualTo("제목"); assertThat(taggedDraft.getBodyText()).isEqualTo("내용"); - assertThat(taggedDraft.getPostIntro()).isEqualTo("intro"); assertThat(taggedDraft.getWriter()).isEqualTo(mallang); assertThat(taggedDraft.getTags()) .containsExactly("tag1", "tag2"); @@ -148,7 +139,6 @@ class 생성_시 { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") .writer(mallang) .build(); @@ -164,7 +154,6 @@ class 생성_시 { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") .writer(mallang) .tags(List.of("태그1", "태그1")) .build() @@ -178,7 +167,6 @@ class 생성_시 { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") .writer(mallang) .category(jpaPostCategory) .build(); @@ -186,37 +174,6 @@ class 생성_시 { // then assertThat(draft.getCategory().getName()).isEqualTo("JPA"); } - - @Test - void 썸네일_사진_설정이_가능하다() { - // given - Draft draft = Draft.builder() - .blog(blog) - .title("제목") - .bodyText("내용") - .intro("intro") - .postThumbnailImageName("thumbnail") - .writer(mallang) - .build(); - - // when & then - assertThat(draft.getPostThumbnailImageName()).isEqualTo("thumbnail"); - } - - @Test - void 썸네일은_없어도_된다() { - // given - Draft draft = Draft.builder() - .blog(blog) - .title("제목") - .bodyText("내용") - .intro("intro") - .writer(mallang) - .build(); - - // when & then - assertThat(draft.getPostThumbnailImageName()).isNull(); - } } @Nested @@ -229,7 +186,6 @@ class 수정_시 { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") .writer(mallang) .tags(List.of("태그1")) .build(); @@ -237,8 +193,7 @@ class 수정_시 { // when draft.update( "수정제목", - "수정인트로", "수정내용", - "postThumbnailImageName", + "수정내용", null, List.of("태그2") ); @@ -257,7 +212,6 @@ class 수정_시 { .blog(blog) .title("제목") .bodyText("내용") - .intro("intro") .writer(mallang) .tags(List.of("태그1")) .build(); @@ -266,8 +220,7 @@ class 수정_시 { assertThatThrownBy(() -> { draft.update( "수정제목", - "수정인트로", "수정내용", - "postThumbnailImageName", + "수정내용", otherPostCategory, Collections.emptyList() ); @@ -283,7 +236,6 @@ class 수정_시 { .title("제목") .bodyText("내용") .writer(mallang) - .intro("intro") .category(springPostCategory) .build(); diff --git a/src/test/java/com/mallang/post/query/DraftQueryServiceTest.java b/src/test/java/com/mallang/post/query/DraftQueryServiceTest.java index f491c31d..41b8edce 100644 --- a/src/test/java/com/mallang/post/query/DraftQueryServiceTest.java +++ b/src/test/java/com/mallang/post/query/DraftQueryServiceTest.java @@ -48,7 +48,6 @@ void setUp() { .blogName(blogName) .title("임시 글 1") .bodyText("bodyText") - .intro("intro") .tags(List.of("tag1", "tag2", "tag3")) .categoryId(categoryId) .build(); @@ -59,7 +58,6 @@ void setUp() { .blogName(blogName) .title("임시 글 2") .bodyText("bodyText") - .intro("intro") .build(); 임시_글_2_ID = draftService.create(임시_글_2_요청); }