@Test public void testPagination() { Map<String, Object> fileContents = new HashMap<String, Object>(); final int TOTAL_POSTS = 5; final int PER_PAGE = 2; for (int i = 1; i <= TOTAL_POSTS; i++) { fileContents.put("name", "dummyfile" + i); ODocument doc = new ODocument("post"); doc.fields(fileContents); boolean cached = fileContents.get("cached") != null ? Boolean.valueOf((String) fileContents.get("cached")) : true; doc.field("cached", cached); doc.save(); } int iterationCount = 0; int start = 0; db.setLimit(PER_PAGE); while (start < TOTAL_POSTS) { db.setStart(start); List<ODocument> posts = db.getAllContent("post"); Assert.assertEquals( "dummyfile" + (1 + (PER_PAGE * iterationCount)), posts.get(0).field("name")); // Assert.assertEquals("dummyfile" + (PER_PAGE + (PER_PAGE * iterationCount)), // posts.get(posts.size()-1).field("name")); iterationCount++; start += PER_PAGE; } Assert.assertEquals(Math.round(TOTAL_POSTS / (1.0 * PER_PAGE) + 0.4), iterationCount); }