From e0e94d765b4364f1d1469262a3c827d3804f7860 Mon Sep 17 00:00:00 2001 From: 70825 Date: Tue, 2 Apr 2024 23:51:22 +0900 Subject: [PATCH] test19 --- .../review/application/ReviewServiceTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/funeat/review/application/ReviewServiceTest.java b/src/test/java/com/funeat/review/application/ReviewServiceTest.java index f16ea97f..c6c5b918 100644 --- a/src/test/java/com/funeat/review/application/ReviewServiceTest.java +++ b/src/test/java/com/funeat/review/application/ReviewServiceTest.java @@ -30,6 +30,7 @@ import static com.funeat.fixture.ReviewFixture.리뷰추가요청_재구매O_생성; import static com.funeat.fixture.TagFixture.태그_맛있어요_TASTE_생성; import static com.funeat.fixture.TagFixture.태그_아침식사_ETC_생성; +import static com.funeat.review.exception.ReviewErrorCode.REVIEW_NOT_FOUND; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; @@ -56,12 +57,17 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import jakarta.persistence.EntityManager; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; @SuppressWarnings("NonAsciiCharacters") class ReviewServiceTest extends ServiceTest { + @Autowired + private EntityManager entityManager; + @Nested class create_성공_테스트 { @@ -393,14 +399,20 @@ class sortingReviews_성공_테스트 { Thread.sleep(100); final var review3 = 리뷰_이미지test3_평점3점_재구매X_생성(member, product, 130L); 복수_리뷰_저장(review1, review2, review3); - + entityManager.clear(); final var request = 리뷰정렬요청_최신순_생성(3L); final var expected = List.of(review2.getId(), review1.getId()); + Review review3_1 = reviewRepository.findById(3L) + .orElseThrow(() -> new ReviewNotFoundException(REVIEW_NOT_FOUND, 3L)); // when final var actual = reviewService.sortingReviews(productId, memberId, request).getReviews(); + System.out.println("review3.created_at asdfasdf" + review3_1.getCreatedAt()); + System.out.println("review3.created_at asdfasdf" + review3_1.getCreatedAt()); + System.out.println("review size: " + actual.size() + ", and review[0].crated_at" + actual.get(0).getCreatedAt()); + // then assertThat(actual).extracting(SortingReviewDto::getId) .containsExactlyElementsOf(expected);