Skip to content

Commit a693d3f

Browse files
Test unwrapped.empty instantiation when used as ctor argument.
Original Pull Request: #4492
1 parent 53760b0 commit a693d3f

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
@@ -2368,6 +2368,21 @@ void readUnwrappedTypeWithComplexValueUsingConstructor() {
23682368
.isEqualTo(expected);
23692369
}
23702370

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

0 commit comments

Comments
 (0)