Package org.jugile.daims

Source Code of org.jugile.daims.BoCollectionTest

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());
   
  }
 
}
TOP

Related Classes of org.jugile.daims.BoCollectionTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.