@@ -1,20 +1,25 @@
 package com.toongather.toongather.domain.review.repository;
 
-import static org.junit.jupiter.api.Assertions.*;
+
 
 import com.toongather.toongather.domain.member.domain.Member;
-import com.toongather.toongather.domain.member.repository.MemberRepository;
 import com.toongather.toongather.domain.member.service.MemberService;
 import com.toongather.toongather.domain.review.domain.Review;
 import com.toongather.toongather.domain.review.domain.ReviewSortType;
+import com.toongather.toongather.domain.review.dto.ReviewSearchDto;
 import com.toongather.toongather.domain.webtoon.domain.Age;
 import com.toongather.toongather.domain.webtoon.domain.Platform;
 import com.toongather.toongather.domain.webtoon.domain.Webtoon;
 import com.toongather.toongather.domain.webtoon.domain.WebtoonStatus;
 import com.toongather.toongather.domain.webtoon.repository.WebtoonRepository;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 import javax.transaction.Transactional;
+import org.assertj.core.api.Assertions;
 import org.junit.Test;
-import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +34,9 @@
 @Rollback(false)
 public class ReviewJpaRepositoryTest {
 
+  @PersistenceContext
+  private EntityManager em;
+
   @Autowired
   private ReviewJpaRepository reviewJpaRepository;
 
@@ -38,12 +46,13 @@ public class ReviewJpaRepositoryTest {
   @Autowired
   private WebtoonRepository webtoonRepository;
 
-  @DisplayName("jpql로 작성한 리뷰를 정렬타입에 따라서 조회 할 수 있다.")
+  @DisplayName("[jpql] 작성한 리뷰를 정렬타입에 따라서 조회 할 수 있다.")
+  @Rollback(true)
   @Test
-  public void searchWithSortType() {
+  public void searchWithSortTypeJpql() throws ParseException {
     //Given
-   Member m1= Member.builder().name("김동휘").nickName("닉네임").phone("010-2345-1234").email("123@gmail.com").password("123").build();
-   memberService.join(m1);
+    Member m1= Member.builder().name("김동휘").nickName("닉네임").phone("010-2345-1234").email("123@gmail.com").password("123").build();
+    memberService.join(m1);
 
     Webtoon w1 = Webtoon.builder()
         .toonId("1000000721433")
@@ -67,24 +76,49 @@ public void searchWithSortType() {
 
     Review r1 = Review.builder().member(m1)
         .star(5L)
-        .recomandComment("넘잼")
+        .recommendComment("넘잼")
         .toon(w1)
         .build();
     reviewJpaRepository.save(r1);
-    
+
+    reviewJpaRepository.flush();
+
+    try {
+      Thread.sleep(2000);
+    } catch (InterruptedException e) {
+      e.printStackTrace();
+    }
+
     Review r2 = Review.builder().member(m1)
         .star(4L)
-        .recomandComment("넘잼")
+        .recommendComment("넘잼")
         .toon(w2)
         .build();
-    reviewJpaRepository.save(r1);
-
-    ReviewSortType sort = ReviewSortType.STAR_ASC;
+    reviewJpaRepository.save(r2);
 
     //When
-    reviewJpaRepository.searchWithSortType(sort);
+    ReviewSortType starAscSort = ReviewSortType.STAR_ASC;
+    List<ReviewSearchDto> statAscResult = reviewJpaRepository.findAllWithSortType(starAscSort);
+
+    ReviewSortType starDescSort = ReviewSortType.STAR_DESC;
+    List<ReviewSearchDto> statDescResult = reviewJpaRepository.findAllWithSortType(starDescSort);
+
+    ReviewSortType createDtDescSort = ReviewSortType.CREATE_DATE_DESC;
+    List<ReviewSearchDto> createDtDescResult = reviewJpaRepository.findAllWithSortType(createDtDescSort);
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+//    for (ReviewSearchDto dto: createDtDescResult) {
+//      System.out.println("date : "+ dto.getReviewDate());
+//      System.out.println("date : "+ sdf.parse(dto.getReviewDate()));
+//    };
+
     //Then
-    //org.assertj.core.api.Assertions.assertThat()
+//    System.out.println("star 1: "+statAscResult.get(0).getStar());
+//    System.out.println("star 2: "+statDescResult.get(0).getStar());
+    Assertions.assertThat(statAscResult.get(0).getStar()).isEqualTo(4L);
+    Assertions.assertThat(statDescResult.get(0).getStar()).isEqualTo(5L);
+    Assertions.assertThat(sdf.parse(createDtDescResult.get(0).getReviewDate()))
+        .isAfter(sdf.parse(createDtDescResult.get(1).getReviewDate()));
 
   }
 

리뷰: 여기에 sleep 코드는 왜 있는건가요??