Search in sources :

Example 1 with NestedType

use of org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.NestedType in project spring-data-mongodb by spring-projects.

the class MappingMongoConverterUnitTests method writesProjectingTypeCorrectly.

// DATAMONGO-766
@Test
void writesProjectingTypeCorrectly() {
    NestedType nested = new NestedType();
    nested.c = "C";
    ProjectingType type = new ProjectingType();
    type.name = "name";
    type.foo = "bar";
    type.a = nested;
    org.bson.Document result = new org.bson.Document();
    converter.write(type, result);
    assertThat(result.get("name")).isEqualTo((Object) "name");
    org.bson.Document aValue = DocumentTestUtils.getAsDocument(result, "a");
    assertThat(aValue.get("b")).isEqualTo((Object) "bar");
    assertThat(aValue.get("c")).isEqualTo((Object) "C");
}
Also used : ProjectingType(org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.ProjectingType) Document(org.springframework.data.mongodb.core.mapping.Document) NestedType(org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.NestedType) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 NestedType (org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.NestedType)1 ProjectingType (org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.ProjectingType)1 Document (org.springframework.data.mongodb.core.mapping.Document)1