Skip to content

Commit dab1140

Browse files
committed
CommentCreateRequest 수정
1 parent 5354fd9 commit dab1140

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

back/src/main/java/com/back/domain/post/comment/dto/CommentCreateRequest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55

66
public record CommentCreateRequest(
7-
String role,
8-
97
@NotBlank(message = "댓글을 입력해주세요")
108
String comment
119
) {

back/src/main/java/com/back/domain/post/comment/service/PostCommentService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public class PostCommentService {
2727
public void createComment(Member member, Long postId, CommentCreateRequest commentCreateRequest) {
2828
Post post = postRepository.findById(postId).orElseThrow(() -> new ServiceException("400", "해당 Id의 게시글이 없습니다."));
2929

30+
if ( commentCreateRequest.comment() == null || commentCreateRequest.comment().isEmpty()) {
31+
throw new ServiceException("400", "댓글은 비어 있을 수 없습니다.");
32+
}
33+
3034
PostComment postComment = PostComment.builder()
3135
.post(post)
3236
.content(commentCreateRequest.comment())

back/src/test/java/com/back/domain/post/comment/service/PostCommentServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void createComment_success() {
5050
Member member = MemberFixture.create(1L, "[email protected]", "User", "password", Member.Role.MENTEE);
5151
Post post = createDefaultPost(member);
5252
Long postId = 1L;
53-
CommentCreateRequest request = new CommentCreateRequest("MENTEE","테스트 댓글");
53+
CommentCreateRequest request = new CommentCreateRequest("테스트 댓글");
5454

5555
when(postRepository.findById(postId)).thenReturn(Optional.of(post));
5656
when(postCommentRepository.save(any(PostComment.class))).thenReturn(any(PostComment.class));
@@ -69,7 +69,7 @@ void createComment_postNotExists_failure() {
6969
// given
7070
Member member = MemberFixture.createDefault();
7171
Long postId = 999L;
72-
CommentCreateRequest request = new CommentCreateRequest("MENTEE","테스트 댓글");
72+
CommentCreateRequest request = new CommentCreateRequest("테스트 댓글");
7373

7474
when(postRepository.findById(postId)).thenReturn(Optional.empty());
7575

0 commit comments

Comments
 (0)