package org.jugile.daims;
import java.util.List;
import org.jugile.proto2.domain.Domain;
import org.jugile.proto2.domain.Person;
import org.jugile.proto2.domain.PersonCollection;
import org.jugile.util.JugileTestCase;
public class BoCollectionTest extends JugileTestCase {
public void testPaging() {
Domain d = Domain.getDomain();
PersonCollection pc = new PersonCollection();
for (int i = 0; i < 20; i++) {
Person p = d.createPerson();
p.setName("p"+i);
pc.add(p);
}
for (Person p : pc) {
print("p: " + p);
}
pc.reset();
List<Person> res = null;
res = pc.page(0, 5, "id");
assertEquals(true,pc.hasNextPage());
assertEquals(false,pc.hasPrevPage());
res = pc.page(1, 5, "id");
assertEquals(true,pc.hasNextPage());
assertEquals(true,pc.hasPrevPage());
res = pc.page(4, 5, "id");
assertEquals(false,pc.hasNextPage());
assertEquals(true,pc.hasPrevPage());
res = pc.page(10, 5, "id");
assertEquals(false,pc.hasNextPage());
assertEquals(false,pc.hasPrevPage());
res = pc.page(5, 5, "id");
assertEquals(false,pc.hasNextPage());
assertEquals(true,pc.hasPrevPage());
}
}