diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepositoryImpl.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepositoryImpl.java index 3d8645bba..42eb53d08 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepositoryImpl.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/QuerydslAuctionRepositoryImpl.java @@ -8,12 +8,15 @@ import com.ddang.ddang.auction.configuration.util.AuctionSortConditionConsts; import com.ddang.ddang.auction.domain.Auction; -import com.ddang.ddang.auction.infrastructure.persistence.util.AuctionSortCondition; +import com.ddang.ddang.auction.infrastructure.persistence.exception.UnsupportedSortConditionException; import com.ddang.ddang.auction.presentation.dto.request.ReadAuctionSearchCondition; import com.ddang.ddang.common.helper.QuerydslSliceHelper; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.CaseBuilder; +import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -47,13 +50,51 @@ public Slice findAuctionsAllByCondition( } private List> calculateOrderSpecifiers(final Pageable pageable) { - final List> orderSpecifiers = new ArrayList<>(convertOrderSpecifiers(pageable)); + final List> orderSpecifiers = new ArrayList<>(processOrderSpecifiers(pageable)); orderSpecifiers.add(auction.id.desc()); return orderSpecifiers; } + private List> processOrderSpecifiers(final Pageable pageable) { + final List> orderSpecifiers = new ArrayList<>(); + final Sort sort = pageable.getSort(); + + for (final Order order : sort) { + if (AuctionSortConditionConsts.ID.equals(order.getProperty())) { + return Collections.emptyList(); + } + + orderSpecifiers.addAll(processOrderSpecifierByCondition(order)); + } + + return orderSpecifiers; + } + + private List> processOrderSpecifierByCondition(final Order order) { + if (AuctionSortConditionConsts.RELIABILITY.equals(order.getProperty())) { + return List.of(auction.seller.reliability.desc()); + } + if (AuctionSortConditionConsts.AUCTIONEER_COUNT.equals(order.getProperty())) { + return List.of(auction.auctioneerCount.desc()); + } + if (AuctionSortConditionConsts.CLOSING_TINE.equals(order.getProperty())) { + final LocalDateTime now = LocalDateTime.now(); + final NumberExpression closingTimeOrder = new CaseBuilder() + .when(auction.closingTime.after(now)).then(1) + .otherwise(2); + final List> orderSpecifiers = new ArrayList<>(); + + orderSpecifiers.add(closingTimeOrder.asc()); + orderSpecifiers.add(auction.closingTime.asc()); + + return orderSpecifiers; + } + + throw new UnsupportedSortConditionException("지원하지 않는 정렬 방식입니다."); + } + private List calculateBooleanExpressions(final ReadAuctionSearchCondition searchCondition) { final List booleanExpressions = new ArrayList<>(); @@ -92,21 +133,6 @@ private BooleanExpression convertTitleSearchCondition(final ReadAuctionSearchCon return auction.title.like("%" + titleSearchCondition + "%"); } - private List> convertOrderSpecifiers(final Pageable pageable) { - final List> orderSpecifiers = new ArrayList<>(); - final Sort sort = pageable.getSort(); - - for (final Order order : sort) { - if (AuctionSortConditionConsts.ID.equals(order.getProperty())) { - return Collections.emptyList(); - } - - orderSpecifiers.add(AuctionSortCondition.convert(order)); - } - - return orderSpecifiers; - } - private List findAuctionsByIdsAndOrderSpecifiers( final List targetIds, final List> orderSpecifiers @@ -144,7 +170,10 @@ public Optional findAuctionById(final Long auctionId) { @Override public Slice findAuctionsAllByUserId(final Long userId, final Pageable pageable) { - final List booleanExpressions = List.of(auction.seller.id.eq(userId)); + final List booleanExpressions = List.of( + auction.seller.id.eq(userId), + auction.deleted.isFalse() + ); final List> orderSpecifiers = List.of(auction.id.desc()); final List findAuctionIds = findAuctionIds(booleanExpressions, orderSpecifiers, pageable); final List findAuctions = findAuctionsByIdsAndOrderSpecifiers( diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/util/exception/UnsupportedSortConditionException.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/exception/UnsupportedSortConditionException.java similarity index 71% rename from backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/util/exception/UnsupportedSortConditionException.java rename to backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/exception/UnsupportedSortConditionException.java index 752dfaa1a..336072ceb 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/util/exception/UnsupportedSortConditionException.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/exception/UnsupportedSortConditionException.java @@ -1,4 +1,4 @@ -package com.ddang.ddang.auction.infrastructure.persistence.util.exception; +package com.ddang.ddang.auction.infrastructure.persistence.exception; public class UnsupportedSortConditionException extends IllegalArgumentException { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/util/AuctionSortCondition.java b/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/util/AuctionSortCondition.java deleted file mode 100644 index 775f00dc4..000000000 --- a/backend/ddang/src/main/java/com/ddang/ddang/auction/infrastructure/persistence/util/AuctionSortCondition.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ddang.ddang.auction.infrastructure.persistence.util; - -import static com.ddang.ddang.auction.domain.QAuction.auction; -import static org.springframework.data.domain.Sort.Order; - -import com.ddang.ddang.auction.configuration.util.AuctionSortConditionConsts; -import com.ddang.ddang.auction.infrastructure.persistence.util.exception.UnsupportedSortConditionException; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.dsl.ComparableExpressionBase; -import java.util.Arrays; - -public enum AuctionSortCondition { - - ID(AuctionSortConditionConsts.ID, auction.id), - AUCTIONEER_COUNT(AuctionSortConditionConsts.AUCTIONEER_COUNT, auction.auctioneerCount), - CLOSING_TIME(AuctionSortConditionConsts.CLOSING_TINE, auction.closingTime), - RELIABILITY(AuctionSortConditionConsts.RELIABILITY, auction.seller.reliability); - - private final String sortCondition; - private final ComparableExpressionBase sortExpression; - - AuctionSortCondition(final String sortCondition, final ComparableExpressionBase sortExpression) { - this.sortCondition = sortCondition; - this.sortExpression = sortExpression; - } - - public static OrderSpecifier convert(final Order order) { - return Arrays.stream(AuctionSortCondition.values()) - .filter(auctionSortCondition -> isTargetSort(order, auctionSortCondition)) - .findAny() - .map(auctionSortCondition -> convertOrderSpecifier(auctionSortCondition, order)) - .orElseThrow(() -> new UnsupportedSortConditionException("지원하지 않는 정렬 방식입니다.")); - } - - private static boolean isTargetSort(final Order order, final AuctionSortCondition converter) { - return converter.sortCondition.equals(order.getProperty()); - } - - private static OrderSpecifier convertOrderSpecifier( - final AuctionSortCondition sortCondition, - final Order order - ) { - if (order.isDescending()) { - return sortCondition.sortExpression.desc(); - } - - return sortCondition.sortExpression.asc(); - } -} diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByBidderIdTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByBidderIdTest.java index c98c863b8..d19f3d7da 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByBidderIdTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByBidderIdTest.java @@ -10,22 +10,22 @@ /** * 사용하는 더미 데이터 (제목 키워드 / ID / 신뢰도 / 경매 참여자 수 / 경매 마감일 / 판매자) * - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 / seller 1 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 / seller 1 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 / seller 2 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 / seller 3 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 / seller 4 * Auction5 : 핫식스 / 5L / 1.5d / 4 / 1일 뒤 / seller 5 - * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 뒤 / seller 6 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 / seller 1 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 전 / seller 6 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 / seller 1 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 / seller 2 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 / seller 2 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 / seller 2 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 / seller 2 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 / seller 2 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 / seller 2 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 / seller 2 */ @SuppressWarnings("NonAsciiCharacters") public class AuctionQueryByBidderIdTest extends InitializeCommonAuctionData { diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByUserIdTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByUserIdTest.java index 30fad54c4..8f96083e7 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByUserIdTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionQueryByUserIdTest.java @@ -10,22 +10,22 @@ /** * 사용하는 더미 데이터 (제목 키워드 / ID / 신뢰도 / 경매 참여자 수 / 경매 마감일 / 판매자) * - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 / seller 1 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 / seller 1 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 / seller 2 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 / seller 3 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 / seller 4 * Auction5 : 핫식스 / 5L / 1.5d / 4 / 1일 뒤 / seller 5 - * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 뒤 / seller 6 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 / seller 1 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 전 / seller 6 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 / seller 1 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 / seller 2 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 / seller 2 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 / seller 2 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 / seller 2 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 / seller 2 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 / seller 2 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 / seller 2 */ @SuppressWarnings("NonAsciiCharacters") public class AuctionQueryByUserIdTest extends InitializeCommonAuctionData { @@ -36,11 +36,11 @@ class 회원이_등록한_경매_목록_조회_테스트 { /** * seller 2 기반 경매 목록 * - * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 / seller 2 Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 / seller 2 Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 / seller 2 Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 / seller 2 + * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 / seller 2 Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 / seller 2 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 / seller 2 Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 / seller 2 Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 / seller 2 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 / seller 2 Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 / seller 2 + * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 / seller 2 Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 / seller 2 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 / seller 2 Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 / seller 2 */ @Nested class Seller2_요청_테스트 { diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchAndSortQueryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchAndSortQueryTest.java index 05cef930a..43af54aba 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchAndSortQueryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchAndSortQueryTest.java @@ -13,22 +13,22 @@ /** * 사용하는 더미 데이터 (제목 키워드 / ID / 신뢰도 / 경매 참여자 수 / 경매 마감일) * - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 * Auction5 : 핫식스 / 5L / 1.5d / 4 / 1일 뒤 - * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 + * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 전 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 - * Auction16 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 */ @SuppressWarnings("NonAsciiCharacters") public class AuctionSearchAndSortQueryTest extends InitializeCommonAuctionData { @@ -44,17 +44,17 @@ class 맥북_검색_테스트 { * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 */ @Nested class Id_기준_정렬_조회_테스트 { @@ -189,15 +189,15 @@ class Id_기준_정렬_조회_테스트 { * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 */ @Nested @@ -330,17 +330,17 @@ class 경매_참여자_수_정렬_조회_테스트 { * 신뢰도 기준 정렬 순서 * * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 * @@ -475,19 +475,19 @@ class 신뢰도_정렬_조회_테스트 { * 마감 임박순 기준 정렬 순서 * * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 - * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 */ @Nested class 마감_임박순_정렬_조회_테스트 { @@ -507,8 +507,8 @@ class 마감_임박순_정렬_조회_테스트 { SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction4); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction7); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction3); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction3); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction15); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -527,9 +527,9 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction16); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction15); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction14); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction14); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction12); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction11); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -548,9 +548,9 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction13); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction12); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction11); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction10); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction2); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction1); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -569,9 +569,9 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction10); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction9); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction8); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction16); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction13); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction9); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -590,8 +590,8 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(2); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction2); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction1); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction8); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction7); softAssertions.assertThat(actual.hasNext()).isFalse(); }); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchTitleQueryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchTitleQueryTest.java index f333c300b..ca1e5f6b9 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchTitleQueryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSearchTitleQueryTest.java @@ -10,23 +10,22 @@ /** * 사용하는 더미 데이터 (제목 키워드 / ID / 신뢰도 / 경매 참여자 수 / 경매 마감일) * - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 * Auction5 : 핫식스 / 5L / 1.5d / 4 / 1일 뒤 - * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 + * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 전 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 - * Auction16 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 - * Auction17 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 */ @SuppressWarnings("NonAsciiCharacters") class AuctionSearchTitleQueryTest extends InitializeCommonAuctionData { @@ -80,7 +79,7 @@ class AuctionSearchTitleQueryTest extends InitializeCommonAuctionData { /** * 제목 "맥북" 검색 시 결과 * - * Auction16 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 */ @@ -106,7 +105,7 @@ class AuctionSearchTitleQueryTest extends InitializeCommonAuctionData { * 제목 "맥북" 검색 시 결과 * * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 */ @Test void 검색_결과가_페이지_크기보다_큰_경우_마지막_페이지를_요청하면_검색_결과를_페이지로_나눈_나머지만큼의_검색_결과를_가진_Slice를_반환한다() { diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSortQueryTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSortQueryTest.java index 96eacc998..2182b24f5 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSortQueryTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/AuctionSortQueryTest.java @@ -13,22 +13,22 @@ /** * 사용하는 더미 데이터 (제목 키워드 / ID / 신뢰도 / 경매 참여자 수 / 경매 마감일) * - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 * Auction5 : 핫식스 / 5L / 1.5d / 4 / 1일 뒤 - * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 + * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 전 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 - * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 */ @SuppressWarnings("NonAsciiCharacters") class AuctionSortQueryTest extends InitializeCommonAuctionData { @@ -538,21 +538,21 @@ class 경매_참여자_수_정렬_조회_테스트 { * 마감 임박순 기준 정렬 순서 * * Auction5 : 핫식스 / 5L / 1.5d / 4 / 1일 뒤 - * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 뒤 * Auction4 : 맥북 / 4L / 5.0d / 7 / 2일 뒤 - * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 뒤 * Auction3 : 맥북 / 3L / 2.1d / 4 / 3일 뒤 - * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 뒤 * Auction15 : 맥북 / 15L / 3.5d / 6 / 4일 뒤 * Auction14 : 맥북 / 14L / 3.5d / 6 / 4일 뒤 - * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 뒤 * Auction12 : 맥북 / 12L / 3.5d / 6 / 4일 뒤 * Auction11 : 맥북 / 11L / 3.5d / 6 / 4일 뒤 * Auction10 : 맥북 / 10L / 3.5d / 6 / 4일 뒤 * Auction2 : 맥북 / 2L / 3.5d / 1 / 4일 뒤 - * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 뒤 - * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 뒤 - * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 뒤 + * Auction1 : 맥북 / 1L / 4.7d / 2 / 5일 전 + * Auction16 : 맥북 / 16L / 3.5d / 6 / 4일 전 + * Auction13 : 맥북 / 13L / 3.5d / 6 / 4일 전 + * Auction9 : 맥북 / 9L / 3.5d / 6 / 4일 전 + * Auction8 : 맥북 / 8L / 3.5d / 6 / 4일 전 + * Auction7 : 맥북 / 7L / 4.7d / 3 / 3일 전 + * Auction6 : 레드불 / 6L / 0.3d / 8 / 2일 전 */ @Nested class 마감_임박순_정렬_조회_테스트 { @@ -572,8 +572,8 @@ class 마감_임박순_정렬_조회_테스트 { SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction5); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction6); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction4); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction4); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction3); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -592,9 +592,9 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction7); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction3); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction16); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction15); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction14); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction12); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -613,9 +613,9 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction15); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction14); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction13); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction11); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction10); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction2); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -634,9 +634,9 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(3); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction12); - softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction11); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction10); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction1); + softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction16); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction13); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -657,7 +657,7 @@ class 마감_임박순_정렬_조회_테스트 { softAssertions.assertThat(actual).hasSize(3); softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction9); softAssertions.assertThat(actual.getContent().get(1)).isEqualTo(auction8); - softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction2); + softAssertions.assertThat(actual.getContent().get(2)).isEqualTo(auction7); softAssertions.assertThat(actual.hasNext()).isTrue(); }); } @@ -676,7 +676,7 @@ class 마감_임박순_정렬_조회_테스트 { // then SoftAssertions.assertSoftly(softAssertions -> { softAssertions.assertThat(actual).hasSize(1); - softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction1); + softAssertions.assertThat(actual.getContent().get(0)).isEqualTo(auction6); softAssertions.assertThat(actual.hasNext()).isFalse(); }); } diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/InitializeCommonAuctionData.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/InitializeCommonAuctionData.java index e72f9f809..7a8988121 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/InitializeCommonAuctionData.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/InitializeCommonAuctionData.java @@ -59,41 +59,41 @@ void setUp() { querydslAuctionRepository = new QuerydslAuctionRepositoryImpl(new JPAQueryFactory(em)); seller1 = User.builder() - .name("회원1234543211") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(4.7d) - .oauthId("1234543211") - .build(); + .name("회원1234543211") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(4.7d) + .oauthId("1234543211") + .build(); seller2 = User.builder() - .name("회원1234543212") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(3.5d) - .oauthId("1234543212") - .build(); + .name("회원1234543212") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(3.5d) + .oauthId("1234543212") + .build(); seller3 = User.builder() - .name("회원1234543213") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(2.1d) - .oauthId("1234543213") - .build(); + .name("회원1234543213") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(2.1d) + .oauthId("1234543213") + .build(); seller4 = User.builder() - .name("회원1234543214") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(5.0d) - .oauthId("1234543214") - .build(); + .name("회원1234543214") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(5.0d) + .oauthId("1234543214") + .build(); seller5 = User.builder() - .name("회원1234543215") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(1.5d) - .oauthId("1234543215") - .build(); + .name("회원1234543215") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(1.5d) + .oauthId("1234543215") + .build(); seller6 = User.builder() - .name("회원1234543216") - .profileImage(new ProfileImage("upload.png", "store.png")) - .reliability(0.3d) - .oauthId("1234543216") - .build(); + .name("회원1234543216") + .profileImage(new ProfileImage("upload.png", "store.png")) + .reliability(0.3d) + .oauthId("1234543216") + .build(); seller7 = User.builder() .name("회원1234543217") .profileImage(new ProfileImage("upload.png", "store.png")) @@ -118,7 +118,7 @@ void setUp() { .description("레드불을 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(2)) + .closingTime(nowTime.minusDays(2)) .seller(seller6) .build(); bidding(auction6, seller1); @@ -128,7 +128,7 @@ void setUp() { .description("맥북을 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(4)) + .closingTime(nowTime.minusDays(4)) .seller(seller2) .build(); bidding(auction8, seller1); @@ -138,7 +138,7 @@ void setUp() { .description("맥북을 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(4)) + .closingTime(nowTime.minusDays(4)) .seller(seller2) .build(); bidding(auction16, seller1); @@ -148,7 +148,7 @@ void setUp() { .description("맥북을 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(4)) + .closingTime(nowTime.minusDays(4)) .seller(seller2) .build(); bidding(auction9, seller1); @@ -158,7 +158,7 @@ void setUp() { .description("맥북을 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(4)) + .closingTime(nowTime.minusDays(4)) .seller(seller2) .build(); bidding(auction13, seller1); @@ -168,7 +168,7 @@ void setUp() { .description("맥북1을 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(3)) + .closingTime(nowTime.minusDays(3)) .seller(seller1) .build(); addAuctioneerCount(auction7, 3); @@ -177,7 +177,7 @@ void setUp() { .description("맥북에어를 팝니다") .bidUnit(new BidUnit(1_000)) .startPrice(new Price(1_000)) - .closingTime(nowTime.plusDays(5)) + .closingTime(nowTime.minusDays(5)) .seller(seller1) .build(); addAuctioneerCount(auction1, 2); diff --git a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/util/AuctionSortConditionTest.java b/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/util/AuctionSortConditionTest.java deleted file mode 100644 index 825444fc4..000000000 --- a/backend/ddang/src/test/java/com/ddang/ddang/auction/infrastructure/persistence/util/AuctionSortConditionTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ddang.ddang.auction.infrastructure.persistence.util; - -import static com.ddang.ddang.auction.domain.QAuction.auction; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import com.ddang.ddang.auction.infrastructure.persistence.util.exception.UnsupportedSortConditionException; -import com.querydsl.core.types.OrderSpecifier; -import java.util.stream.Stream; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.springframework.data.domain.Sort.Order; - -class AuctionSortConditionTest { - - @ParameterizedTest(name = "condition이 {0}일 때 {1}을 반환한다.") - @MethodSource("successConvertConditionArguments") - void 유효한_정렬_조건을_전달하면_Querydsl_표현식을_반환한다( - final String sortCondition, - final OrderSpecifier expected - ) { - final OrderSpecifier actual = AuctionSortCondition.convert(Order.by(sortCondition)); - - assertThat(actual).isEqualTo(expected); - } - - private static Stream successConvertConditionArguments() { - return Stream.of( - Arguments.arguments("id", auction.id.asc()), - Arguments.arguments("auctioneerCount", auction.auctioneerCount.asc()), - Arguments.arguments("closingTime", auction.closingTime.asc()), - Arguments.arguments("reliability", auction.seller.reliability.asc()) - ); - } - - @Test - void 유효하지_않은_정렬_조건을_전달하면_예외가_발생한다() { - final String invalidSortCondition = "invalidSortCondition"; - - assertThatThrownBy(() -> AuctionSortCondition.convert(Order.asc(invalidSortCondition))) - .isInstanceOf(UnsupportedSortConditionException.class) - .hasMessageContaining("지원하지 않는 정렬 방식입니다."); - } -}