@@ -3,10 +3,11 @@
 import static org.assertj.core.api.Assertions.assertThat;
 import static reviewme.fixture.QuestionFixture.서술형_필수_질문;
 import static reviewme.fixture.ReviewFixture.비회원_작성_리뷰;
+import static reviewme.fixture.ReviewFixture.회원_작성_리뷰;
 import static reviewme.fixture.ReviewGroupFixture.비회원_리뷰_그룹;
+import static reviewme.fixture.ReviewGroupFixture.회원_리뷰_그룹;
 import static reviewme.fixture.SectionFixture.항상_보이는_섹션;
 
-import java.time.LocalDate;
 import java.util.List;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Nested;
@@ -56,137 +57,194 @@ class ReviewRepositoryTest {
     @Nested
     @DisplayName("리뷰 그룹 아이디에 해당하는 리뷰를 생성일 기준 내림차순으로 페이징하여 불러온다")
     class FindByReviewGroupIdWithLimit {
-        Question question = 서술형_필수_질문();
-        Section section = 항상_보이는_섹션(List.of(question));
-        Template template = templateRepository.save(new Template(List.of(section)));
-        private final ReviewGroup reviewGroup = reviewGroupRepository.save(비회원_리뷰_그룹());
-
-        private final Review review1 = reviewRepository.save(
-                비회원_작성_리뷰(template.getId(), reviewGroup.getId(), null));
-        private final Review review2 = reviewRepository.save(
-                비회원_작성_리뷰(template.getId(), reviewGroup.getId(), null));
-        private final Review review3 = reviewRepository.save(
-                비회원_작성_리뷰(template.getId(), reviewGroup.getId(), null));
-
         @Test
-        void 페이징_크기보다_적은_수의_리뷰가_등록되었으면_그_크기만큼의_리뷰만_반환한다() {
+        void lastReviewId가_주어지지_않을_경우_가장_최근의_리뷰부터_반환한다() {
             // given
-            int limit = 5;
-            long lastReviewId = Long.MAX_VALUE;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+            Review review1 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            Review review2 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            Review review3 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+
+            Long lastReviewId = null;
 
             // when
-            List<Review> actual = reviewRepository.findByReviewGroupIdWithLimit(
-                    reviewGroup.getId(), lastReviewId, limit);
+            List<Review> reviews = reviewRepository.findAllByReviewGroupIdWithLimit(reviewGroup.getId(), lastReviewId, 10);
 
             // then
-            assertThat(actual)
-                    .hasSize(3)
-                    .containsExactly(review3, review2, review1);
+            assertThat(reviews).extracting(Review::getId)
+                    .containsExactly(review3.getId(), review2.getId(), review1.getId());
         }
 
         @Test
-        void 페이징_크기보다_큰_수의_리뷰가_등록되었으면_페이징_크기만큼의_리뷰를_반환한다() {
+        void lastReviewId가_주어질_경우_해당ID_이전의_가장_최근의_리뷰부터_반환한다() {
             // given
-            int limit = 2;
-            long lastReviewId = Long.MAX_VALUE;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+            Review review1 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            Review review2 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            Review review3 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            Review review4 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+
+            long lastReviewId = review3.getId();
 
             // when
-            List<Review> actual = reviewRepository.findByReviewGroupIdWithLimit(
-                    reviewGroup.getId(), lastReviewId, limit);
+            List<Review> reviews = reviewRepository.findAllByReviewGroupIdWithLimit(reviewGroup.getId(), lastReviewId, 10);
 
             // then
-            assertThat(actual)
-                    .hasSize(2)
-                    .containsExactly(review3, review2);
+            assertThat(reviews).extracting(Review::getId)
+                    .containsExactly(review2.getId(), review1.getId());
         }
 
         @Test
-        void 마지막_리뷰_아이디가_주어지지_않으면_가장_최신순으로_리뷰를_반환한다() {
+        void lastReviewId_보다_이전에_등록된_리뷰가_없으면_빈_리스트를_반환한다() {
             // given
-            int limit = 5;
-            Long lastReviewId = null;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+            Review review1 = reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            Review review2 = reviewRepository.save(비회원_작성_리뷰( 1L, reviewGroup.getId(), List.of()));
+            Review review3 = reviewRepository.save(비회원_작성_리뷰( 1L, reviewGroup.getId(), List.of()));
+
+            long lastReviewId = review1.getId();
 
             // when
-            List<Review> actual = reviewRepository.findByReviewGroupIdWithLimit(
-                    reviewGroup.getId(), lastReviewId, limit);
+            List<Review> reviews = reviewRepository.findAllByReviewGroupIdWithLimit(reviewGroup.getId(), lastReviewId, 10);
 
             // then
-            assertThat(actual)
-                    .hasSize(3)
-                    .containsExactly(review3, review2, review1);
+            assertThat(reviews).isEmpty();
         }
 
         @Test
-        void 마지막_리뷰_아이디를_기준으로_그보다_전에_적힌_리뷰를_반환한다() {
+        void 페이징_크기보다_적은_수의_리뷰가_등록되었으면_등록된_크기만큼만_반환한다() {
             // given
-            int limit = 5;
-            long lastReviewId = review3.getId();
+            int numberOfReview = 4;
+            int limit = Integer.MAX_VALUE;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+
+            for (int i = 0; i < numberOfReview; i++) {
+                reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            }
 
             // when
-            List<Review> actual = reviewRepository.findByReviewGroupIdWithLimit(
-                    reviewGroup.getId(), lastReviewId, limit);
+            List<Review> reviews = reviewRepository.findAllByReviewGroupIdWithLimit(reviewGroup.getId(), null, limit);
 
             // then
-            assertThat(actual)
-                    .hasSize(2)
-                    .containsExactly(review2, review1);
+            assertThat(reviews).hasSize(numberOfReview);
         }
 
         @Test
-        void 마지막으로_온_리뷰_전에_작성된_리뷰가_없으면_빈_리스트를_반환한다() {
+        void 페이징_크기보다_큰_수의_리뷰가_등록되었으면_페이징_크기만큼만_반환한다() {
             // given
-            int limit = 5;
-            long lastReviewId = review1.getId();
+            int numberOfReviewGroup = 4;
+            int limit = 3;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+
+            for (int i = 0; i < numberOfReviewGroup; i++) {
+                reviewRepository.save(비회원_작성_리뷰(1L, reviewGroup.getId(), List.of()));
+            }
 
             // when
-            List<Review> actual = reviewRepository.findByReviewGroupIdWithLimit(
-                    reviewGroup.getId(), lastReviewId, limit);
+            List<Review> reviews = reviewRepository.findAllByReviewGroupIdWithLimit(reviewGroup.getId(), null, limit);
 
             // then
-            assertThat(actual).isEmpty();
+            assertThat(reviews).hasSize(limit);
         }
     }
 
     @Nested
-    @DisplayName("주어진 리뷰보다 오래된 리뷰가 있는지 검사한다")
-    class ExistsOlderReviewInReviewGroup {
-        Question question = 서술형_필수_질문();
-        Section section = 항상_보이는_섹션(List.of(question));
-        Template template = templateRepository.save(new Template(List.of(section)));
+    @DisplayName("회원 아이디에 해당하는 리뷰를 생성일 기준 내림차순으로 페이징하여 불러온다")
+    class FindByMemberIdWithLimit {
 
-        ReviewGroup reviewGroup = reviewGroupRepository.save(비회원_리뷰_그룹());
+        @Test
+        void lastReviewId가_주어지지_않을_경우_가장_최근의_리뷰부터_반환한다() {
+            // given
+            long memberId = 1L;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+            Review review1 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review2 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review3 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
 
-        Review firstReview = reviewRepository.save(
-                비회원_작성_리뷰(template.getId(), reviewGroup.getId(), null));
-        Review secondReview = reviewRepository.save(
-                비회원_작성_리뷰(template.getId(), reviewGroup.getId(), null));
+            Long lastReviewId = null;
+
+            // when
+            List<Review> reviews = reviewRepository.findAllByMemberIdWithLimit(memberId, lastReviewId, 10);
+
+            // then
+            assertThat(reviews).extracting(Review::getId)
+                    .containsExactly(review3.getId(), review2.getId(), review1.getId());
+        }
 
         @Test
-        void 주어진_리뷰가_가장_오래된_경우() {
+        void lastReviewId가_주어질_경우_해당ID_이전의_가장_최근의_리뷰부터_반환한다() {
             // given
-            long reviewGroupId = reviewGroup.getId();
-            long reviewId = firstReview.getId();
-            LocalDate createdAt = firstReview.getCreatedAt().toLocalDate();
+            long memberId = 1L;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+            Review review1 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review2 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review3 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review4 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+
+            long lastReviewId = review3.getId();
 
             // when
-            boolean isOlderExist = reviewRepository.existsOlderReviewInGroup(reviewGroupId, reviewId, createdAt);
+            List<Review> reviews = reviewRepository.findAllByMemberIdWithLimit(memberId, lastReviewId, 10);
 
             // then
-            assertThat(isOlderExist).isFalse();
+            assertThat(reviews).extracting(Review::getId)
+                    .containsExactly(review2.getId(), review1.getId());
         }
 
         @Test
-        void 주어진_리뷰가_가장_오래되지_않은_경우() {
+        void lastReviewId_보다_이전에_등록된_리뷰가_없으면_빈_리스트를_반환한다() {
             // given
-            long reviewGroupId = reviewGroup.getId();
-            long reviewId = secondReview.getId();
-            LocalDate createdAt = secondReview.getCreatedAt().toLocalDate();
+            long memberId = 1L;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+            Review review1 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review2 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            Review review3 = reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+
+            long lastReviewId = review1.getId();
+
+            // when
+            List<Review> reviews = reviewRepository.findAllByMemberIdWithLimit(memberId, lastReviewId, 10);
+
+            // then
+            assertThat(reviews).isEmpty();
+        }
+
+        @Test
+        void 페이징_크기보다_적은_수의_리뷰가_등록되었으면_등록된_크기만큼만_반환한다() {
+            // given
+            long memberId = 1L;
+            int numberOfReview = 4;
+            int limit = Integer.MAX_VALUE;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+
+            for (int i = 0; i < numberOfReview; i++) {
+                reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            }
+
+            // when
+            List<Review> reviews = reviewRepository.findAllByMemberIdWithLimit(memberId, null, limit);
+
+            // then
+            assertThat(reviews).hasSize(numberOfReview);
+        }
+
+        @Test
+        void 페이징_크기보다_큰_수의_리뷰가_등록되었으면_페이징_크기만큼만_반환한다() {
+            // given
+            long memberId = 1L;
+            int numberOfReviewGroup = 4;
+            int limit = 3;
+            ReviewGroup reviewGroup = reviewGroupRepository.save(회원_리뷰_그룹());
+
+            for (int i = 0; i < numberOfReviewGroup; i++) {
+                reviewRepository.save(회원_작성_리뷰(memberId, 1L, reviewGroup.getId(), List.of()));
+            }
 
             // when
-            boolean isOlderExist = reviewRepository.existsOlderReviewInGroup(reviewGroupId, reviewId, createdAt);
+            List<Review> reviews = reviewRepository.findAllByMemberIdWithLimit(memberId, null, limit);
 
             // then
-            assertThat(isOlderExist).isTrue();
+            assertThat(reviews).hasSize(limit);
         }
     }
 }

리뷰: 이것도 "이전"이 의미가 맞지 않을까요?