Skip to content

Commit

Permalink
Merge pull request #186 from jakartaee/fix-flaky-tests
Browse files Browse the repository at this point in the history
Fixed TCK tests
  • Loading branch information
dearrudam authored Dec 28, 2024
2 parents 4a363d2 + 31b7eca commit cd94b28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions tck/src/main/java/jakarta/nosql/tck/QueryMapperTemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void shouldInsertIterableAndSelectWithGreaterThanCondition(List<Person> entities

var secondElder = entities.stream()
.mapToInt(Person::getAge)
.sorted()
.skip(1)
.findFirst()
.orElseThrow();
Expand All @@ -101,10 +102,11 @@ void shouldInsertIterableAndSelectWithLessThanCondition(List<Person> entities) {
try {

var secondElder = entities.stream()
.mapToInt(Person::getAge)
.skip(1)
.findFirst()
.orElseThrow();
.mapToInt(Person::getAge)
.sorted()
.skip(1)
.findFirst()
.orElseThrow();

var result = template.select(Person.class)
.where("age")
Expand Down Expand Up @@ -192,6 +194,7 @@ void shouldInsertIterableAndSelectWithSkipAndLimitCondition(List<Person> entitie

var secondElder = entities.stream()
.mapToInt(Person::getAge)
.sorted()
.skip(1)
.findFirst()
.orElseThrow();
Expand Down Expand Up @@ -221,6 +224,7 @@ void shouldInsertIterableAndSelectWithOrderByCondition(List<Person> entities) {

var secondElder = entities.stream()
.mapToInt(Person::getAge)
.sorted()
.skip(1)
.findFirst()
.orElseThrow();
Expand Down Expand Up @@ -253,7 +257,8 @@ void shouldInsertIterableAndSelectWithComplexQuery(List<Person> entities) {

var secondElder = entities.stream()
.mapToInt(Person::getAge)
.skip(1)
.sorted()
.skip(entities.size() - 1)
.findFirst()
.orElseThrow();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void shouldSelectWithGreaterThanCondition(List<Animal> animals) {

var secondElder = animals.stream()
.mapToInt(Animal::getAge)
.sorted()
.skip(1)
.findFirst()
.orElseThrow();
Expand All @@ -86,12 +87,13 @@ void shouldSelectWithLessThanCondition(List<Animal> animals) {

var secondElder = animals.stream()
.mapToInt(Animal::getAge)
.sorted()
.skip(1)
.findFirst()
.orElseThrow();

var result = template.select(Animal.class)
.where("species")
.where("age")
.lt(secondElder)
.<Animal>result();

Expand Down Expand Up @@ -180,7 +182,7 @@ void shouldSelectWithSkipAndLimitCondition(List<Animal> animals) {

SoftAssertions.assertSoftly(soft -> {
soft.assertThat(result).isNotEmpty();
soft.assertThat(result).allMatch(animal -> animal.getAge() > animals.get(0).getAge());
soft.assertThat(result).allMatch(animal -> animal.getAge() > secondOlder);
});
}
}

0 comments on commit cd94b28

Please sign in to comment.