public void setMenuItemEnabledState( List<UIRepositoryObject> selectedRepoObjects ) {
    try {
      boolean result = false;
      if ( selectedRepoObjects.size() == 1 && selectedRepoObjects.get( 0 ) instanceof UIRepositoryDirectory ) {
        lockFileMenuItem.setDisabled( true );
        deleteFileMenuItem.setDisabled( false );
        renameFileMenuItem.setDisabled( false );
      } else if ( selectedRepoObjects.size() == 1 && selectedRepoObjects.get( 0 ) instanceof ILockObject ) {
        final UIRepositoryContent contentToLock = (UIRepositoryContent) selectedRepoObjects.get( 0 );
        if ( ( (ILockObject) contentToLock ).isLocked() ) {
          if ( repository instanceof PurRepository
                  //repository can be Proxy of repository and first part condition will fail
                  || repository.getRepositoryMeta() instanceof PurRepositoryMeta ) {
            result = service.canUnlockFileById( contentToLock.getObjectId() );

          } else {
            result =
                ( (ILockObject) contentToLock ).getRepositoryLock().getLogin().equalsIgnoreCase(
                    repository.getUserInfo().getLogin() );
          }
          lockFileMenuItem.setDisabled( !result );
          deleteFileMenuItem.setDisabled( !result );
          renameFileMenuItem.setDisabled( !result );
        } else {
          lockFileMenuItem.setDisabled( false );
          deleteFileMenuItem.setDisabled( false );
          renameFileMenuItem.setDisabled( false );
        }
      } else {
        lockFileMenuItem.setDisabled( true );
        deleteFileMenuItem.setDisabled( true );
        renameFileMenuItem.setDisabled( true );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e );
    }

  }
@Test
  public void testBlockLock() throws Exception {
    RepositoryLockController repositoryLockController = new RepositoryLockController();
    List<UIRepositoryObject> selectedRepoObjects = new ArrayList<>();
    UIEETransformation lockObject = Mockito.mock( UIEETransformation.class );
    selectedRepoObjects.add( lockObject );
    Mockito.when( lockObject.isLocked() ).thenReturn( true );
    ObjectId objectId = Mockito.mock( ObjectId.class );
    Mockito.when( lockObject.getObjectId() ).thenReturn( objectId );

    XulMenuitem lockFileMenuItem = Mockito.mock( XulMenuitem.class );
    Field lockFileMenuItemField = repositoryLockController.getClass().getDeclaredField( "lockFileMenuItem" );
    lockFileMenuItemField.setAccessible( true );
    lockFileMenuItemField.set( repositoryLockController, lockFileMenuItem );

    XulMenuitem deleteFileMenuItem = Mockito.mock( XulMenuitem.class );
    Field deleteFileMenuItemField = repositoryLockController.getClass().getDeclaredField( "deleteFileMenuItem" );
    deleteFileMenuItemField.setAccessible( true );
    deleteFileMenuItemField.set( repositoryLockController, deleteFileMenuItem );

    XulMenuitem renameFileMenuItem = Mockito.mock( XulMenuitem.class );
    Field renameFileMenuItemField = repositoryLockController.getClass().getDeclaredField( "renameFileMenuItem" );
    renameFileMenuItemField.setAccessible( true );
    renameFileMenuItemField.set( repositoryLockController, renameFileMenuItem );

    Repository repository = Mockito.mock( Repository.class );
    PurRepositoryMeta repositoryMeta = Mockito.mock( PurRepositoryMeta.class );
    Mockito.when( repository.getRepositoryMeta() ).thenReturn( repositoryMeta );
    Field repositoryField = repositoryLockController.getClass().getDeclaredField( "repository" );
    repositoryField.setAccessible( true );
    repositoryField.set( repositoryLockController, repository );

    ILockService service = Mockito.mock( ILockService.class );
    Mockito.when( service.canUnlockFileById( objectId ) ).thenReturn( true );
    Field serviceField = repositoryLockController.getClass().getDeclaredField( "service" );
    serviceField.setAccessible( true );
    serviceField.set( repositoryLockController, service );

    repositoryLockController.setMenuItemEnabledState( selectedRepoObjects );
    Assert.assertFalse( lockFileMenuItem.isDisabled() );

    Mockito.verify( lockFileMenuItem ).setDisabled( false );

  }