use of dev.morphia.mapping.codec.pojo.PropertyModel 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());
}
use of dev.morphia.mapping.codec.pojo.PropertyModel in project morphia by mongodb.
the class TestVersioning method testVersionFieldNameContribution.
@Test
public void testVersionFieldNameContribution() {
final PropertyModel mappedFieldByJavaField = getMapper().getEntityModel(NamedVersion.class).getProperty("v");
assertEquals(mappedFieldByJavaField.getMappedName(), "v");
}
Aggregations