UserManager { 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, "The number of items to skip can't be negative."); return userDao.getAll(maxItems, skipCount); } @Inject  UserManager(
      UserDao userDao,
      ProfileDao profileDao,
      PreferenceDao preferencesDao,
      EventService eventService,
      @Named("che.auth.reserved_user_names") String[] reservedNames); User create(User newUser, boolean isTemporary); void update(User user); User getById(String id); User getByAlias(String alias); User getByName(String name); User getByEmail(String email); Page<UserImpl> getAll(int maxItems, long skipCount); Page<? extends User> getByEmailPart(String emailPart, int maxItems, long skipCount); Page<? extends User> getByNamePart(String namePart, int maxItems, long skipCount); long getTotalCount(); void remove(String id); static final String PERSONAL_ACCOUNT; }
@Test public void shouldGetAllUsers() throws Exception { final Page users = new Page( Arrays.asList( new UserImpl( "identifier1", "test1@email.com", "testName1", "password", Collections.singletonList("alias1")), new UserImpl( "identifier2", "test2@email.com", "testName2", "password", Collections.singletonList("alias2")), new UserImpl( "identifier3", "test3@email.com", "testName3", "password", Collections.singletonList("alias3"))), 0, 30, 3); when(userDao.getAll(30, 0)).thenReturn(users); assertEquals(manager.getAll(30, 0), users); verify(userDao).getAll(30, 0); }
@Test(expectedExceptions = IllegalArgumentException.class) public void shouldThrowIllegalArgumentExceptionsWhenGetAllUsersWithNegativeMaxItems() throws Exception { manager.getAll(-5, 0); }
@Test(expectedExceptions = IllegalArgumentException.class) public void shouldThrowIllegalArgumentExceptionsWhenGetAllUsersWithNegativeSkipCount() throws Exception { manager.getAll(30, -11); }