LegacyElasticsearchConfig { @Bean(name = "legacyRestHighLevelClient", destroyMethod = "close") public RestHighLevelClient buildRestClient() { RestHighLevelClient elasticsearchClient = new RestHighLevelClient(buildRestClientBuilder()); return elasticsearchClient; }  @Bean(name = "legacyRestHighLevelClient", destroyMethod = "close") RestHighLevelClient buildRestClient();  }
@Test public void testBuildRestClient() { when(elasticSearchProperties.getConfig()).thenReturn(config); when(elasticSearchProperties.getUrls()).thenReturn("localhost:8000"); val elasticsearchRestClient = elasticSearchConfig.buildRestClient(); assertNotNull(elasticsearchRestClient); }