47
47
import org .springframework .data .neo4j .test .Neo4jExtension ;
48
48
import org .springframework .data .neo4j .test .Neo4jIntegrationTest ;
49
49
import org .springframework .data .querydsl .QuerydslPredicateExecutor ;
50
- import org .springframework .data .repository .query .FluentQuery ;
50
+ import org .springframework .data .repository .query .FluentQuery . FetchableFluentQuery ;
51
51
import org .springframework .transaction .PlatformTransactionManager ;
52
52
import org .springframework .transaction .annotation .EnableTransactionManagement ;
53
53
@@ -97,7 +97,7 @@ protected static void setupData(@Autowired BookmarkCapture bookmarkCapture) {
97
97
void fluentFindOneShouldWork (@ Autowired QueryDSLPersonRepository repository ) {
98
98
99
99
Predicate predicate = Expressions .predicate (Ops .EQ , firstNamePath , Expressions .asString ("Helge" ));
100
- Person person = repository .findBy (predicate , q -> q . oneValue () );
100
+ Person person = repository .findBy (predicate , FetchableFluentQuery :: oneValue );
101
101
102
102
assertThat (person ).isNotNull ();
103
103
assertThat (person ).extracting (Person ::getLastName ).isEqualTo ("Schneider" );
@@ -108,7 +108,7 @@ void fluentFindAllShouldWork(@Autowired QueryDSLPersonRepository repository) {
108
108
109
109
Predicate predicate = Expressions .predicate (Ops .EQ , firstNamePath , Expressions .asString ("Helge" ))
110
110
.or (Expressions .predicate (Ops .EQ , lastNamePath , Expressions .asString ("B." )));
111
- List <Person > people = repository .findBy (predicate , q -> q . all () );
111
+ List <Person > people = repository .findBy (predicate , FetchableFluentQuery :: all );
112
112
113
113
assertThat (people ).extracting (Person ::getFirstName )
114
114
.containsExactlyInAnyOrder ("Bela" , "Helge" );
@@ -170,9 +170,10 @@ void scrollByExampleWithContinuingOffset(@Autowired QueryDSLPersonRepository rep
170
170
Predicate predicate = Expressions .predicate (Ops .EQ , firstNamePath , Expressions .asString ("Helge" ))
171
171
.or (Expressions .predicate (Ops .EQ , lastNamePath , Expressions .asString ("B." )));
172
172
173
- Window <Person > peopleWindow = repository .findBy (predicate , q -> q .limit (1 ).sortBy (Sort .by ("firstName" ).descending ()).scroll (ScrollPosition .offset ()));
173
+ var firstName = Sort .by ("firstName" ).descending ();
174
+ Window <Person > peopleWindow = repository .findBy (predicate , q -> q .limit (1 ).sortBy (firstName ).scroll (ScrollPosition .offset ()));
174
175
ScrollPosition currentPosition = peopleWindow .positionAt (peopleWindow .getContent ().get (0 ));
175
- peopleWindow = repository .findBy (predicate , q -> q .limit (1 ).scroll (currentPosition ));
176
+ peopleWindow = repository .findBy (predicate , q -> q .limit (1 ).sortBy ( firstName ). scroll (currentPosition ));
176
177
177
178
assertThat (peopleWindow .getContent ()).extracting (Person ::getFirstName )
178
179
.containsExactlyInAnyOrder ("Bela" );
@@ -250,7 +251,7 @@ void fluentfindAllAsShouldWork(@Autowired QueryDSLPersonRepository repository) {
250
251
void fluentStreamShouldWork (@ Autowired QueryDSLPersonRepository repository ) {
251
252
252
253
Predicate predicate = Expressions .predicate (Ops .EQ , firstNamePath , Expressions .asString ("Helge" ));
253
- Stream <Person > people = repository .findBy (predicate , FluentQuery . FetchableFluentQuery ::stream );
254
+ Stream <Person > people = repository .findBy (predicate , FetchableFluentQuery ::stream );
254
255
255
256
assertThat (people .map (Person ::getFirstName )).containsExactly ("Helge" );
256
257
}
@@ -323,7 +324,7 @@ void fluentFindAllWithLimitShouldWork(@Autowired QueryDSLPersonRepository reposi
323
324
Predicate predicate = Expressions .predicate (Ops .EQ , firstNamePath , Expressions .asString ("Helge" ))
324
325
.or (Expressions .predicate (Ops .EQ , lastNamePath , Expressions .asString ("B." )));
325
326
List <Person > people = repository .findBy (predicate ,
326
- q -> q .limit (1 )).all ();
327
+ q -> q .limit (1 ). sortBy ( Sort . by ( "firstName" ). descending ()) ).all ();
327
328
328
329
assertThat (people ).hasSize (1 );
329
330
assertThat (people ).extracting (Person ::getFirstName ).containsExactly ("Helge" );
0 commit comments