UserManager { public User getByAlias(String alias) throws NotFoundException, ServerException { requireNonNull(alias, "Required non-null alias"); return userDao.getByAlias(alias); } @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(expectedExceptions = NullPointerException.class) public void shouldThrownNpeWhenTryingToGetUserByNullAlias() throws Exception { manager.getByAlias(null); }
@Test public void shouldGetUserByAlias() throws Exception { final User user = new UserImpl( "identifier", "test@email.com", "testName", "password", Collections.singletonList("alias")); when(manager.getByAlias("alias")).thenReturn(user); assertEquals(manager.getByAlias("alias"), user); }