ElasticSearchUtils { public static CreateIndexResponse createIndex(Client client, String indexName) { try { return internalCreateIndex(client, indexName); } catch(Exception e) { if(log.isErrorEnabled()) { log.error("Error Creating Index", e); } throw new CreateIndexFailedException(indexName, e); } } private  ElasticSearchUtils(); static IndicesExistsResponse indexExist(Client client, String indexName); static CreateIndexResponse createIndex(Client client, String indexName); static AcknowledgedResponse putMapping(Client client, String indexName, IElasticSearchMapping mapping);  }
@Test public void create_index_throws_correct_exception_when_underlying_client_throws() throws Exception { when(client.admin()).thenThrow(new RuntimeException()); TestUtils.assertThrows(() -> ElasticSearchUtils.createIndex(client, ""), CreateIndexFailedException.class); }