CollectionProxy { public UpdateResponse deleteAllAndCommit() { try { return new UpdateRequest().deleteByQuery("*:*").commit(solrClient, nameOrAlias); } catch (IOException e) { logException(e); throw new UncheckedIOException(e); } catch (SolrServerException e) { logException(e); throw new UncheckedIOException(new IOException(e)); } } protected  CollectionProxy(SolrClient solrClient, String nameOrAlias); QueryResponse rawQuery(SolrQuery solrQuery); UpdateResponse addAndCommit(Collection<SolrInputDocument> docs); UpdateResponse deleteAllAndCommit(); final SolrClient solrClient; final String nameOrAlias; }
@Test public void deleteIOExceptionIsWrapped() throws IOException, SolrServerException { when(solrClientMock.request(any(UpdateRequest.class), eq(subject.nameOrAlias))) .thenThrow(new IOException()); assertThatExceptionOfType(UncheckedIOException.class) .isThrownBy(() -> subject.deleteAllAndCommit()); }
@Test public void deleteSolrServerExceptionIsWrapped() throws IOException, SolrServerException { when(solrClientMock.request(any(UpdateRequest.class), eq(subject.nameOrAlias))) .thenThrow(new SolrServerException("")); assertThatExceptionOfType(UncheckedIOException.class) .isThrownBy(() -> subject.deleteAllAndCommit()); }