Skip to content

Commit

Permalink
Test: Controller - 유저 좋아요한 리뷰 조회 테스트 코드 작성 (TAVE-balak#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyjyjy25 committed Feb 17, 2024
1 parent dcecc17 commit 448695f
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,30 @@ public void findUserReviews() throws Exception {
.andExpect(jsonPath("$.data").isNotEmpty())
.andExpect(jsonPath("$.data", response).exists());
}

@Test
@DisplayName("유저는 좋아요한 리뷰 목록을 조회할 수 있다.")
public void findUserLikedReviews() throws Exception {
// given
List<String> reviewTagNames1 = new ArrayList<>(Arrays.asList("극장에서 또 보고 싶어요"));
MyReviewDto reviewDto1 = new MyReviewDto(6L, LocalDateTime.now(), "https://ottify-s3-bucket.s3.ap-northeast-2.amazonaws.com/profile-images/813f55bc-8900-49e3-8e6b-98cc85f2fa0d.jpg",
"닉네임1", "어벤져스: 인피니티 워", 3.5, reviewTagNames1, "액션 그 자체 난 아직도 이때가 그립다", 3);

List<String> reviewTagNames2 = new ArrayList<>(Arrays.asList("극장에서 또 보고 싶어요"));
MyReviewDto reviewDto2 = new MyReviewDto(7L, LocalDateTime.now(), "https://ottify-s3-bucket.s3.ap-northeast-2.amazonaws.com/profile-images/813f55bc-8900-49e3-8e6b-98cc85f2fa0d.jpg",
"닉네임2", "어벤져스", 4.5, reviewTagNames1, "그 시절 나는 슈퍼 hero 였다 ...", 3);

List<MyReviewDto> response = new ArrayList<>(Arrays.asList(reviewDto1, reviewDto2));

// when
when(userService.getLikedReview(any(Pageable.class))).thenReturn(response);

ResultActions result = mockMvc.perform(get(BASE_URL + "/likedReviews"));

// then
result.andExpect(status().isOk())
.andExpect(jsonPath("$.data").isNotEmpty())
.andExpect(jsonPath("$.data", response).exists());

}
}

0 comments on commit 448695f

Please sign in to comment.