@Test public void testOnApplicationEvent() { }
@Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (properties.isCreateIndexIfNotFound()) { try { boolean isPresent = client.indices().exists(getIndexRequest(), RequestOptions.DEFAULT); if (!isPresent) { val response = client.indices().create(createIndexRequest(), RequestOptions.DEFAULT); if (!response.isAcknowledged()) { throw new RuntimeException("Index creation failed"); } log.info("Successfully created index: {}", properties.getIndexName()); } } catch (IOException e) { log.error("Index creation failed", e); throw new RuntimeException(e); } } }
IndexCreatorIfNotPresent implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (properties.isCreateIndexIfNotFound()) { try { boolean isPresent = client.indices().exists(getIndexRequest(), RequestOptions.DEFAULT); if (!isPresent) { val response = client.indices().create(createIndexRequest(), RequestOptions.DEFAULT); if (!response.isAcknowledged()) { throw new RuntimeException("Index creation failed"); } log.info("Successfully created index: {}", properties.getIndexName()); } } catch (IOException e) { log.error("Index creation failed", e); throw new RuntimeException(e); } } } }
IndexCreatorIfNotPresent implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (properties.isCreateIndexIfNotFound()) { try { boolean isPresent = client.indices().exists(getIndexRequest(), RequestOptions.DEFAULT); if (!isPresent) { val response = client.indices().create(createIndexRequest(), RequestOptions.DEFAULT); if (!response.isAcknowledged()) { throw new RuntimeException("Index creation failed"); } log.info("Successfully created index: {}", properties.getIndexName()); } } catch (IOException e) { log.error("Index creation failed", e); throw new RuntimeException(e); } } }  }
IndexCreatorIfNotPresent implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (properties.isCreateIndexIfNotFound()) { try { boolean isPresent = client.indices().exists(getIndexRequest(), RequestOptions.DEFAULT); if (!isPresent) { val response = client.indices().create(createIndexRequest(), RequestOptions.DEFAULT); if (!response.isAcknowledged()) { throw new RuntimeException("Index creation failed"); } log.info("Successfully created index: {}", properties.getIndexName()); } } catch (IOException e) { log.error("Index creation failed", e); throw new RuntimeException(e); } } }  @Override void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent); }
IndexCreatorIfNotPresent implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (properties.isCreateIndexIfNotFound()) { try { boolean isPresent = client.indices().exists(getIndexRequest(), RequestOptions.DEFAULT); if (!isPresent) { val response = client.indices().create(createIndexRequest(), RequestOptions.DEFAULT); if (!response.isAcknowledged()) { throw new RuntimeException("Index creation failed"); } log.info("Successfully created index: {}", properties.getIndexName()); } } catch (IOException e) { log.error("Index creation failed", e); throw new RuntimeException(e); } } }  @Override void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent);  }