ElasticsearchConfig { @Bean public ElasticsearchRestTemplate elasticsearchTemplate() { return new ElasticsearchRestTemplate(client()); }  @Bean ElasticsearchRestTemplate elasticsearchTemplate(); @Bean(destroyMethod = "close") RestHighLevelClient client();  }
@Test public void testRestTemplate() { when(elasticSearchProperties.getUrls()).thenReturn("localhost:8000"); when(elasticSearchProperties.getConfig()).thenReturn(config); val elasticsearchRestTemplate = elasticSearchConfig.elasticsearchTemplate(); assertNotNull(elasticsearchRestTemplate); }