use of org.mongodb.morphia.entities.EntityWithListsAndArrays in project morphia by mongodb.
the class CustomConvertersTest method customerIteratorConverter.
@Test
public void customerIteratorConverter() {
getMorphia().getMapper().getConverters().addConverter(ListToMapConvert.class);
getMorphia().getMapper().getOptions().setStoreEmpties(false);
getMorphia().getMapper().getOptions().setStoreNulls(false);
getMorphia().map(EntityWithListsAndArrays.class);
final EntityWithListsAndArrays entity = new EntityWithListsAndArrays();
entity.setListOfStrings(Arrays.asList("string 1", "string 2", "string 3"));
getDs().save(entity);
final DBObject dbObject = getDs().getCollection(EntityWithListsAndArrays.class).findOne();
Assert.assertFalse(dbObject.get("listOfStrings") instanceof BasicDBList);
final EntityWithListsAndArrays loaded = getDs().find(EntityWithListsAndArrays.class).get();
Assert.assertEquals(entity.getListOfStrings(), loaded.getListOfStrings());
}
Aggregations