Test unwrapped.empty instantiation when used as ctor argument.

Original Pull Request: #4492
This commit is contained in:
Christoph Strobl
2023-09-11 12:14:52 +02:00
parent 53760b07bc
commit a693d3fde9

View File

@@ -2368,6 +2368,21 @@ class MappingMongoConverterUnitTests {
.isEqualTo(expected);
}
@Test // GH-4491
void readUnwrappedTypeWithComplexValueUsingConstructorWhenUnwrappedPropertiesNotPresent() {
org.bson.Document source = new org.bson.Document("_id", "id-1");
WithUnwrappedConstructor target = converter.read(WithUnwrappedConstructor.class, source);
assertThat(target.id).isEqualTo("id-1");
assertThat(target.embeddableValue).isNotNull(); // it's defined as Empty
assertThat(target.embeddableValue.stringValue) //
.isNull();
assertThat(target.embeddableValue.address) //
.isNull();
}
@Test // DATAMONGO-1902
void writeUnwrappedTypeWithComplexValue() {