|
7 | 7 |
|
8 | 8 | import org.assertj.core.api.Assertions; |
9 | 9 | import org.assertj.core.api.InstanceOfAssertFactories; |
| 10 | +import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; |
10 | 11 | import org.junit.BeforeClass; |
11 | 12 | import org.junit.Test; |
12 | 13 |
|
@@ -149,13 +150,20 @@ public void test_createCollection() throws Exception { |
149 | 150 | Map.entry("booleanBoxedList", "boolean[]")); |
150 | 151 | } |
151 | 152 |
|
| 153 | + private final RecursiveComparisonConfiguration COMPARISON_CONFIG = RecursiveComparisonConfiguration.builder() |
| 154 | + // Assertj is having a really bad time comparing List<Float>, |
| 155 | + // so we'll just always return true here. |
| 156 | + .withComparatorForFields((a, b) -> 0, "floatBoxedList") |
| 157 | + .withComparatorForType((a, b) -> Double.compare(a.doubleValue(), b.doubleValue()), Number.class) |
| 158 | + .build(); |
| 159 | + |
152 | 160 | @Test |
153 | 161 | public void test_insertAndQuery() throws Exception { |
154 | 162 | short short_ = 666; |
155 | 163 | int int_ = 666; |
156 | | - long long_ = 666L; |
157 | | - float float_ = 666f; |
158 | | - double double_ = 666d; |
| 164 | + long long_ = 666; |
| 165 | + float float_ = 666; |
| 166 | + double double_ = 666; |
159 | 167 | boolean boolean_ = true; |
160 | 168 | UUID uuid = UUID.randomUUID(); |
161 | 169 | OffsetDateTime date = OffsetDateTime.now(); |
@@ -216,12 +224,12 @@ public void test_insertAndQuery() throws Exception { |
216 | 224 | var inserted = things.data.insert(thing); |
217 | 225 |
|
218 | 226 | // Assert |
219 | | - var got = things.query.byId(inserted.uuid()); |
220 | | - Assertions.assertThat(got).get() |
221 | | - .extracting(WeaviateObject::properties, InstanceOfAssertFactories.type(Thing.class)); |
| 227 | + var optional = things.query.byId(inserted.uuid()); |
| 228 | + var got = Assertions.assertThat(optional).get() |
| 229 | + .extracting(WeaviateObject::properties).actual(); |
222 | 230 |
|
223 | | - // TODO: add assertions; |
| 231 | + Assertions.assertThat(got) |
| 232 | + .usingRecursiveComparison(COMPARISON_CONFIG) |
| 233 | + .isEqualTo(thing); |
224 | 234 | } |
225 | | - |
226 | | - // TODO: insertMany (batch) |
227 | 235 | } |
0 commit comments