@Test void searchWithIOException() throws IOException { when(restClient.search(any(), any())).thenThrow(new IOException()); assertThrows( IllegalStateException.class, () -> client.search(new ElasticsearchScrollRequest("test", factory))); }
@Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> { try { return client.search(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform search operation with request " + req, e); } }, req -> { try { return client.scroll(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform scroll operation with request " + req, e); } } ); }
ElasticsearchRestClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> { try { return client.search(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform search operation with request " + req, e); } }, req -> { try { return client.scroll(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform scroll operation with request " + req, e); } } ); } }
ElasticsearchRestClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> { try { return client.search(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform search operation with request " + req, e); } }, req -> { try { return client.scroll(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform scroll operation with request " + req, e); } } ); }  }
ElasticsearchRestClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> { try { return client.search(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform search operation with request " + req, e); } }, req -> { try { return client.scroll(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform scroll operation with request " + req, e); } } ); }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task); }
ElasticsearchRestClient implements ElasticsearchClient { @Override public ElasticsearchResponse search(ElasticsearchRequest request) { return request.search( req -> { try { return client.search(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform search operation with request " + req, e); } }, req -> { try { return client.scroll(req, RequestOptions.DEFAULT); } catch (IOException e) { throw new IllegalStateException( "Failed to perform scroll operation with request " + req, e); } } ); }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task);  }