Assert.assertTrue(indexInfo.isEmpty() || indexInfo.size() == 1);
// Insert "Max" records successfully
for (int i = 1; i <= max; i++)
{
MongoDBCappedEntity entity = new MongoDBCappedEntity();
entity.setPersonId(i + "");
entity.setPersonName("Person_Name_" + i);
entity.setAge((short) i);
em.persist(entity);
}
// Insert one more record and check whether it replaces first one
MongoDBCappedEntity entity = new MongoDBCappedEntity();
entity.setPersonId((max + 1) + "");
entity.setPersonName("Person_Name_" + (max + 1));
entity.setAge((short) (max + 1));
em.persist(entity);
em.clear();
MongoDBCappedEntity firstRecord = em.find(MongoDBCappedEntity.class, "1");
Assert.assertNull(firstRecord);
MongoDBCappedEntity lastRecord = em.find(MongoDBCappedEntity.class, "" + (max + 1));
Assert.assertNotNull(lastRecord);
// Deleting documents within a capped collection should simply ignore,
// as is done by native API
em.remove(lastRecord);