|
37 | 37 | import org.mockito.junit.jupiter.MockitoSettings;
|
38 | 38 | import org.mockito.quality.Strictness;
|
39 | 39 | import org.springframework.data.domain.Limit;
|
| 40 | +import org.springframework.data.domain.OffsetScrollPosition; |
40 | 41 | import org.springframework.data.domain.Page;
|
41 | 42 | import org.springframework.data.domain.PageRequest;
|
42 | 43 | import org.springframework.data.domain.Pageable;
|
| 44 | +import org.springframework.data.domain.ScrollPosition; |
43 | 45 | import org.springframework.data.domain.Slice;
|
44 | 46 | import org.springframework.data.domain.Sort;
|
45 | 47 | import org.springframework.data.domain.Sort.Direction;
|
| 48 | +import org.springframework.data.domain.Window; |
46 | 49 | import org.springframework.data.mongodb.MongoDatabaseFactory;
|
47 | 50 | import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
48 | 51 | import org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery;
|
@@ -329,6 +332,20 @@ void usesAnnotatedSortWhenPresent() {
|
329 | 332 | assertThat(captor.getValue().getSortObject()).isEqualTo(new Document("age", 1));
|
330 | 333 | }
|
331 | 334 |
|
| 335 | + @Test // GH-4758 |
| 336 | + void scrollUsesAnnotatedSortWhenPresent() { |
| 337 | + |
| 338 | + createQueryForMethod("scrollByAge", Integer.class, ScrollPosition.class) // |
| 339 | + .execute(new Object[] { 1000, ScrollPosition.keyset()}); |
| 340 | + |
| 341 | + ArgumentCaptor<Query> captor = ArgumentCaptor.forClass(Query.class); |
| 342 | + verify(withQueryMock).matching(captor.capture()); |
| 343 | + |
| 344 | + Query query = captor.getValue(); |
| 345 | + assertThat(query.getSortObject()).isEqualTo(new Document("age", 1)); |
| 346 | + assertThat(query.isSorted()).isTrue(); |
| 347 | + } |
| 348 | + |
332 | 349 | @Test // DATAMONGO-1979
|
333 | 350 | void usesExplicitSortOverridesAnnotatedSortWhenPresent() {
|
334 | 351 |
|
@@ -637,6 +654,9 @@ private interface Repo extends MongoRepository<Person, Long> {
|
637 | 654 | @org.springframework.data.mongodb.repository.Query(sort = "{ age : 1 }")
|
638 | 655 | List<Person> findByAge(Integer age);
|
639 | 656 |
|
| 657 | + @org.springframework.data.mongodb.repository.Query(sort = "{ age : 1 }") |
| 658 | + Window<Person> scrollByAge(Integer age, ScrollPosition position); |
| 659 | + |
640 | 660 | @org.springframework.data.mongodb.repository.Query(sort = "{ age : 1 }")
|
641 | 661 | List<Person> findByAge(Integer age, Sort page);
|
642 | 662 |
|
@@ -670,6 +690,7 @@ private interface Repo extends MongoRepository<Person, Long> {
|
670 | 690 |
|
671 | 691 | @ReadPreference(value = "secondaryPreferred")
|
672 | 692 | List<Person> findWithReadPreferenceByFirstname(String firstname);
|
| 693 | + |
673 | 694 | }
|
674 | 695 |
|
675 | 696 | // DATAMONGO-1872
|
|
0 commit comments