From 30ae71fa20d1101763cae7cbbfe431a7c97376ef Mon Sep 17 00:00:00 2001 From: Ssamssamukja <109636635+Ssamssamukja@users.noreply.github.com> Date: Thu, 5 Feb 2026 00:33:48 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EB=82=B4=20=EA=B8=80=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A4=EB=A5=B8=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=20=EC=82=AD=EC=A0=9C=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/service/CommentServiceImpl.java | 6 +- .../comment/service/CommentServiceTest.java | 56 +++++++++++++++++-- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/clokey-api/src/main/java/org/clokey/domain/comment/service/CommentServiceImpl.java b/clokey-api/src/main/java/org/clokey/domain/comment/service/CommentServiceImpl.java index 9c4fc792..aacb27f8 100644 --- a/clokey-api/src/main/java/org/clokey/domain/comment/service/CommentServiceImpl.java +++ b/clokey-api/src/main/java/org/clokey/domain/comment/service/CommentServiceImpl.java @@ -151,7 +151,11 @@ public void deleteComment(Long commentId) { final Member currentMember = memberUtil.getCurrentMember(); final Comment comment = getCommentById(commentId); - validateCommentOwner(currentMember, comment); + boolean isHistoryOwner = + Objects.equals(comment.getHistory().getMember().getId(), currentMember.getId()); + if (!isHistoryOwner) { + validateCommentOwner(currentMember, comment); + } if (comment.getComment() != null) { commentRepository.delete(comment); diff --git a/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java b/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java index 11eab2dd..cbb4413f 100644 --- a/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java +++ b/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java @@ -590,7 +590,14 @@ void setUp() { "testEmail2", "testNickName2", OauthInfo.createOauthInfo("testOauthId2", OauthProvider.KAKAO)); - memberRepository.saveAll(List.of(member1, member2)); + + Member member3 = + Member.createMember( + "testEmail3", + "testNickName3", + OauthInfo.createOauthInfo("testOauthId3", OauthProvider.KAKAO)); + + memberRepository.saveAll(List.of(member1, member2, member3)); given(memberUtil.getCurrentMember()).willReturn(member1); Situation situation = Situation.createSituation("testSituation"); @@ -606,7 +613,10 @@ void setUp() { Comment reply1 = Comment.createReply("testContent1", member1, history, comment1); Comment reply2 = Comment.createReply("testContent2", member1, history, comment1); Comment reply3 = Comment.createReply("testContent3", member1, history, comment2); - commentRepository.saveAll(List.of(comment1, comment2, reply1, reply2, reply3)); + Comment otherComment = Comment.createParentComment("otherContent", member2, history); + Comment otherReply = Comment.createReply("otherReply", member2, history, otherComment); + commentRepository.saveAll( + List.of(comment1, comment2, reply1, reply2, reply3, otherComment, otherReply)); } @Test @@ -642,13 +652,49 @@ void setUp() { } @Test - void 댓글_작성자가_아닌_경우_예외가_발생한다() { + void 글_작성자는_내_글에_달린_남의_댓글을_삭제할_수_있고_대댓글도_함께_삭제된다() { // given - Member member = memberRepository.findById(2L).orElseThrow(); + Member historyOwner = memberRepository.findById(1L).orElseThrow(); + given(memberUtil.getCurrentMember()).willReturn(historyOwner); + + Comment otherComment = + commentRepository.findAll().stream() + .filter(c -> c.getComment() == null) + .filter(c -> "otherContent".equals(c.getContent())) + .findFirst() + .orElseThrow(); + + Comment otherReply = + commentRepository.findAll().stream() + .filter(c -> c.getComment() != null) + .filter(c -> "otherReply".equals(c.getContent())) + .findFirst() + .orElseThrow(); + + // when + commentService.deleteComment(otherComment.getId()); + + // then + Assertions.assertAll( + () -> assertThat(commentRepository.findById(otherComment.getId())).isEmpty(), + () -> assertThat(commentRepository.findById(otherReply.getId())).isEmpty()); + } + + @Test + void 글_작성자도_아니고_댓글_작성자도_아니면_남의_댓글을_삭제할_수_없다() { + // given + Member member = memberRepository.findById(3L).orElseThrow(); given(memberUtil.getCurrentMember()).willReturn(member); + Comment otherComment = + commentRepository.findAll().stream() + .filter(c -> c.getComment() == null) + .filter(c -> "otherContent".equals(c.getContent())) + .findFirst() + .orElseThrow(); + // when & then - assertThatThrownBy(() -> commentService.deleteComment(1L)) + assertThatThrownBy(() -> commentService.deleteComment(otherComment.getId())) .isInstanceOf(BaseCustomException.class) .hasMessage(CommentErrorCode.NOT_MY_COMMENT.getMessage()); } From 328970051d025cc029810b9e86ae1a45d0571883 Mon Sep 17 00:00:00 2001 From: Ssamssamukja <109636635+Ssamssamukja@users.noreply.github.com> Date: Thu, 5 Feb 2026 01:51:38 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EB=8C=93=EA=B8=80=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C/=EB=8C=80=EB=8C=93=EA=B8=80=EC=A1=B0=ED=9A=8C=20api?= =?UTF-8?q?=EC=97=90=20canDelete=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/CommentListResponse.java | 3 +- .../dto/response/ReplyListResponse.java | 3 +- .../repository/CommentRepositoryImpl.java | 13 +++- .../controller/CommentControllerTest.java | 65 ++++++++++++++-- .../comment/service/CommentServiceTest.java | 77 ++++++++++++++++--- 5 files changed, 137 insertions(+), 24 deletions(-) diff --git a/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/CommentListResponse.java b/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/CommentListResponse.java index 2b2ccb44..eb0ae23f 100644 --- a/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/CommentListResponse.java +++ b/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/CommentListResponse.java @@ -11,4 +11,5 @@ public record CommentListResponse( @Schema(description = "댓글 내용", example = "이 옷 정보 알려주세요!") String content, @Schema(description = "대댓글 존재 여부", example = "false") boolean replied, @Schema(description = "총 대댓글 개수", example = "0") long replyCount, - @Schema(description = "내가 작성한 댓글인가?", example = "false") boolean isMine) {} + @Schema(description = "내가 작성한 댓글인가?", example = "false") boolean isMine, + @Schema(description = "댓글 삭제 가능 여부", example = "false") boolean canDelete) {} diff --git a/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/ReplyListResponse.java b/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/ReplyListResponse.java index fbe7a1a3..e1f6149a 100644 --- a/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/ReplyListResponse.java +++ b/clokey-api/src/main/java/org/clokey/domain/comment/dto/response/ReplyListResponse.java @@ -9,4 +9,5 @@ public record ReplyListResponse( @Schema(description = "댓글 작성자 이미지 주소", example = "https://s3.amazonaws.com/example.jpg") String profileImageUrl, @Schema(description = "댓글 내용", example = "이 옷 정보 알려주세요!") String content, - @Schema(description = "내가 작성한 대댓글인가?", example = "false") boolean isMine) {} + @Schema(description = "내가 작성한 대댓글인가?", example = "false") boolean isMine, + @Schema(description = "댓글 삭제 가능 여부", example = "false") boolean canDelete) {} diff --git a/clokey-api/src/main/java/org/clokey/domain/comment/repository/CommentRepositoryImpl.java b/clokey-api/src/main/java/org/clokey/domain/comment/repository/CommentRepositoryImpl.java index f18cc699..b50ab786 100644 --- a/clokey-api/src/main/java/org/clokey/domain/comment/repository/CommentRepositoryImpl.java +++ b/clokey-api/src/main/java/org/clokey/domain/comment/repository/CommentRepositoryImpl.java @@ -55,7 +55,10 @@ public Slice findAllParentCommentByHistoryId( comment.content, Expressions.constant(false), Expressions.constant(0L), - member.id.eq(currentMemberId))) + member.id.eq(currentMemberId), + member.id + .eq(currentMemberId) + .or(history.member.id.eq(currentMemberId)))) .from(comment) .join(comment.member, member) .where( @@ -107,7 +110,8 @@ public Slice findAllParentCommentByHistoryId( c.content(), replyCountMap.getOrDefault(c.commentId(), 0L) > 0, replyCountMap.getOrDefault(c.commentId(), 0L), - c.isMine())) + c.isMine(), + c.canDelete())) .toList(); return new SliceImpl<>(finalResults, PageRequest.of(0, size), hasNext); @@ -131,7 +135,10 @@ public Slice findAllRepliesByCommentId( member.nickname, member.profileImageUrl, comment.content, - member.id.eq(currentMemberId))) + member.id.eq(currentMemberId), + member.id + .eq(currentMemberId) + .or(history.member.id.eq(currentMemberId)))) .from(comment) .join(comment.member, member) .where( diff --git a/clokey-api/src/test/java/org/clokey/domain/comment/controller/CommentControllerTest.java b/clokey-api/src/test/java/org/clokey/domain/comment/controller/CommentControllerTest.java index 1f95e3ec..3dbf1666 100644 --- a/clokey-api/src/test/java/org/clokey/domain/comment/controller/CommentControllerTest.java +++ b/clokey-api/src/test/java/org/clokey/domain/comment/controller/CommentControllerTest.java @@ -292,6 +292,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent1", false, 0L, + true, true), new CommentListResponse( 2L, @@ -301,6 +302,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent2", false, 0L, + true, true)); given(commentService.getHistoryComments(1L, null, 2, SortDirection.ASC)) @@ -319,6 +321,7 @@ class 기록의_댓글_목록_조회_요청_시 { .andExpect(jsonPath("$.code").value("COMMON200")) .andExpect(jsonPath("$.result.content[0].commentId").value(1)) .andExpect(jsonPath("$.result.content[1].commentId").value(2)) + .andExpect(jsonPath("$.result.content[0].canDelete").value(true)) .andExpect(jsonPath("$.result.isLast").value(true)); } @@ -335,6 +338,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent2", false, 0L, + true, true), new CommentListResponse( 1L, @@ -344,6 +348,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent1", false, 0L, + true, true)); given(commentService.getHistoryComments(1L, null, 2, SortDirection.DESC)) @@ -378,6 +383,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent2", false, 0L, + true, true)); given(commentService.getHistoryComments(1L, null, 1, SortDirection.ASC)) @@ -411,6 +417,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent1", false, 0L, + true, true), new CommentListResponse( 2L, @@ -420,6 +427,7 @@ class 기록의_댓글_목록_조회_요청_시 { "testContent2", false, 0L, + true, true)); given(commentService.getHistoryComments(1L, null, 1, SortDirection.ASC)) @@ -508,9 +516,21 @@ class 댓글의_대댓글_목록_조회_요청_시 { List commentReplies = List.of( new ReplyListResponse( - 1L, 1L, "testNickName", "testProfile", "testContent1", true), + 1L, + 1L, + "testNickName", + "testProfile", + "testContent1", + true, + true), new ReplyListResponse( - 2L, 1L, "testNickName", "testProfile", "testContent2", true)); + 2L, + 1L, + "testNickName", + "testProfile", + "testContent2", + true, + true)); given(commentService.getCommentReplies(1L, null, 2, SortDirection.ASC)) .willReturn(new SliceResponse<>(commentReplies, true)); @@ -527,6 +547,7 @@ class 댓글의_대댓글_목록_조회_요청_시 { .andExpect(jsonPath("$.code").value("COMMON200")) .andExpect(jsonPath("$.result.content[0].replyId").value(1)) .andExpect(jsonPath("$.result.content[1].replyId").value(2)) + .andExpect(jsonPath("$.result.content[0].canDelete").value(true)) .andExpect(jsonPath("$.result.isLast").value(true)); } @@ -536,9 +557,21 @@ class 댓글의_대댓글_목록_조회_요청_시 { List commentReplies = List.of( new ReplyListResponse( - 2L, 1L, "testNickName", "testProfile", "testContent2", true), + 2L, + 1L, + "testNickName", + "testProfile", + "testContent2", + true, + true), new ReplyListResponse( - 1L, 1L, "testNickName", "testProfile", "testContent1", true)); + 1L, + 1L, + "testNickName", + "testProfile", + "testContent1", + true, + true)); given(commentService.getCommentReplies(1L, null, 2, SortDirection.DESC)) .willReturn(new SliceResponse<>(commentReplies, true)); @@ -564,7 +597,13 @@ class 댓글의_대댓글_목록_조회_요청_시 { List commentReplies = List.of( new ReplyListResponse( - 2L, 1L, "testNickName", "testProfile", "testContent2", true)); + 2L, + 1L, + "testNickName", + "testProfile", + "testContent2", + true, + true)); given(commentService.getCommentReplies(1L, null, 1, SortDirection.ASC)) .willReturn(new SliceResponse<>(commentReplies, true)); @@ -589,9 +628,21 @@ class 댓글의_대댓글_목록_조회_요청_시 { List commentsReplies = List.of( new ReplyListResponse( - 1L, 1L, "testNickName", "testProfile", "testContent1", true), + 1L, + 1L, + "testNickName", + "testProfile", + "testContent1", + true, + true), new ReplyListResponse( - 2L, 1L, "testNickName", "testProfile", "testContent2", true)); + 2L, + 1L, + "testNickName", + "testProfile", + "testContent2", + true, + true)); given(commentService.getCommentReplies(1L, null, 2, SortDirection.ASC)) .willReturn(new SliceResponse<>(commentsReplies, false)); diff --git a/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java b/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java index cbb4413f..5fd8abe8 100644 --- a/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java +++ b/clokey-api/src/test/java/org/clokey/domain/comment/service/CommentServiceTest.java @@ -331,7 +331,12 @@ void setUp() { "testNickName2", OauthInfo.createOauthInfo("testOauthId2", OauthProvider.KAKAO)); member2.changeVisibility(); - memberRepository.saveAll(List.of(member1, member2)); + Member member3 = + Member.createMember( + "testEmail3", + "testNickName3", + OauthInfo.createOauthInfo("testOauthId3", OauthProvider.KAKAO)); + memberRepository.saveAll(List.of(member1, member2, member3)); given(memberUtil.getCurrentMember()).willReturn(member1); Situation situation = Situation.createSituation("testSituation"); @@ -351,8 +356,9 @@ void setUp() { Comment comment1 = Comment.createParentComment("testContent1", member1, history1); Comment comment2 = Comment.createParentComment("testContent2", member2, history1); Comment comment3 = Comment.createParentComment("testContent3", member2, history1); + Comment comment4 = Comment.createParentComment("testContent4", member3, history1); Comment reply1 = Comment.createReply("testContent1", member1, history1, comment1); - commentRepository.saveAll(List.of(comment1, comment2, comment3, reply1)); + commentRepository.saveAll(List.of(comment1, comment2, comment3, comment4, reply1)); } @Test @@ -373,10 +379,10 @@ void setUp() { void 정렬_조건이_DESC면_commentId를_내림차순으로_조회한다() { // when SliceResponse response = - commentService.getHistoryComments(1L, null, 3, SortDirection.DESC); + commentService.getHistoryComments(1L, null, 4, SortDirection.DESC); // then - assertThat(response.content()).extracting("commentId").containsExactly(3L, 2L, 1L); + assertThat(response.content()).extracting("commentId").containsExactly(4L, 3L, 2L, 1L); } @Test @@ -405,11 +411,11 @@ void setUp() { void 마지막_페이지인_경우_isLast를_true로_반환한다() { // when SliceResponse response = - commentService.getHistoryComments(1L, null, 3, SortDirection.ASC); + commentService.getHistoryComments(1L, null, 4, SortDirection.ASC); // then Assertions.assertAll( - () -> assertThat(response.content().size()).isEqualTo(3), + () -> assertThat(response.content().size()).isEqualTo(4), () -> assertThat(response.isLast()).isTrue()); } @@ -444,6 +450,27 @@ void setUp() { .isInstanceOf(BaseCustomException.class) .hasMessage(HistoryErrorCode.LIMITED_AUTHORITY.getMessage()); } + + @Test + void 내가_아닌_공개_계정의_기록에_다른_사람의_댓글을_조회하면_canDelete가_false로_반환된다() { + // given + Member member = memberRepository.findById(3L).orElse(null); + given(memberUtil.getCurrentMember()).willReturn(member); + + // when + SliceResponse response = + commentService.getHistoryComments(1L, null, 4, SortDirection.ASC); + + // then + assertThat(response.content()) + .extracting("commentId", "canDelete") + .containsExactly( + tuple(1L, false), // 다른 사람이 쓴 댓글 + tuple(2L, false), // 다른 사람이 쓴 댓글 + tuple(3L, false), // 다른 사람이 쓴 댓글 + tuple(4L, true) // 내가 쓴 댓글 + ); + } } @Nested @@ -463,7 +490,12 @@ void setUp() { "testNickName2", OauthInfo.createOauthInfo("testOauthId2", OauthProvider.KAKAO)); member2.changeVisibility(); - memberRepository.saveAll(List.of(member1, member2)); + Member member3 = + Member.createMember( + "testEmail3", + "testNickName3", + OauthInfo.createOauthInfo("testOauthId3", OauthProvider.KAKAO)); + memberRepository.saveAll(List.of(member1, member2, member3)); given(memberUtil.getCurrentMember()).willReturn(member1); Situation situation = Situation.createSituation("testSituation"); @@ -483,8 +515,9 @@ void setUp() { Comment reply1 = Comment.createReply("testContent1", member1, history1, comment1); Comment reply2 = Comment.createReply("testContent2", member2, history1, comment1); Comment reply3 = Comment.createReply("testContent3", member2, history2, comment2); + Comment reply4 = Comment.createReply("testContent3", member3, history1, comment1); commentRepository.saveAll( - List.of(comment1, comment2, comment3, reply1, reply2, reply3)); + List.of(comment1, comment2, comment3, reply1, reply2, reply3, reply4)); } @Test @@ -504,7 +537,7 @@ void setUp() { commentService.getCommentReplies(1L, null, 2, SortDirection.DESC); // then - assertThat(response.content()).extracting("replyId").containsExactly(5L, 4L); + assertThat(response.content()).extracting("replyId").containsExactly(7L, 5L); } @Test @@ -514,7 +547,7 @@ void setUp() { commentService.getCommentReplies(1L, 4L, 2, SortDirection.ASC); // then - assertThat(response.content()).extracting("replyId").containsExactly(5L); + assertThat(response.content()).extracting("replyId").containsExactly(5L, 7L); } @Test @@ -533,11 +566,11 @@ void setUp() { void 마지막_페이지인_경우_isLast를_true로_반환한다() { // when SliceResponse response = - commentService.getCommentReplies(1L, null, 2, SortDirection.ASC); + commentService.getCommentReplies(1L, null, 3, SortDirection.ASC); // then Assertions.assertAll( - () -> assertThat(response.content().size()).isEqualTo(2), + () -> assertThat(response.content().size()).isEqualTo(3), () -> assertThat(response.isLast()).isTrue()); } @@ -572,6 +605,26 @@ void setUp() { .isInstanceOf(BaseCustomException.class) .hasMessage(HistoryErrorCode.LIMITED_AUTHORITY.getMessage()); } + + @Test + void 내가_아닌_공개_계정의_기록의_대댓글을_조회하면_canDelete가_false로_반환된다() { + // given + Member member = memberRepository.findById(3L).orElse(null); + given(memberUtil.getCurrentMember()).willReturn(member); + + // when + SliceResponse response = + commentService.getCommentReplies(1L, null, 3, SortDirection.ASC); + + // then + assertThat(response.content()) + .extracting("replyId", "canDelete") + .containsExactly( + tuple(4L, false), // 다른 사람이 쓴 댓글 + tuple(5L, false), // 다른 사람이 쓴 댓글 + tuple(7L, true) // 내가 쓴 댓글 + ); + } } @Nested From 46c950026bac34358b3de2f1e9d2bba7ed2004c2 Mon Sep 17 00:00:00 2001 From: Ssamssamukja <109636635+Ssamssamukja@users.noreply.github.com> Date: Thu, 5 Feb 2026 01:59:25 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EC=B5=9C=EC=95=A0=EC=BD=94?= =?UTF-8?q?=EB=94=94=20response=EC=97=90=20=EC=BD=94=EB=94=94=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/FavoriteCoordinateResponse.java | 8 +++++--- .../controller/CoordinateControllerTest.java | 10 +++++++--- .../coordinate/service/CoordinateServiceImplTest.java | 7 ++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/clokey-api/src/main/java/org/clokey/domain/coordinate/dto/response/FavoriteCoordinateResponse.java b/clokey-api/src/main/java/org/clokey/domain/coordinate/dto/response/FavoriteCoordinateResponse.java index 7c6a5ad7..e064a052 100644 --- a/clokey-api/src/main/java/org/clokey/domain/coordinate/dto/response/FavoriteCoordinateResponse.java +++ b/clokey-api/src/main/java/org/clokey/domain/coordinate/dto/response/FavoriteCoordinateResponse.java @@ -4,9 +4,11 @@ import org.clokey.coordinate.entity.Coordinate; public record FavoriteCoordinateResponse( - @Schema(description = "코디 ID") Long coordinateId, - @Schema(description = "코디 이미지 url") String imageUrl) { + @Schema(description = "코디 ID", example = "1") Long coordinateId, + @Schema(description = "코디 이미지 url", example = "https://exampe.com") String imageUrl, + @Schema(description = "코디 이름", example = "영화관 데이트") String coordinateName) { public static FavoriteCoordinateResponse from(Coordinate coordinates) { - return new FavoriteCoordinateResponse(coordinates.getId(), coordinates.getImageUrl()); + return new FavoriteCoordinateResponse( + coordinates.getId(), coordinates.getImageUrl(), coordinates.getName()); } } diff --git a/clokey-api/src/test/java/org/clokey/domain/coordinate/controller/CoordinateControllerTest.java b/clokey-api/src/test/java/org/clokey/domain/coordinate/controller/CoordinateControllerTest.java index b14ad183..d4ba629b 100644 --- a/clokey-api/src/test/java/org/clokey/domain/coordinate/controller/CoordinateControllerTest.java +++ b/clokey-api/src/test/java/org/clokey/domain/coordinate/controller/CoordinateControllerTest.java @@ -1645,8 +1645,10 @@ class 최애_코디_조회_요청_시 { // given List response = List.of( - new FavoriteCoordinateResponse(1L, "testImageUrl1"), - new FavoriteCoordinateResponse(2L, "testImageUrl2")); + new FavoriteCoordinateResponse( + 1L, "testImageUrl1", "testCoordinateName1"), + new FavoriteCoordinateResponse( + 2L, "testImageUrl2", "testCoordinateName2")); given(coordinateService.getFavoriteCoordinates()).willReturn(response); @@ -1658,8 +1660,10 @@ class 최애_코디_조회_요청_시 { .andExpect(jsonPath("$.code").value("COMMON200")) .andExpect(jsonPath("$.result[0].coordinateId").value(1)) .andExpect(jsonPath("$.result[0].imageUrl").value("testImageUrl1")) + .andExpect(jsonPath("$.result[0].coordinateName").value("testCoordinateName1")) .andExpect(jsonPath("$.result[1].coordinateId").value(2)) - .andExpect(jsonPath("$.result[1].imageUrl").value("testImageUrl2")); + .andExpect(jsonPath("$.result[1].imageUrl").value("testImageUrl2")) + .andExpect(jsonPath("$.result[1].coordinateName").value("testCoordinateName2")); } } diff --git a/clokey-api/src/test/java/org/clokey/domain/coordinate/service/CoordinateServiceImplTest.java b/clokey-api/src/test/java/org/clokey/domain/coordinate/service/CoordinateServiceImplTest.java index ca2675c5..ffda8002 100644 --- a/clokey-api/src/test/java/org/clokey/domain/coordinate/service/CoordinateServiceImplTest.java +++ b/clokey-api/src/test/java/org/clokey/domain/coordinate/service/CoordinateServiceImplTest.java @@ -1948,12 +1948,13 @@ void setUp() { // then assertThat(responses) - .extracting("coordinateId", "imageUrl") - .containsExactly(tuple(1L, "testUrl1"), tuple(2L, "testUrl2")); + .extracting("coordinateId", "imageUrl", "coordinateName") + .containsExactly( + tuple(1L, "testUrl1", "testName1"), tuple(2L, "testUrl2", "testName2")); } @Test - void 좋아요한_코디가_없는_경우_빈_리스틀_반환한다() { + void 좋아요한_코디가_없는_경우_빈_리스트를_반환한다() { // given Member member = memberRepository.findById(2L).orElseThrow(); given(memberUtil.getCurrentMember()).willReturn(member);