|
57 | 57 | import org.springframework.data.domain.*;
|
58 | 58 | import org.springframework.data.domain.Sort.Direction;
|
59 | 59 | import org.springframework.data.domain.Sort.Order;
|
| 60 | +import org.springframework.data.domain.ExampleMatcher.*; |
60 | 61 | import org.springframework.data.jpa.domain.Specification;
|
61 | 62 | import org.springframework.data.jpa.domain.sample.Address;
|
62 | 63 | import org.springframework.data.jpa.domain.sample.QUser;
|
@@ -1304,6 +1305,31 @@ void scrollByExampleKeysetBackward() {
|
1304 | 1305 | assertThat(previousWindow.hasNext()).isTrue();
|
1305 | 1306 | }
|
1306 | 1307 |
|
| 1308 | + @Test // GH-2999 |
| 1309 | + void scrollInitiallyByExampleKeysetBackward() { |
| 1310 | + |
| 1311 | + User jane1 = new User( "Jane", "Doe", "[email protected]"); |
| 1312 | + User jane2 = new User( "Jane", "Doe", "[email protected]"); |
| 1313 | + User john1 = new User( "John", "Doe", "[email protected]"); |
| 1314 | + User john2 = new User( "John", "Doe", "[email protected]"); |
| 1315 | + |
| 1316 | + repository.saveAllAndFlush(Arrays.asList(john1, john2, jane1, jane2)); |
| 1317 | + |
| 1318 | + Example<User> example = Example.of(new User("J", null, null), |
| 1319 | + matching().withMatcher("firstname", GenericPropertyMatcher::startsWith).withIgnorePaths("age", "createdAt", |
| 1320 | + "dateOfBirth")); |
| 1321 | + |
| 1322 | + Window<User> firstWindow = repository.findBy(example, |
| 1323 | + q -> q.limit(2).sortBy(Sort.by("firstname", "emailAddress")).scroll(ScrollPosition.keyset().backward())); |
| 1324 | + |
| 1325 | + assertThat(firstWindow).containsExactly(john1, john2); |
| 1326 | + |
| 1327 | + Window<User> previousWindow = repository.findBy(example, |
| 1328 | + q -> q.limit(2).sortBy(Sort.by("firstname", "emailAddress")).scroll(firstWindow.positionAt(0))); |
| 1329 | + |
| 1330 | + assertThat(previousWindow).containsExactly(jane1, jane2); |
| 1331 | + } |
| 1332 | + |
1307 | 1333 | @Test // GH-2878
|
1308 | 1334 | void scrollByPredicateOffset() {
|
1309 | 1335 |
|
|
0 commit comments