5656import org .springframework .dao .IncorrectResultSizeDataAccessException ;
5757import org .springframework .dao .InvalidDataAccessApiUsageException ;
5858import org .springframework .data .domain .*;
59+ import org .springframework .data .domain .ExampleMatcher .GenericPropertyMatcher ;
60+ import org .springframework .data .domain .ExampleMatcher .StringMatcher ;
5961import org .springframework .data .domain .Sort .Direction ;
6062import org .springframework .data .domain .Sort .Order ;
6163import org .springframework .data .jpa .domain .Specification ;
@@ -1243,7 +1245,7 @@ void scrollByExampleOffset() {
12431245 matching ().withMatcher ("firstname" , GenericPropertyMatcher ::startsWith ).withIgnorePaths ("age" , "createdAt" ,
12441246 "dateOfBirth" ));
12451247 Window <User > firstWindow = repository .findBy (example ,
1246- q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (OffsetScrollPosition . initial ()));
1248+ q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (ScrollPosition . offset ()));
12471249
12481250 assertThat (firstWindow ).containsExactly (jane1 , jane2 );
12491251 assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1269,7 +1271,7 @@ void scrollByExampleKeyset() {
12691271 matching ().withMatcher ("firstname" , GenericPropertyMatcher ::startsWith ).withIgnorePaths ("age" , "createdAt" ,
12701272 "dateOfBirth" ));
12711273 Window <User > firstWindow = repository .findBy (example ,
1272- q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1274+ q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
12731275
12741276 assertThat (firstWindow ).containsOnly (jane1 );
12751277 assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1295,12 +1297,12 @@ void scrollByExampleKeysetBackward() {
12951297 matching ().withMatcher ("firstname" , GenericPropertyMatcher ::startsWith ).withIgnorePaths ("age" , "createdAt" ,
12961298 "dateOfBirth" ));
12971299 Window <User > firstWindow = repository .findBy (example ,
1298- q -> q .limit (4 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1300+ q -> q .limit (4 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
12991301
13001302 KeysetScrollPosition scrollPosition = (KeysetScrollPosition ) firstWindow .positionAt (2 );
13011303 Window <User > previousWindow = repository .findBy (example ,
13021304 q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" ))
1303- .scroll (KeysetScrollPosition . of (scrollPosition .getKeys (), KeysetScrollPosition . Direction . Backward )));
1305+ .scroll (ScrollPosition . backward (scrollPosition .getKeys ())));
13041306
13051307 assertThat (previousWindow ).containsOnly (jane2 );
13061308 assertThat (previousWindow .hasNext ()).isTrue ();
@@ -1317,7 +1319,7 @@ void scrollByPredicateOffset() {
13171319 repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
13181320
13191321 Window <User > firstWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1320- q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (OffsetScrollPosition . initial ()));
1322+ q -> q .limit (2 ).sortBy (Sort .by ("firstname" )).scroll (ScrollPosition . offset ()));
13211323
13221324 assertThat (firstWindow ).containsExactly (jane1 , jane2 );
13231325 assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1340,7 +1342,7 @@ void scrollByPredicateKeyset() {
13401342 repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
13411343
13421344 Window <User > firstWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1343- q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1345+ q -> q .limit (1 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
13441346
13451347 assertThat (firstWindow ).containsOnly (jane1 );
13461348 assertThat (firstWindow .hasNext ()).isTrue ();
@@ -1363,16 +1365,14 @@ void scrollByPredicateKeysetBackward() {
13631365 repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
13641366
13651367 Window <User > firstWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1366- q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (KeysetScrollPosition . initial ()));
1368+ q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (ScrollPosition . keyset ()));
13671369
13681370 assertThat (firstWindow ).containsExactly (jane1 , jane2 , john1 );
13691371 assertThat (firstWindow .hasNext ()).isTrue ();
13701372
13711373 KeysetScrollPosition scrollPosition = (KeysetScrollPosition ) firstWindow .positionAt (2 );
1372- KeysetScrollPosition backward = KeysetScrollPosition .of (scrollPosition .getKeys (),
1373- KeysetScrollPosition .Direction .Backward );
13741374 Window <User > previousWindow = repository .findBy (QUser .user .firstname .startsWith ("J" ),
1375- q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (backward ));
1375+ q -> q .limit (3 ).sortBy (Sort .by ("firstname" , "emailAddress" )).scroll (scrollPosition . backward () ));
13761376
13771377 assertThat (previousWindow ).containsExactly (jane1 , jane2 );
13781378
@@ -1391,16 +1391,14 @@ void scrollByPartTreeKeysetBackward() {
13911391 repository .saveAllAndFlush (Arrays .asList (john1 , john2 , jane1 , jane2 ));
13921392
13931393 Window <User > firstWindow = repository .findTop3ByFirstnameStartingWithOrderByFirstnameAscEmailAddressAsc ("J" ,
1394- KeysetScrollPosition . initial ());
1394+ ScrollPosition . keyset ());
13951395
13961396 assertThat (firstWindow ).containsExactly (jane1 , jane2 , john1 );
13971397 assertThat (firstWindow .hasNext ()).isTrue ();
13981398
13991399 KeysetScrollPosition scrollPosition = (KeysetScrollPosition ) firstWindow .positionAt (2 );
1400- KeysetScrollPosition backward = KeysetScrollPosition .of (scrollPosition .getKeys (),
1401- KeysetScrollPosition .Direction .Backward );
14021400 Window <User > previousWindow = repository .findTop3ByFirstnameStartingWithOrderByFirstnameAscEmailAddressAsc ("J" ,
1403- backward );
1401+ scrollPosition . backward () );
14041402
14051403 assertThat (previousWindow ).containsExactly (jane1 , jane2 );
14061404
@@ -1914,7 +1912,7 @@ void findByCollectionWithPageRequest() {
19141912
19151913 flushTestUsers ();
19161914
1917- Page <User > userPage = repository .findByAgeIn (List .of (28 , 35 ), ( PageRequest ) PageRequest .of (0 , 2 ));
1915+ Page <User > userPage = repository .findByAgeIn (List .of (28 , 35 ), PageRequest .of (0 , 2 ));
19181916
19191917 assertThat (userPage ).hasSize (2 );
19201918 assertThat (userPage .getTotalElements ()).isEqualTo (2 );
0 commit comments