Skip to content

Commit def204b

Browse files
committed
refactor(community): sonar 반영
- View 생성자 제거 - isDeleted 메서드 추가 - test isEqual("") -> isEmpty()
1 parent 20e8bc3 commit def204b

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/main/java/com/somemore/community/domain/CommunityComment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ public void updateWith(CommunityCommentUpdateRequestDto dto) {
5555
public void replaceComment() {
5656
this.content = "삭제된 댓글입니다";
5757
}
58+
59+
public Boolean isDeleted() {
60+
return this.getDeleted();
61+
}
5862
}

src/main/java/com/somemore/community/repository/mapper/CommunityCommentView.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
import com.somemore.community.domain.CommunityComment;
44
import lombok.Builder;
55

6+
@Builder
67
public record CommunityCommentView(
78
CommunityComment communityComment,
89
String writerNickname
910
) {
10-
@Builder
11-
public CommunityCommentView(CommunityComment communityComment, String writerNickname) {
12-
this.communityComment = communityComment;
13-
this.writerNickname = writerNickname;
14-
}
15-
1611
public CommunityCommentView replaceWriterNickname(CommunityCommentView communityCommentView) {
1712
return CommunityCommentView.builder()
1813
.communityComment(communityCommentView.communityComment)

src/main/java/com/somemore/community/service/comment/CommunityCommentQueryService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private List<Long> findParentCommentIds(List<CommunityCommentView> comments) {
4444
private Optional<CommunityCommentView> processDeletedComment(List<Long> parentCommentIds, CommunityCommentView commentView) {
4545
CommunityComment comment = commentView.communityComment();
4646

47-
if (comment.getDeleted()) {
47+
if (comment.isDeleted()) {
4848
if (parentCommentIds.contains(comment.getId())) {
4949
return Optional.of(commentView.replaceWriterNickname(commentView));
5050
}

src/test/java/com/somemore/community/service/comment/CommunityCommentQueryServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void getCommentsByCommunityBoardIdWithDeletedComment() {
131131
//then
132132
assertThat(comments).hasSize(1);
133133
assertThat(comments.getFirst().content()).isEqualTo("삭제된 댓글입니다");
134-
assertThat(comments.getFirst().writerNickname()).isEqualTo("");
134+
assertThat(comments.getFirst().writerNickname()).isEmpty();
135135
assertThat(comments.getFirst().replies()).hasSize(1);
136136
assertThat(comments.getFirst().replies().getFirst().id()).isEqualTo(replyId);
137137
}

0 commit comments

Comments
 (0)