|
|
|
@ -42,10 +42,9 @@ import static org.mockito.Mockito.mock; |
|
|
|
public class Neo4jHealthIndicatorAutoConfigurationTests { |
|
|
|
public class Neo4jHealthIndicatorAutoConfigurationTests { |
|
|
|
|
|
|
|
|
|
|
|
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() |
|
|
|
private ApplicationContextRunner contextRunner = new ApplicationContextRunner() |
|
|
|
.withUserConfiguration(Neo4jConfiguration.class) |
|
|
|
.withUserConfiguration(Neo4jConfiguration.class).withConfiguration( |
|
|
|
.withConfiguration(AutoConfigurations.of( |
|
|
|
AutoConfigurations.of(Neo4jHealthIndicatorAutoConfiguration.class, |
|
|
|
Neo4jHealthIndicatorAutoConfiguration.class, |
|
|
|
HealthIndicatorAutoConfiguration.class)); |
|
|
|
HealthIndicatorAutoConfiguration.class)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void runShouldCreateIndicator() { |
|
|
|
public void runShouldCreateIndicator() { |
|
|
|
@ -64,9 +63,8 @@ public class Neo4jHealthIndicatorAutoConfigurationTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void defaultIndicatorCanBeReplaced() { |
|
|
|
public void defaultIndicatorCanBeReplaced() { |
|
|
|
this.contextRunner |
|
|
|
this.contextRunner.withUserConfiguration(CustomIndicatorConfiguration.class) |
|
|
|
.withUserConfiguration(CustomIndicatorConfiguration.class).run( |
|
|
|
.run((context) -> { |
|
|
|
(context) -> { |
|
|
|
|
|
|
|
assertThat(context).hasSingleBean(Neo4jHealthIndicator.class); |
|
|
|
assertThat(context).hasSingleBean(Neo4jHealthIndicator.class); |
|
|
|
assertThat(context).doesNotHaveBean(ApplicationHealthIndicator.class); |
|
|
|
assertThat(context).doesNotHaveBean(ApplicationHealthIndicator.class); |
|
|
|
Health health = context.getBean(Neo4jHealthIndicator.class).health(); |
|
|
|
Health health = context.getBean(Neo4jHealthIndicator.class).health(); |
|
|
|
@ -90,12 +88,15 @@ public class Neo4jHealthIndicatorAutoConfigurationTests { |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public Neo4jHealthIndicator neo4jHealthIndicator(SessionFactory sessionFactory) { |
|
|
|
public Neo4jHealthIndicator neo4jHealthIndicator(SessionFactory sessionFactory) { |
|
|
|
return new Neo4jHealthIndicator(sessionFactory) { |
|
|
|
return new Neo4jHealthIndicator(sessionFactory) { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void extractResult(Session session, Health.Builder builder) { |
|
|
|
protected void extractResult(Session session, Health.Builder builder) { |
|
|
|
builder.up().withDetail("test", true); |
|
|
|
builder.up().withDetail("test", true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|