Skip to content

Commit 09b8fdb

Browse files
avoid using internal AstSortOrder as EnumSource in SortingSelectQueryIntegrationTests
1 parent 9eab404 commit 09b8fdb

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/integrationTest/java/com/mongodb/hibernate/query/select/SortingSelectQueryIntegrationTests.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
package com.mongodb.hibernate.query.select;
1818

1919
import static com.mongodb.hibernate.internal.MongoConstants.MONGO_DBMS_NAME;
20-
import static com.mongodb.hibernate.internal.translate.mongoast.command.aggregate.AstSortOrder.ASC;
2120
import static org.assertj.core.api.Assertions.assertThat;
2221
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2322
import static org.hibernate.cfg.QuerySettings.DEFAULT_NULL_ORDERING;
2423

2524
import com.mongodb.hibernate.internal.FeatureNotSupportedException;
26-
import com.mongodb.hibernate.internal.translate.mongoast.command.aggregate.AstSortOrder;
2725
import java.util.Arrays;
2826
import java.util.List;
2927
import org.hibernate.query.NullPrecedence;
@@ -35,7 +33,6 @@
3533
import org.junit.jupiter.api.Nested;
3634
import org.junit.jupiter.api.Test;
3735
import org.junit.jupiter.params.ParameterizedTest;
38-
import org.junit.jupiter.params.provider.EnumSource;
3936
import org.junit.jupiter.params.provider.ValueSource;
4037

4138
@DomainModel(annotatedClasses = Book.class)
@@ -64,25 +61,26 @@ void beforeEach() {
6461
}
6562

6663
@ParameterizedTest
67-
@EnumSource(AstSortOrder.class)
68-
void testOrderBySingleFieldWithoutTies(AstSortOrder sortOrder) {
64+
@ValueSource(strings = {"ASC", "DESC"})
65+
void testOrderBySingleFieldWithoutTies(String sortOrder) {
6966
assertSelectionQuery(
7067
"from Book as b ORDER BY b.publishYear " + sortOrder,
7168
Book.class,
72-
"{ 'aggregate': 'books', 'pipeline': [ { '$sort': { 'publishYear': " + (sortOrder == ASC ? "1" : "-1")
69+
"{ 'aggregate': 'books', 'pipeline': [ { '$sort': { 'publishYear': "
70+
+ (sortOrder.equals("ASC") ? "1" : "-1")
7371
+ " } }, {'$project': {'_id': true, 'discount': true, 'isbn13': true, 'outOfStock': true, 'price': true, 'publishYear': true, 'title': true} } ] }",
74-
sortOrder == ASC ? getBooksByIds(2, 1, 3, 4, 5) : getBooksByIds(5, 4, 3, 1, 2));
72+
sortOrder.equals("ASC") ? getBooksByIds(2, 1, 3, 4, 5) : getBooksByIds(5, 4, 3, 1, 2));
7573
}
7674

7775
@ParameterizedTest
78-
@EnumSource(AstSortOrder.class)
79-
void testOrderBySingleFieldWithTies(AstSortOrder sortOrder) {
76+
@ValueSource(strings = {"ASC", "DESC"})
77+
void testOrderBySingleFieldWithTies(String sortOrder) {
8078
assertSelectionQuery(
8179
"from Book as b ORDER BY b.title " + sortOrder,
8280
Book.class,
83-
"{ 'aggregate': 'books', 'pipeline': [ { '$sort': { 'title': " + (sortOrder == ASC ? "1" : "-1")
81+
"{ 'aggregate': 'books', 'pipeline': [ { '$sort': { 'title': " + (sortOrder.equals("ASC") ? "1" : "-1")
8482
+ " } }, {'$project': {'_id': true, 'discount': true, 'isbn13': true, 'outOfStock': true, 'price': true, 'publishYear': true, 'title': true} } ] }",
85-
sortOrder == ASC
83+
sortOrder.equals("ASC")
8684
? resultList -> assertThat(resultList)
8785
.satisfiesAnyOf(
8886
list -> assertResultListEquals(getBooksByIds(3, 2, 4, 1, 5), list),

0 commit comments

Comments
 (0)