JpaUserDao implements UserDao { @Override @Transactional public Page<UserImpl> getAll(int maxItems, long skipCount) throws ServerException { checkArgument(maxItems >= 0, "The number of items to return can't be negative."); checkArgument( skipCount >= 0 && skipCount <= Integer.MAX_VALUE, "The number of items to skip can't be negative or greater than " + Integer.MAX_VALUE); try { final List<UserImpl> list = managerProvider .get() .createNamedQuery("User.getAll", UserImpl.class) .setMaxResults(maxItems) .setFirstResult((int) skipCount) .getResultList() .stream() .map(JpaUserDao::erasePassword) .collect(toList()); return new Page<>(list, skipCount, maxItems, getTotalCount()); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }  @Override @Transactional UserImpl getByAliasAndPassword(String emailOrName, String password); @Override void create(UserImpl user); @Override void update(UserImpl update); @Override void remove(String id); @Override UserImpl getByAlias(String alias); @Override @Transactional UserImpl getById(String id); @Override @Transactional UserImpl getByName(String name); @Override @Transactional UserImpl getByEmail(String email); @Override @Transactional Page<UserImpl> getAll(int maxItems, long skipCount); @Override @Transactional Page<UserImpl> getByNamePart(String namePart, int maxItems, long skipCount); @Override @Transactional Page<UserImpl> getByEmailPart(String emailPart, int maxItems, long skipCount); @Override @Transactional long getTotalCount();  }
@Test( expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The number of items to skip can't be negative or greater than 2147483647") public void shouldThrowExceptionOnGetAllWithGraterThanMaximumIntegerValueAsSkipCountParameter() throws Exception { userDao.getAll(30, Integer.MAX_VALUE + 1L); }