Skip to content

Commit 11b992c

Browse files
Test unwrapped.empty instantiation when used as ctor argument.
Original Pull Request: #4492
1 parent 9429cfd commit 11b992c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java

+15
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,21 @@ void readUnwrappedTypeWithComplexValueUsingConstructor() {
23642364
.isEqualTo(expected);
23652365
}
23662366

2367+
@Test // GH-4491
2368+
void readUnwrappedTypeWithComplexValueUsingConstructorWhenUnwrappedPropertiesNotPresent() {
2369+
2370+
org.bson.Document source = new org.bson.Document("_id", "id-1");
2371+
2372+
WithUnwrappedConstructor target = converter.read(WithUnwrappedConstructor.class, source);
2373+
2374+
assertThat(target.id).isEqualTo("id-1");
2375+
assertThat(target.embeddableValue).isNotNull(); // it's defined as Empty
2376+
assertThat(target.embeddableValue.stringValue) //
2377+
.isNull();
2378+
assertThat(target.embeddableValue.address) //
2379+
.isNull();
2380+
}
2381+
23672382
@Test // DATAMONGO-1902
23682383
void writeUnwrappedTypeWithComplexValue() {
23692384

0 commit comments

Comments
 (0)