Skip to content

Commit 5e8cd0a

Browse files
Merge branch 'main' into HIBERNATE-70-new
2 parents 5e4a6fd + 21096b1 commit 5e8cd0a

25 files changed

+843
-208
lines changed

src/integrationTest/java/com/mongodb/hibernate/MongoTestAssertions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21+
import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration;
2122
import org.jspecify.annotations.Nullable;
2223

2324
public final class MongoTestAssertions {
@@ -35,4 +36,19 @@ public static void assertEquals(@Nullable Object expected, @Nullable Object actu
3536
.withStrictTypeChecking()
3637
.isEqualTo(expected);
3738
}
39+
40+
/**
41+
* This method is intended to be a drop-in replacement for
42+
* {@link org.junit.jupiter.api.Assertions#assertIterableEquals(Iterable, Iterable)}. It should work even if
43+
* elements in {@code expected}/{@code actual} do not override {@link Object#equals(Object)}.
44+
*/
45+
@SuppressWarnings("unchecked")
46+
public static <T> void assertIterableEq(Iterable<T> expectedResultList, Iterable<? extends T> actualResultList) {
47+
assertThat((Iterable<T>) actualResultList)
48+
.usingRecursiveFieldByFieldElementComparator(RecursiveComparisonConfiguration.builder()
49+
.withIgnoreAllOverriddenEquals(false)
50+
.withStrictTypeChecking(true)
51+
.build())
52+
.containsExactlyElementsOf(expectedResultList);
53+
}
3854
}

src/integrationTest/java/com/mongodb/hibernate/query/select/AbstractSelectionQueryIntegrationTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.mongodb.hibernate.query.select;
1818

19+
import static com.mongodb.hibernate.MongoTestAssertions.assertIterableEq;
1920
import static org.assertj.core.api.Assertions.assertThat;
2021
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2122

@@ -65,9 +66,12 @@ <T> void assertSelectionQuery(
6566
Consumer<SelectionQuery<T>> queryPostProcessor,
6667
String expectedMql,
6768
List<T> expectedResultList) {
68-
assertSelectionQuery(hql, resultType, queryPostProcessor, expectedMql, resultList -> assertThat(resultList)
69-
.usingRecursiveFieldByFieldElementComparator()
70-
.containsExactlyElementsOf(expectedResultList));
69+
assertSelectionQuery(
70+
hql,
71+
resultType,
72+
queryPostProcessor,
73+
expectedMql,
74+
resultList -> assertIterableEq(expectedResultList, resultList));
7175
}
7276

7377
<T> void assertSelectionQuery(String hql, Class<T> resultType, String expectedMql, List<T> expectedResultList) {

src/integrationTest/java/com/mongodb/hibernate/query/select/Book.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Book {
2727
@Id
2828
int id;
2929

30-
// dummy values are set for currently null value is not supported
30+
// TODO-HIBERNATE-48 dummy values are set for currently null value is not supported
3131
String title = "";
3232
Boolean outOfStock = false;
3333
Integer publishYear = 0;
@@ -43,9 +43,4 @@ class Book {
4343
this.publishYear = publishYear;
4444
this.outOfStock = outOfStock;
4545
}
46-
47-
@Override
48-
public String toString() {
49-
return "Book{" + "id=" + id + '}';
50-
}
5146
}

0 commit comments

Comments
 (0)