public void createRole( IRole newRole ) throws KettleException {
    ensureHasPermissions();

    ProxyPentahoRole role = UserRoleHelper.convertToPentahoProxyRole( newRole );
    try {
      ProxyPentahoRole[] existingRoles = userRoleWebService.getRoles();
      if ( existsAmong( existingRoles, role ) ) {
        throw roleExistsException();
      }
    } catch ( UserRoleException e ) {
      throw cannotCreateRoleException( newRole, e );
    }

    try {
      userRoleWebService.createRole( role );
      userRoleWebService.setUsers( role, UserRoleHelper.convertToPentahoProxyUsers( newRole.getUsers() ) );
      lookupCache.insertRoleToLookupSet( newRole );
      fireUserRoleListChange();
    } catch ( UserRoleException e ) {
      throw cannotCreateRoleException( newRole, e );
    } 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 roleExistsException();
      }
    }
  }
@Test
  public void createRole_CreatesSuccessfully_WhenNameIsUnique() throws Exception {
    final String name = "role";
    delegate.createRole( new EERoleInfo( name ) );
    verify( roleWebService ).createRole( any( ProxyPentahoRole.class ) );
  }