use of dev.morphia.test.models.methods.MethodMappedSpecializedEntity in project morphia by mongodb.
the class TestGenerics method testMethodMappedGenericEntities.
@Test
public void testMethodMappedGenericEntities() {
Datastore datastore = createDatastore(getMongoClient(), TEST_DB_NAME, MapperOptions.builder().propertyDiscovery(PropertyDiscovery.METHODS).build());
EntityModel entityModel = datastore.getMapper().map(MethodMappedSpecializedEntity.class).get(0);
PropertyModel test = entityModel.getProperty("test");
assertEquals(test.getType(), UUID.class);
MethodMappedSpecializedEntity beforeDB = new MethodMappedSpecializedEntity();
beforeDB.setId(UUID.randomUUID());
beforeDB.setTest(UUID.randomUUID());
datastore.save(beforeDB);
MethodMappedSpecializedEntity loaded = datastore.find(MethodMappedSpecializedEntity.class).filter(eq("_id", beforeDB.getId())).first();
assertEquals(loaded.getId(), beforeDB.getId());
assertEquals(loaded.getTest(), beforeDB.getTest());
}
Aggregations