diff --git a/src/test/java/com/funeat/fixture/PageFixture.java b/src/test/java/com/funeat/fixture/PageFixture.java index 773658f4..a53cbd64 100644 --- a/src/test/java/com/funeat/fixture/PageFixture.java +++ b/src/test/java/com/funeat/fixture/PageFixture.java @@ -5,6 +5,10 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.domain.Sort.Order; + +import java.util.ArrayList; +import java.util.List; @SuppressWarnings("NonAsciiCharacters") public class PageFixture { @@ -18,7 +22,7 @@ public class PageFixture { public static final String 평점_오름차순 = "rating,asc"; public static final String 평점_내림차순 = "rating,desc"; public static final String 과거순 = "createdAt,asc"; - public static final String 최신순 = "createdAt,desc"; + public static final String 최신순 = "createdAt,desc,id,desc"; public static final String 아이디_내림차순 = "id,desc"; public static final Long PAGE_SIZE = 10L; @@ -36,10 +40,14 @@ public class PageFixture { public static PageRequest 페이지요청_생성(final int page, final int size, final String sort) { final String[] splitSort = sort.split(","); - final String order = splitSort[0]; - final Direction direction = Direction.fromString(splitSort[1]); - - return PageRequest.of(page, size, Sort.by(direction, order)); + final List orders = new ArrayList<>(); + for (int idx = 0; idx < splitSort.length; idx += 2) { + final String property = splitSort[idx]; + final Direction direction = Direction.fromString(splitSort[idx + 1]); + orders.add(new Order(direction, property)); + } + + return PageRequest.of(page, size, Sort.by(orders)); } public static PageDto 응답_페이지_생성(final Long totalDataCount, final Long totalPages, final boolean firstPage,