Search in sources :

Example 1 with SpecializedEntity

use of dev.morphia.test.models.SpecializedEntity in project morphia by mongodb.

the class TestGenerics method testGenericEntities.

@Test
public void testGenericEntities() {
    EntityModel entityModel = getMapper().map(SpecializedEntity.class).get(0);
    PropertyModel test = entityModel.getProperty("test");
    assertEquals(test.getType(), UUID.class);
    SpecializedEntity beforeDB = new SpecializedEntity();
    beforeDB.setId(UUID.randomUUID());
    beforeDB.setTest(UUID.randomUUID());
    getDs().save(beforeDB);
    SpecializedEntity loaded = getDs().find(SpecializedEntity.class).filter(eq("_id", beforeDB.getId())).first();
    assertEquals(loaded.getId(), beforeDB.getId());
    assertEquals(loaded.getTest(), beforeDB.getTest());
}
Also used : EntityModel(dev.morphia.mapping.codec.pojo.EntityModel) PropertyModel(dev.morphia.mapping.codec.pojo.PropertyModel) MethodMappedSpecializedEntity(dev.morphia.test.models.methods.MethodMappedSpecializedEntity) SpecializedEntity(dev.morphia.test.models.SpecializedEntity) Test(org.testng.annotations.Test)

Aggregations

EntityModel (dev.morphia.mapping.codec.pojo.EntityModel)1 PropertyModel (dev.morphia.mapping.codec.pojo.PropertyModel)1 SpecializedEntity (dev.morphia.test.models.SpecializedEntity)1 MethodMappedSpecializedEntity (dev.morphia.test.models.methods.MethodMappedSpecializedEntity)1 Test (org.testng.annotations.Test)1