Search in sources :

Example 1 with Morphia.createDatastore

use of dev.morphia.Morphia.createDatastore in project morphia by mongodb.

the class TestVersioning method testCanMapAnEntityWithAnAbstractVersionedParent.

@Test
public void testCanMapAnEntityWithAnAbstractVersionedParent() {
    Datastore datastore = Morphia.createDatastore(getMongoClient(), TEST_DB_NAME);
    Mapper mapper = datastore.getMapper();
    mapper.map(VersionedChildEntity.class);
    List<EntityModel> mappedEntities = mapper.getMappedEntities();
    assertEquals(mappedEntities.size(), 2, mappedEntities.toString());
    List<Class<?>> list = new ArrayList<>();
    for (EntityModel entityModel : mappedEntities) {
        list.add(entityModel.getType());
    }
    assertTrue(list.contains(VersionedChildEntity.class));
    assertTrue(list.contains(AbstractVersionedBase.class));
}
Also used : Mapper(dev.morphia.mapping.Mapper) VersionedChildEntity(dev.morphia.test.models.versioned.VersionedChildEntity) Datastore(dev.morphia.Datastore) Morphia.createDatastore(dev.morphia.Morphia.createDatastore) EntityModel(dev.morphia.mapping.codec.pojo.EntityModel) ArrayList(java.util.ArrayList) AbstractVersionedBase(dev.morphia.test.models.versioned.AbstractVersionedBase) Test(org.testng.annotations.Test)

Aggregations

Datastore (dev.morphia.Datastore)1 Morphia.createDatastore (dev.morphia.Morphia.createDatastore)1 Mapper (dev.morphia.mapping.Mapper)1 EntityModel (dev.morphia.mapping.codec.pojo.EntityModel)1 AbstractVersionedBase (dev.morphia.test.models.versioned.AbstractVersionedBase)1 VersionedChildEntity (dev.morphia.test.models.versioned.VersionedChildEntity)1 ArrayList (java.util.ArrayList)1 Test (org.testng.annotations.Test)1