use of dev.morphia.test.models.CurrentStatus in project morphia by mongodb.
the class TestDatastore method testCappedEntity.
@Test
public void testCappedEntity() {
// given
getMapper().map(CurrentStatus.class);
getDs().ensureCaps();
assertCapped(CurrentStatus.class, 1, 1048576);
// when-then
Query<CurrentStatus> query = getDs().find(CurrentStatus.class);
getDs().save(new CurrentStatus("All Good"));
assertEquals(query.count(), 1);
getDs().save(new CurrentStatus("Kinda Bad"));
assertEquals(query.count(), 1);
assertTrue(query.iterator(new FindOptions().limit(1)).next().message.contains("Bad"));
getDs().save(new CurrentStatus("Kinda Bad2"));
assertEquals(query.count(), 1);
getDs().save(new CurrentStatus("Kinda Bad3"));
assertEquals(query.count(), 1);
getDs().save(new CurrentStatus("Kinda Bad4"));
assertEquals(query.count(), 1);
}
Aggregations