Polish
This commit is contained in:
@@ -47,8 +47,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ConditionalOnEnabledHealthIndicator("influxdb")
|
||||
@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class)
|
||||
@AutoConfigureAfter(InfluxDbAutoConfiguration.class)
|
||||
public class InfluxDbHealthIndicatorAutoConfiguration extends
|
||||
CompositeHealthIndicatorConfiguration<InfluxDbHealthIndicator, InfluxDB> {
|
||||
public class InfluxDbHealthIndicatorAutoConfiguration
|
||||
extends CompositeHealthIndicatorConfiguration<InfluxDbHealthIndicator, InfluxDB> {
|
||||
|
||||
private final Map<String, InfluxDB> influxDbs;
|
||||
|
||||
|
||||
@@ -38,10 +38,9 @@ import static org.mockito.Mockito.mock;
|
||||
public class InfluxDbHealthIndicatorAutoConfigurationTests {
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(InfluxDbConfiguration.class)
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
InfluxDbHealthIndicatorAutoConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class));
|
||||
.withUserConfiguration(InfluxDbConfiguration.class).withConfiguration(
|
||||
AutoConfigurations.of(InfluxDbHealthIndicatorAutoConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() {
|
||||
@@ -52,9 +51,8 @@ public class InfluxDbHealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.health.influxdb.enabled:false").run(
|
||||
(context) -> assertThat(context)
|
||||
this.contextRunner.withPropertyValues("management.health.influxdb.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(InfluxDbHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@@ -42,10 +42,9 @@ import static org.mockito.Mockito.mock;
|
||||
public class Neo4jHealthIndicatorAutoConfigurationTests {
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(Neo4jConfiguration.class)
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
Neo4jHealthIndicatorAutoConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class));
|
||||
.withUserConfiguration(Neo4jConfiguration.class).withConfiguration(
|
||||
AutoConfigurations.of(Neo4jHealthIndicatorAutoConfiguration.class,
|
||||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() {
|
||||
@@ -64,9 +63,8 @@ public class Neo4jHealthIndicatorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void defaultIndicatorCanBeReplaced() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(CustomIndicatorConfiguration.class).run(
|
||||
(context) -> {
|
||||
this.contextRunner.withUserConfiguration(CustomIndicatorConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(Neo4jHealthIndicator.class);
|
||||
assertThat(context).doesNotHaveBean(ApplicationHealthIndicator.class);
|
||||
Health health = context.getBean(Neo4jHealthIndicator.class).health();
|
||||
@@ -90,12 +88,15 @@ public class Neo4jHealthIndicatorAutoConfigurationTests {
|
||||
@Bean
|
||||
public Neo4jHealthIndicator neo4jHealthIndicator(SessionFactory sessionFactory) {
|
||||
return new Neo4jHealthIndicator(sessionFactory) {
|
||||
|
||||
@Override
|
||||
protected void extractResult(Session session, Health.Builder builder) {
|
||||
builder.up().withDetail("test", true);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user