SolrDeletionManager extends SolrManager { public void deleteSolrCluster(String cluster_id) throws SolrServerException { log.info(MessageFormat.format(Messages.getString("RetrieveAndRank.CLUSTER_DELETING"), cluster_id)); List<SolrCluster> clusters = service.getSolrClusters().getSolrClusters(); for (SolrCluster cluster : clusters) { if (cluster.getId().equals(cluster_id)) { service.deleteSolrCluster(cluster_id); log.info(Messages.getString("RetrieveAndRank.CLUSTER_DELETED")); return; } } throw new SolrServerException( MessageFormat.format(Messages.getString("RetrieveAndRank.CLUSTER_UNKNOWN"), cluster_id)); } SolrDeletionManager(String username, String password, String rnr_endpoint); void deleteSolrCluster(String cluster_id); static void main(String[] args);  }
@Test public void test_delete_Cluster() throws InterruptedException, URISyntaxException, SolrServerException { String cluster_id = "some_id"; mockedDeletionManager = mock(SolrDeletionManager.class); GIVEN.create_manager(mockedDeletionManager); AND.manager_has_cluster(mockedDeletionManager, cluster_id); THEN.mockedDeletionManager.deleteSolrCluster(cluster_id); }
@Test(expected = URISyntaxException.class) public void test_fail_delete_invalid_url_cluster() throws InterruptedException, URISyntaxException, SolrServerException, IOException { String cluster_id = "some_id"; GIVEN.deletion_manager_is_from_invalid_url(); THEN.mockedDeletionManager.deleteSolrCluster(cluster_id);; }
@Test(expected = SolrServerException.class) public void test_fail_delete_cluster() throws InterruptedException, URISyntaxException, SolrServerException, IOException { String cluster_id = "some_id"; GIVEN.create_deletion_manager(); THEN.mockedDeletionManager.deleteSolrCluster(cluster_id);; }