|
1 | 1 | package io.weaviate.integration; |
2 | 2 |
|
3 | 3 | import java.io.IOException; |
| 4 | +import java.time.OffsetDateTime; |
| 5 | +import java.util.List; |
4 | 6 | import java.util.Map; |
| 7 | +import java.util.UUID; |
5 | 8 |
|
6 | 9 | import org.assertj.core.api.Assertions; |
7 | 10 | import org.assertj.core.api.InstanceOfAssertFactories; |
@@ -407,4 +410,61 @@ public void testDuplicateUuid() throws IOException { |
407 | 410 | // Act |
408 | 411 | things.data.insert(Map.of(), thing -> thing.uuid(thing_1.uuid())); |
409 | 412 | } |
| 413 | + |
| 414 | + @Test |
| 415 | + public void testDataTypes() throws IOException { |
| 416 | + // Arrange |
| 417 | + var nsDataTypes = ns("DataTypes"); |
| 418 | + |
| 419 | + // BLOB type is omitted because a base64-encoded image |
| 420 | + // isn't doing the failure message any favours. |
| 421 | + // It's tested in other test cases above. |
| 422 | + client.collections.create( |
| 423 | + nsDataTypes, c -> c |
| 424 | + .properties( |
| 425 | + Property.text("prop_text"), |
| 426 | + Property.integer("prop_integer"), |
| 427 | + Property.number("prop_number"), |
| 428 | + Property.bool("prop_bool"), |
| 429 | + Property.date("prop_date"), |
| 430 | + Property.uuid("prop_uuid"), |
| 431 | + Property.integerArray("prop_integer_array"), |
| 432 | + Property.numberArray("prop_number_array"), |
| 433 | + Property.boolArray("prop_bool_array"), |
| 434 | + Property.dateArray("prop_date_array"), |
| 435 | + Property.uuidArray("prop_uuid_array"), |
| 436 | + Property.textArray("prop_text_array"))); |
| 437 | + |
| 438 | + var types = client.collections.use(nsDataTypes); |
| 439 | + |
| 440 | + var now = OffsetDateTime.now(); |
| 441 | + var uuid = UUID.randomUUID(); |
| 442 | + |
| 443 | + Map<String, Object> want = Map.ofEntries( |
| 444 | + Map.entry("prop_text", "Hello, World!"), |
| 445 | + Map.entry("prop_integer", 1L), |
| 446 | + Map.entry("prop_number", 1D), |
| 447 | + Map.entry("prop_bool", true), |
| 448 | + Map.entry("prop_date", now), |
| 449 | + Map.entry("prop_uuid", uuid), |
| 450 | + Map.entry("prop_integer_array", List.of(1L, 2L, 3L)), |
| 451 | + Map.entry("prop_number_array", List.of(1D, 2D, 3D)), |
| 452 | + Map.entry("prop_bool_array", List.of(true, false)), |
| 453 | + Map.entry("prop_date_array", List.of(now, now)), |
| 454 | + Map.entry("prop_uuid_array", List.of(uuid, uuid)), |
| 455 | + Map.entry("prop_text_array", List.of("a", "b", "c"))); |
| 456 | + var returnProperties = want.keySet().toArray(String[]::new); |
| 457 | + |
| 458 | + // Act |
| 459 | + var object = types.data.insert(want); |
| 460 | + var got = types.query.byId(object.uuid(), |
| 461 | + q -> q.returnProperties(returnProperties)); |
| 462 | + |
| 463 | + // Assert |
| 464 | + Assertions.assertThat(got).get() |
| 465 | + .extracting(WeaviateObject::properties) |
| 466 | + .asInstanceOf(InstanceOfAssertFactories.map(String.class, Object.class)) |
| 467 | + .containsAllEntriesOf(want); |
| 468 | + |
| 469 | + } |
410 | 470 | } |
0 commit comments