use of org.mongodb.morphia.entities.IndexOnValue in project morphia by mongodb.
the class TestIndexed method testIndexedEntity.
@Test
public void testIndexedEntity() throws Exception {
getDs().ensureIndexes();
assertThat(getDs().getCollection(IndexOnValue.class).getIndexInfo(), hasIndexNamed("value_1"));
getDs().save(new IndexOnValue());
getDs().ensureIndexes();
assertThat(getDs().getCollection(IndexOnValue.class).getIndexInfo(), hasIndexNamed("value_1"));
}
use of org.mongodb.morphia.entities.IndexOnValue in project morphia by mongodb.
the class TestIndexed method shouldNotCreateAnIndexWhenAnIndexedEntityIsMarkedAsNotSaved.
@Test
public void shouldNotCreateAnIndexWhenAnIndexedEntityIsMarkedAsNotSaved() {
// given
getMorphia().map(IndexOnValue.class, NoIndexes.class);
Datastore ds = getDs();
// when
ds.ensureIndexes();
ds.save(new IndexOnValue());
ds.save(new NoIndexes());
// then
List<DBObject> indexes = getDb().getCollection("NoIndexes").getIndexInfo();
assertEquals(1, indexes.size());
}
Aggregations