### Question:
RepositoryConnectController { public boolean deleteRepository( String name ) { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name ); int index = repositoriesMeta.indexOfRepository( repositoryMeta ); if ( index != -1 ) { Spoon spoon = spoonSupplier.get(); if ( spoon.getRepositoryName() != null && spoon.getRepositoryName().equals( repositoryMeta.getName() ) ) { spoon.closeRepository(); setConnectedRepository( null ); } repositoriesMeta.removeRepository( index ); save(); } return true; } RepositoryConnectController( PluginRegistry pluginRegistry, Supplier<Spoon> spoonSupplier,
                                      RepositoriesMeta repositoriesMeta );  RepositoryConnectController(); @SuppressWarnings( "unchecked" ) String getPlugins(); boolean createRepository( String id, Map<String, Object> items ); @SuppressWarnings( "unchecked" ) String getRepositories(); String getRepository( String name ); DatabaseMeta getDatabase( String name ); void removeDatabase( String name ); @SuppressWarnings( "unchecked" ) String getDatabases(); void connectToRepository(); void connectToRepository( String username, String password ); void connectToRepository( RepositoryMeta repositoryMeta ); void connectToRepository( RepositoryMeta repositoryMeta, String username, String password ); void reconnectToRepository( String username, String password ); boolean deleteRepository( String name ); void addDatabase( DatabaseMeta databaseMeta ); boolean setDefaultRepository( String name ); String getDefaultUrl(); String getCurrentUser(); void setCurrentRepository( RepositoryMeta repositoryMeta ); RepositoryMeta getCurrentRepository(); RepositoryMeta getConnectedRepository(); void setConnectedRepository( RepositoryMeta connectedRepository ); RepositoryMeta getDefaultRepositoryMeta(); RepositoryMeta getRepositoryMetaByName( String name ); boolean isConnected( String name ); boolean isConnected(); Repository getConnectedRepositoryInstance(); void save(); PropsUI getPropsUI(); void addListener( RepositoryContollerListener listener ); void fireListeners(); boolean isRelogin(); void setRelogin( boolean relogin ); Map<String, Object> modelToMap( RepositoryModel model ); static final String DISPLAY_NAME; static final String DESCRIPTION; static final String IS_DEFAULT; static final String URL; static final String DATABASE_CONNECTION; static final String SHOW_HIDDEN_FOLDERS; static final String LOCATION; static final String DO_NOT_MODIFY; static final String DEFAULT_URL; static final String ERROR_401; }### Answer:
@Test public void testDeleteRepository() throws Exception { int index = 1; when( repositoriesMeta.findRepository( REPOSITORY_NAME ) ).thenReturn( repositoryMeta ); when( repositoriesMeta.indexOfRepository( repositoryMeta ) ).thenReturn( index ); when( repositoriesMeta.getRepository( index ) ).thenReturn( repositoryMeta ); boolean result = controller.deleteRepository( REPOSITORY_NAME ); assertEquals( true, result ); verify( repositoriesMeta ).removeRepository( index ); verify( repositoriesMeta ).writeData(); }