@Test
public void getBatchTest() {
running(fakeApplication(inMemoryDatabase()), new Runnable() {
public void run() {
ContactDao dao = DaoManager.getContactDao();
for (int i = 0; i < 18; i++) {
Contact c = new Contact();
c.setFirstName("Contact" + i);
c.setLastName("Jones" + i);
try {
dao.persist(c);
} catch (DataAccessException e) {
e.printStackTrace();
}
}
List<Contact> batch1 = null;
List<Contact> batch2 = null;
List<Contact> batch3 = null;
try {
batch1 = dao.getBatch(0, 10);
batch2 = dao.getBatch(1, 10);
batch3 = dao.getBatch(4, 10);
} catch (DataAccessException e) {
e.printStackTrace();
}
assertTrue(batch1.size() == 10);
assertTrue(batch2.size() == 8);