Skip to content

Commit 68762fd

Browse files
refactor: Stablize test.
Sorting is probably a good idea when testing the result on a specific order.
1 parent 0bae3c7 commit 68762fd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/test/java/org/springframework/data/neo4j/integration/imperative/QuerydslNeo4jPredicateExecutorIT.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import org.springframework.data.neo4j.test.Neo4jExtension;
4848
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
4949
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
50-
import org.springframework.data.repository.query.FluentQuery;
50+
import org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery;
5151
import org.springframework.transaction.PlatformTransactionManager;
5252
import org.springframework.transaction.annotation.EnableTransactionManagement;
5353

@@ -97,7 +97,7 @@ protected static void setupData(@Autowired BookmarkCapture bookmarkCapture) {
9797
void fluentFindOneShouldWork(@Autowired QueryDSLPersonRepository repository) {
9898

9999
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);
101101

102102
assertThat(person).isNotNull();
103103
assertThat(person).extracting(Person::getLastName).isEqualTo("Schneider");
@@ -108,7 +108,7 @@ void fluentFindAllShouldWork(@Autowired QueryDSLPersonRepository repository) {
108108

109109
Predicate predicate = Expressions.predicate(Ops.EQ, firstNamePath, Expressions.asString("Helge"))
110110
.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);
112112

113113
assertThat(people).extracting(Person::getFirstName)
114114
.containsExactlyInAnyOrder("Bela", "Helge");
@@ -170,9 +170,10 @@ void scrollByExampleWithContinuingOffset(@Autowired QueryDSLPersonRepository rep
170170
Predicate predicate = Expressions.predicate(Ops.EQ, firstNamePath, Expressions.asString("Helge"))
171171
.or(Expressions.predicate(Ops.EQ, lastNamePath, Expressions.asString("B.")));
172172

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()));
174175
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));
176177

177178
assertThat(peopleWindow.getContent()).extracting(Person::getFirstName)
178179
.containsExactlyInAnyOrder("Bela");
@@ -250,7 +251,7 @@ void fluentfindAllAsShouldWork(@Autowired QueryDSLPersonRepository repository) {
250251
void fluentStreamShouldWork(@Autowired QueryDSLPersonRepository repository) {
251252

252253
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);
254255

255256
assertThat(people.map(Person::getFirstName)).containsExactly("Helge");
256257
}
@@ -323,7 +324,7 @@ void fluentFindAllWithLimitShouldWork(@Autowired QueryDSLPersonRepository reposi
323324
Predicate predicate = Expressions.predicate(Ops.EQ, firstNamePath, Expressions.asString("Helge"))
324325
.or(Expressions.predicate(Ops.EQ, lastNamePath, Expressions.asString("B.")));
325326
List<Person> people = repository.findBy(predicate,
326-
q -> q.limit(1)).all();
327+
q -> q.limit(1).sortBy(Sort.by("firstName").descending())).all();
327328

328329
assertThat(people).hasSize(1);
329330
assertThat(people).extracting(Person::getFirstName).containsExactly("Helge");

0 commit comments

Comments
 (0)