use of org.bson.codecs.pojo.entities.SimpleModel in project mongo-java-driver by mongodb.
the class PojoCustomTest method testDataCanHandleMissingData.
@Test
public void testDataCanHandleMissingData() {
SimpleModel model = getSimpleModel();
model.setIntegerField(null);
decodesTo(getCodec(SimpleModel.class), "{'_t': 'SimpleModel', 'stringField': 'myString'}", model);
}
use of org.bson.codecs.pojo.entities.SimpleModel in project mongo-java-driver by mongodb.
the class PojoTestCase method getNestedGenericHolderSimpleGenericsModel.
static NestedGenericHolderSimpleGenericsModel getNestedGenericHolderSimpleGenericsModel() {
SimpleModel simpleModel = getSimpleModel();
Map<String, SimpleModel> map = new HashMap<String, SimpleModel>();
map.put("A", simpleModel);
Map<String, Map<String, SimpleModel>> mapB = new HashMap<String, Map<String, SimpleModel>>();
mapB.put("A", map);
SimpleGenericsModel<Integer, List<SimpleModel>, Map<String, SimpleModel>> simpleGenericsModel = new SimpleGenericsModel<Integer, List<SimpleModel>, Map<String, SimpleModel>>(42, 42, singletonList(singletonList(simpleModel)), mapB);
GenericHolderModel<SimpleGenericsModel<Integer, List<SimpleModel>, Map<String, SimpleModel>>> nested = new GenericHolderModel<SimpleGenericsModel<Integer, List<SimpleModel>, Map<String, SimpleModel>>>(simpleGenericsModel, 42L);
return new NestedGenericHolderSimpleGenericsModel(nested);
}
use of org.bson.codecs.pojo.entities.SimpleModel in project mongo-java-driver by mongodb.
the class PojoTestCase method getConventionModel.
static ConventionModel getConventionModel() {
SimpleModel simpleModel = getSimpleModel();
ConventionModel child = new ConventionModel("child", null, simpleModel);
return new ConventionModel("id", child, null);
}
use of org.bson.codecs.pojo.entities.SimpleModel in project mongo-java-driver by mongodb.
the class PojoTestCase method getCollectionNestedPojoModel.
private static CollectionNestedPojoModel getCollectionNestedPojoModel(final boolean useNulls) {
List<SimpleModel> listSimple;
Set<SimpleModel> setSimple;
Map<String, SimpleModel> mapSimple;
if (useNulls) {
listSimple = null;
setSimple = null;
mapSimple = null;
} else {
SimpleModel simpleModel = getSimpleModel();
listSimple = singletonList(simpleModel);
setSimple = new HashSet<SimpleModel>(listSimple);
mapSimple = new HashMap<String, SimpleModel>();
mapSimple.put("s", simpleModel);
}
List<List<SimpleModel>> listListSimple = singletonList(listSimple);
Set<Set<SimpleModel>> setSetSimple = new HashSet<Set<SimpleModel>>(singletonList(setSimple));
Map<String, Map<String, SimpleModel>> mapMapSimple = new HashMap<String, Map<String, SimpleModel>>();
mapMapSimple.put("ms", mapSimple);
Map<String, List<SimpleModel>> mapListSimple = new HashMap<String, List<SimpleModel>>();
mapListSimple.put("ls", listSimple);
Map<String, List<Map<String, SimpleModel>>> mapListMapSimple = new HashMap<String, List<Map<String, SimpleModel>>>();
mapListMapSimple.put("lm", singletonList(mapSimple));
Map<String, Set<SimpleModel>> mapSetSimple = new HashMap<String, Set<SimpleModel>>();
mapSetSimple.put("s", setSimple);
List<Map<String, SimpleModel>> listMapSimple = singletonList(mapSimple);
List<Map<String, List<SimpleModel>>> listMapListSimple = singletonList(mapListSimple);
List<Map<String, Set<SimpleModel>>> listMapSetSimple = singletonList(mapSetSimple);
return new CollectionNestedPojoModel(listSimple, listListSimple, setSimple, setSetSimple, mapSimple, mapMapSimple, mapListSimple, mapListMapSimple, mapSetSimple, listMapSimple, listMapListSimple, listMapSetSimple);
}
Aggregations