@Test void getIndexMappingsWithIOException() throws IOException { when(restClient.indices().getMapping(any(GetMappingsRequest.class), any())) .thenThrow(new IOException()); assertThrows(IllegalStateException.class, () -> client.getIndexMappings("test")); }
@Override public Map<String, IndexMapping> getIndexMappings(String indexExpression) { GetMappingsRequest request = new GetMappingsRequest().indices(indexExpression); try { GetMappingsResponse response = client.indices().getMapping(request, RequestOptions.DEFAULT); return response.mappings().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> new IndexMapping(e.getValue()))); } catch (IOException e) { throw new IllegalStateException("Failed to get index mappings for " + indexExpression, e); } }
ElasticsearchRestClient implements ElasticsearchClient { @Override public Map<String, IndexMapping> getIndexMappings(String indexExpression) { GetMappingsRequest request = new GetMappingsRequest().indices(indexExpression); try { GetMappingsResponse response = client.indices().getMapping(request, RequestOptions.DEFAULT); return response.mappings().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> new IndexMapping(e.getValue()))); } catch (IOException e) { throw new IllegalStateException("Failed to get index mappings for " + indexExpression, e); } } }
ElasticsearchRestClient implements ElasticsearchClient { @Override public Map<String, IndexMapping> getIndexMappings(String indexExpression) { GetMappingsRequest request = new GetMappingsRequest().indices(indexExpression); try { GetMappingsResponse response = client.indices().getMapping(request, RequestOptions.DEFAULT); return response.mappings().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> new IndexMapping(e.getValue()))); } catch (IOException e) { throw new IllegalStateException("Failed to get index mappings for " + indexExpression, e); } }  }
ElasticsearchRestClient implements ElasticsearchClient { @Override public Map<String, IndexMapping> getIndexMappings(String indexExpression) { GetMappingsRequest request = new GetMappingsRequest().indices(indexExpression); try { GetMappingsResponse response = client.indices().getMapping(request, RequestOptions.DEFAULT); return response.mappings().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> new IndexMapping(e.getValue()))); } catch (IOException e) { throw new IllegalStateException("Failed to get index mappings for " + indexExpression, 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 Map<String, IndexMapping> getIndexMappings(String indexExpression) { GetMappingsRequest request = new GetMappingsRequest().indices(indexExpression); try { GetMappingsResponse response = client.indices().getMapping(request, RequestOptions.DEFAULT); return response.mappings().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> new IndexMapping(e.getValue()))); } catch (IOException e) { throw new IllegalStateException("Failed to get index mappings for " + indexExpression, e); } }  @Override Map<String, IndexMapping> getIndexMappings(String indexExpression); @Override ElasticsearchResponse search(ElasticsearchRequest request); @Override void cleanup(ElasticsearchRequest request); @Override void schedule(Runnable task);  }