ProductCartDao extends HibernateDao<ProductCart, String> { public List<Product> scrollCartOfUser(final User user, final int skip, final int top) { if (user == null) { return Collections.emptyList(); } ProductCart cart = getCartOfUser(user); if (cart == null) { return Collections.emptyList(); } return setToLimitedList(cart.getProducts(), skip, top); }  @SuppressWarnings("unchecked") ProductCart getCartOfUser(final User user); void deleteCartOfUser(User user); void deleteProductReferences(final Product product); List<Product> scrollCartOfUser(final User user, final int skip, final int top); List<Long> getProductsIdOfCart(User user);  }
@Test public void scrollCartOfUser() { User user = new User(); user.setUUID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0"); Iterator<Product> it = dao.scrollCartOfUser(user, -1, -1).iterator(); assertTrue(CheckIterator.checkElementNumber(it, 2)); it = dao.scrollCartOfUser(user, 0, 10000).iterator(); assertTrue(CheckIterator.checkElementNumber(it, 2)); it = dao.scrollCartOfUser(user, 1, 10).iterator(); assertTrue(CheckIterator.checkElementNumber(it, 1)); it = dao.scrollCartOfUser(user, 2, 10).iterator(); assertTrue(CheckIterator.checkElementNumber(it, 0)); it = dao.scrollCartOfUser(user, 10, 10).iterator(); assertTrue(CheckIterator.checkElementNumber(it, 0)); }