### Question:
JpaUtil { public static <T> List<T> getPagedResultList(TypedQuery<T> query, int offset, int pageSize) { if (pageSize >= LARGE_PAGESIZE) { log.warn("Requesting potentially large resultset. Pagesize is {}", pageSize); } query.setFirstResult(offset).setMaxResults(pageSize); return query.getResultList(); } private  JpaUtil(); static T getSingleResult(List<T> list); static T saveOrUpdate(I id, EntityManager entityManager, T entity); static List<T> getPagedResultList(TypedQuery<T> query, int offset, int pageSize); static void clearAndAdd(List<T> target, List<E> newList, Class<T> clazz);  }### Answer:
@Test @SuppressWarnings("unchecked") public void getPagedResultList() { TypedQuery<BasicEntity> query = createNiceMock(TypedQuery.class); List<BasicEntity> emptyList = new ArrayList<BasicEntity>(); int offset = 0; int pagesize = 10; expect(query.setFirstResult(offset)).andReturn(query); expect(query.setMaxResults(pagesize)).andReturn(query); expect(query.getResultList()).andReturn(emptyList); replay(query); JpaUtil.getPagedResultList(query, offset, pagesize); verify(query); }