ElasticSearchUtils { public static AcknowledgedResponse putMapping(Client client, String indexName, IElasticSearchMapping mapping) { try { return internalPutMapping(client, indexName, mapping); } catch(Exception e) { if(log.isErrorEnabled()) { log.error("Error Creating Index", e); } throw new PutMappingFailedException(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 put_mapping_throws_correct_exception_when_underlying_client_throws() throws Exception { when(client.admin()).thenThrow(new RuntimeException()); TestUtils.assertThrows(() -> ElasticSearchUtils.putMapping(client, "", null), PutMappingFailedException.class); }