Search in sources :

Example 1 with CurrentStatus

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);
}
Also used : FindOptions(dev.morphia.query.FindOptions) CurrentStatus(dev.morphia.test.models.CurrentStatus) Test(org.testng.annotations.Test)

Aggregations

FindOptions (dev.morphia.query.FindOptions)1 CurrentStatus (dev.morphia.test.models.CurrentStatus)1 Test (org.testng.annotations.Test)1