use of org.bson.codecs.pojo.entities.SimpleNestedPojoModel in project mongo-java-driver by mongodb.
the class PojoCustomTest method testCanHandleNullValuesForNestedModels.
@Test
@SuppressWarnings("unchecked")
public void testCanHandleNullValuesForNestedModels() {
SimpleNestedPojoModel model = getSimpleNestedPojoModel();
model.setSimple(null);
ClassModelBuilder<SimpleNestedPojoModel> classModel = ClassModel.builder(SimpleNestedPojoModel.class);
((PropertyModelBuilder<SimpleModel>) classModel.getProperty("simple")).propertySerialization(new PropertySerialization<SimpleModel>() {
@Override
public boolean shouldSerialize(final SimpleModel value) {
return true;
}
});
ClassModelBuilder<SimpleModel> classModelSimple = ClassModel.builder(SimpleModel.class);
roundTrip(getPojoCodecProviderBuilder(classModel, classModelSimple), model, "{'simple': null}");
}
Aggregations