public boolean deleteRepository( String name ) {
    RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name );
    int index = repositoriesMeta.indexOfRepository( repositoryMeta );
    if ( index != -1 ) {
      repositoriesMeta.removeRepository( index );
      save();
      Spoon spoon = spoonSupplier.get();
      Runnable execute = () -> {
        if ( spoon.getRepositoryName() != null && spoon.getRepositoryName().equals( repositoryMeta.getName() ) ) {
          spoon.closeRepository();
          setConnectedRepository( null );
        }
        fireListeners();
      };
      if ( spoon.getShell() != null ) {
        spoon.getShell().getDisplay().asyncExec( execute );
      } else {
        execute.run();
      }
    }
    return true;
  }
@Test
  public void testDeleteRepository() throws Exception {
    int index = 1;
    when( repositoriesMeta.findRepository( REPOSITORY_NAME ) ).thenReturn( repositoryMeta );
    when( repositoriesMeta.indexOfRepository( repositoryMeta ) ).thenReturn( index );
    boolean result = controller.deleteRepository( REPOSITORY_NAME );

    assertEquals( true, result );
    verify( repositoriesMeta ).removeRepository( index );
    verify( repositoriesMeta ).writeData();
  }