PageInfo { void setPage(int page) { int safePage = max(0, page); this.page = min(safePage, getPages() - 1); } PageInfo(int pageSize);   PageInfo(int pageSize, int page, int visible, int total); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); int getFrom(); int getTo(); int getPage(); int getPages(); int getPageSize(); int getVisible(); int getTotal();  }
@Test public void setPage() throws Exception { PageInfo pageInfo = new PageInfo(PAGE_SIZE, 0, 50, 100); pageInfo.setPage(1); assertEquals(1, pageInfo.getPage()); assertEquals(11, pageInfo.getFrom()); assertEquals(20, pageInfo.getTo()); }