public void createUser( IUser newUser ) throws KettleException {
    ensureHasPermissions();

    ProxyPentahoUser user = UserRoleHelper.convertToPentahoProxyUser( newUser );
    try {
      ProxyPentahoUser[] existingUsers = userRoleWebService.getUsers();
      if ( existsAmong( existingUsers, user ) ) {
        throw userExistsException();
      }
    } catch ( UserRoleException e ) {
      throw cannotCreateUserException( newUser, e );
    }

    try {
      userRoleWebService.createUser( user );
      if ( newUser instanceof IEEUser ) {
        userRoleWebService
            .setRoles( user, UserRoleHelper.convertToPentahoProxyRoles( ( (IEEUser) newUser ).getRoles() ) );
      }
      lookupCache.insertUserToLookupSet( newUser );
      fireUserRoleListChange();
    } catch ( Exception e ) { // it is the only way to determine AlreadyExistsException
      if ( e.getCause().toString().contains(
          "org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException" ) ) {
        throw userExistsException();
      }
      throw cannotCreateUserException( newUser, e );
    }
  }
@Test
  public void createUser_CreatesSuccessfully_WhenNameIsUnique() throws Exception {
    final String name = "user";
    delegate.createUser( new UserInfo( name ) );
    verify( roleWebService ).createUser( any( ProxyPentahoUser.class ) );
  }