See gh-18531
pull/18564/head
Johnny Lim 5 years ago committed by Stephane Nicoll
parent 3211d756bf
commit d60d59434d

@ -57,7 +57,7 @@ class HealthContributorRegistryHealthIndicatorRegistryAdapterTests {
} }
@Test @Test
void unregisterWhenDelegatesToContributorRegistry() { void unregisterDelegatesToContributorRegistry() {
HealthIndicator healthIndicator = mock(HealthIndicator.class); HealthIndicator healthIndicator = mock(HealthIndicator.class);
this.contributorRegistry.registerContributor("test", healthIndicator); this.contributorRegistry.registerContributor("test", healthIndicator);
HealthIndicator unregistered = this.adapter.unregister("test"); HealthIndicator unregistered = this.adapter.unregister("test");
@ -89,7 +89,7 @@ class HealthContributorRegistryHealthIndicatorRegistryAdapterTests {
} }
@Test @Test
void getAllDelegatesContributorRegistry() { void getAllDelegatesToContributorRegistry() {
HealthIndicator healthIndicator = mock(HealthIndicator.class); HealthIndicator healthIndicator = mock(HealthIndicator.class);
this.contributorRegistry.registerContributor("test", healthIndicator); this.contributorRegistry.registerContributor("test", healthIndicator);
Map<String, HealthIndicator> all = this.adapter.getAll(); Map<String, HealthIndicator> all = this.adapter.getAll();

@ -16,8 +16,6 @@
package org.springframework.boot.actuate.autoconfigure.health; package org.springframework.boot.actuate.autoconfigure.health;
import java.util.List;
import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -27,7 +25,6 @@ import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegi
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
import org.springframework.boot.actuate.health.CompositeHealthIndicator; import org.springframework.boot.actuate.health.CompositeHealthIndicator;
import org.springframework.boot.actuate.health.HealthAggregator; import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicatorRegistry; import org.springframework.boot.actuate.health.HealthIndicatorRegistry;
import org.springframework.boot.actuate.health.Status; import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
@ -61,12 +58,9 @@ public class HealthIndicatorRegistryInjectionIntegrationTests {
static class Config { static class Config {
Config(HealthAggregator healthAggregator, HealthIndicatorRegistry healthIndicatorRegistry, Config(HealthAggregator healthAggregator, HealthIndicatorRegistry healthIndicatorRegistry,
List<HealthIndicator> healthIndicators, MeterRegistry registry) { MeterRegistry registry) {
CompositeHealthIndicator healthIndicator = new CompositeHealthIndicator(healthAggregator, CompositeHealthIndicator healthIndicator = new CompositeHealthIndicator(healthAggregator,
healthIndicatorRegistry); healthIndicatorRegistry);
for (int i = 0; i < healthIndicators.size(); i++) {
healthIndicatorRegistry.register(Integer.toString(i), healthIndicators.get(i));
}
Gauge.builder("health", healthIndicator, this::getGuageValue) Gauge.builder("health", healthIndicator, this::getGuageValue)
.description("Spring boot health indicator. 3=UP, 2=OUT_OF_SERVICE, 1=DOWN, 0=UNKNOWN") .description("Spring boot health indicator. 3=UP, 2=OUT_OF_SERVICE, 1=DOWN, 0=UNKNOWN")
.strongReference(true).register(registry); .strongReference(true).register(registry);

@ -58,7 +58,7 @@ class ReactiveHealthContributorRegistryReactiveHealthIndicatorRegistryAdapterTes
} }
@Test @Test
void unregisterWhenDelegatesToContributorRegistry() { void unregisterDelegatesToContributorRegistry() {
ReactiveHealthIndicator healthIndicator = mock(ReactiveHealthIndicator.class); ReactiveHealthIndicator healthIndicator = mock(ReactiveHealthIndicator.class);
this.contributorRegistry.registerContributor("test", healthIndicator); this.contributorRegistry.registerContributor("test", healthIndicator);
ReactiveHealthIndicator unregistered = this.adapter.unregister("test"); ReactiveHealthIndicator unregistered = this.adapter.unregister("test");
@ -90,7 +90,7 @@ class ReactiveHealthContributorRegistryReactiveHealthIndicatorRegistryAdapterTes
} }
@Test @Test
void getAllDelegatesContributorRegistry() { void getAllDelegatesToContributorRegistry() {
ReactiveHealthIndicator healthIndicator = mock(ReactiveHealthIndicator.class); ReactiveHealthIndicator healthIndicator = mock(ReactiveHealthIndicator.class);
this.contributorRegistry.registerContributor("test", healthIndicator); this.contributorRegistry.registerContributor("test", healthIndicator);
Map<String, ReactiveHealthIndicator> all = this.adapter.getAll(); Map<String, ReactiveHealthIndicator> all = this.adapter.getAll();

Loading…
Cancel
Save