CollectionProxy { public QueryResponse rawQuery(SolrQuery solrQuery) { try { return solrClient.query(nameOrAlias, solrQuery, SolrRequest.METHOD.POST); } 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 queryIOExceptionIsWrapped() throws IOException, SolrServerException { when(solrClientMock.query(anyString(), any(SolrParams.class), eq(SolrRequest.METHOD.POST))) .thenThrow(new IOException()); assertThatExceptionOfType(UncheckedIOException.class) .isThrownBy(() -> subject.rawQuery(new SolrQuery("*:*"))); }
@Test public void querySolrServerExceptionIsWrapped() throws IOException, SolrServerException { when(solrClientMock.query(anyString(), any(SolrParams.class), eq(SolrRequest.METHOD.POST))) .thenThrow(new SolrServerException("")); assertThatExceptionOfType(UncheckedIOException.class) .isThrownBy(() -> subject.rawQuery(new SolrQuery("*:*"))); }