-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain scroll direction in Keyset position function of the correct item.
Closes #2999
- Loading branch information
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ | |
import org.springframework.data.domain.ExampleMatcher.StringMatcher; | ||
import org.springframework.data.domain.Sort.Direction; | ||
import org.springframework.data.domain.Sort.Order; | ||
import org.springframework.data.domain.ExampleMatcher.*; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import org.springframework.data.jpa.domain.sample.Address; | ||
import org.springframework.data.jpa.domain.sample.QUser; | ||
|
@@ -1308,6 +1309,31 @@ void scrollByExampleKeysetBackward() { | |
assertThat(previousWindow.hasNext()).isTrue(); | ||
} | ||
|
||
@Test // GH-2999 | ||
void scrollInitiallyByExampleKeysetBackward() { | ||
|
||
User jane1 = new User("Jane", "Doe", "[email protected]"); | ||
User jane2 = new User("Jane", "Doe", "[email protected]"); | ||
User john1 = new User("John", "Doe", "[email protected]"); | ||
User john2 = new User("John", "Doe", "[email protected]"); | ||
|
||
repository.saveAllAndFlush(Arrays.asList(john1, john2, jane1, jane2)); | ||
|
||
Example<User> example = Example.of(new User("J", null, null), | ||
matching().withMatcher("firstname", GenericPropertyMatcher::startsWith).withIgnorePaths("age", "createdAt", | ||
"dateOfBirth")); | ||
|
||
Window<User> firstWindow = repository.findBy(example, | ||
q -> q.limit(2).sortBy(Sort.by("firstname", "emailAddress")).scroll(ScrollPosition.keyset().backward())); | ||
|
||
assertThat(firstWindow).containsExactly(john1, john2); | ||
|
||
Window<User> previousWindow = repository.findBy(example, | ||
q -> q.limit(2).sortBy(Sort.by("firstname", "emailAddress")).scroll(firstWindow.positionAt(0))); | ||
|
||
assertThat(previousWindow).containsExactly(jane1, jane2); | ||
} | ||
|
||
@Test // GH-2878 | ||
void scrollByPredicateOffset() { | ||
|
||
|