PageList implements Serializable { public int getPageCount(){ int lim = limit; if(limit < 1){ lim = 1; } int page = total / lim; if (page < 1){ return 1; } int remain = total % lim; if(remain > 0){ page += 1; } return page; } PageList();  PageList(int start, int limit, int total, List<T> list); int getStart(); void setStart(int start); int getLimit(); void setLimit(int limit); int getTotal(); void setTotal(int total); List<T> getList(); void setList(List<T> list); int getPageCount();  }
@Test public void testGetPageCount(){ PageList<Object> pl = new PageList<Object>(0, 100, 52, null); Assert.assertEquals(1, pl.getPageCount()); pl = new PageList<Object>(0, -100, -3, null); Assert.assertEquals(1, pl.getPageCount()); pl = new PageList<Object>(0, 30, 100, null); Assert.assertEquals(4, pl.getPageCount()); }