Skip to content

Commit ab75e87

Browse files
committed
test: MyHistoryControllerTest 내 getMyLikedPosts 테스트 필드 검증 추가
1 parent 28d284e commit ab75e87

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/test/java/com/back/domain/myhistory/controller/MyHistoryControllerTest.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.back.domain.myhistory.controller;
22

33
import com.back.domain.myhistory.dto.*;
4+
import com.back.domain.post.post.enums.PostStatus;
45
import com.back.domain.myhistory.service.MyHistoryService;
56
import com.back.global.aspect.ResponseAspect;
67
import com.back.global.jwt.JwtUtil;
@@ -245,14 +246,24 @@ void getMyComments() throws Exception {
245246
void getMyLikedPosts() throws Exception {
246247
SecurityUser principal = createPrincipal(13L);
247248
LocalDateTime likedAt = LocalDateTime.of(2025, 3, 10, 21, 5, 0);
249+
LocalDateTime createdAt = likedAt.minusDays(2);
250+
LocalDateTime updatedAt = likedAt.minusDays(1);
248251

249252
MyHistoryLikedPostItemDto item = MyHistoryLikedPostItemDto.builder()
250253
.id(70L)
254+
.postId(501L)
255+
.categoryName("칵테일")
256+
.userNickName("하덕코딩")
251257
.title("봄 추천 칵테일")
258+
.content("상큼한 맛을 느껴보세요")
252259
.imageUrls(List.of("https://example.com/spring.png"))
253-
.likedAt(likedAt)
260+
.createdAt(createdAt)
261+
.updatedAt(updatedAt)
262+
.status(PostStatus.PUBLIC)
254263
.likeCount(88)
255264
.commentCount(12)
265+
.viewCount(345)
266+
.likedAt(likedAt)
256267
.build();
257268

258269
MyHistoryLikedPostListDto responseDto = new MyHistoryLikedPostListDto(
@@ -274,11 +285,18 @@ void getMyLikedPosts() throws Exception {
274285
.accept(MediaType.APPLICATION_JSON))
275286
.andExpect(status().isOk())
276287
.andExpect(jsonPath("$.data.items[0].id").value(70L))
288+
.andExpect(jsonPath("$.data.items[0].postId").value(501L))
289+
.andExpect(jsonPath("$.data.items[0].categoryName").value("칵테일"))
290+
.andExpect(jsonPath("$.data.items[0].userNickName").value("하덕코딩"))
277291
.andExpect(jsonPath("$.data.items[0].title").value("봄 추천 칵테일"))
292+
.andExpect(jsonPath("$.data.items[0].content").value("상큼한 맛을 느껴보세요"))
278293
.andExpect(jsonPath("$.data.items[0].imageUrls[0]").value("https://example.com/spring.png"))
279-
.andExpect(jsonPath("$.data.items[0].likedAt").value(ISO_WITH_SECONDS.format(likedAt)))
280-
.andExpect(jsonPath("$.data.items[0].likeCount").value(88))
294+
.andExpect(jsonPath("$.data.items[0].createdAt").value(ISO_WITH_SECONDS.format(createdAt)))
295+
.andExpect(jsonPath("$.data.items[0].updatedAt").value(ISO_WITH_SECONDS.format(updatedAt)))
296+
.andExpect(jsonPath("$.data.items[0].status").value(PostStatus.PUBLIC.name()))
281297
.andExpect(jsonPath("$.data.items[0].commentCount").value(12))
298+
.andExpect(jsonPath("$.data.items[0].viewCount").value(345))
299+
.andExpect(jsonPath("$.data.items[0].likedAt").value(ISO_WITH_SECONDS.format(likedAt)))
282300
.andExpect(jsonPath("$.data.hasNext").value(true))
283301
.andExpect(jsonPath("$.data.nextId").value(55L));
284302

0 commit comments

Comments
 (0)