@Test public void elasticsearchHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "spring.data.elasticsearch.properties.path.home:target", "management.health.diskspace.enabled:false"); this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ElasticsearchHealthIndicator.class); }
@Test public void notElasticsearchHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.elasticsearch.enabled:false", "spring.data.elasticsearch.properties.path.home:target", "management.health.diskspace.enabled:false"); this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, ElasticsearchAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ApplicationHealthIndicator.class); }
@Test public void elasticsearchJestHealthIndicator() { EnvironmentTestUtils.addEnvironment(this.context, "management.health.diskspace.enabled:false"); this.context.register(JestClientConfiguration.class, JestAutoConfiguration.class, ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class); this.context.refresh(); Map<String, HealthIndicator> beans = this.context .getBeansOfType(HealthIndicator.class); assertThat(beans).hasSize(1); assertThat(beans.values().iterator().next().getClass()) .isEqualTo(ElasticsearchJestHealthIndicator.class); }