Commit 3702da45 authored by Phillip Webb's avatar Phillip Webb

Formatting

parent 22157091
...@@ -44,8 +44,8 @@ public abstract class CompositeReactiveHealthIndicatorConfiguration<H extends Re ...@@ -44,8 +44,8 @@ public abstract class CompositeReactiveHealthIndicatorConfiguration<H extends Re
return createHealthIndicator(beans.values().iterator().next()); return createHealthIndicator(beans.values().iterator().next());
} }
ReactiveHealthIndicatorRegistry registry = new DefaultReactiveHealthIndicatorRegistry(); ReactiveHealthIndicatorRegistry registry = new DefaultReactiveHealthIndicatorRegistry();
beans.forEach((name, source) -> registry.register(name, beans.forEach(
createHealthIndicator(source))); (name, source) -> registry.register(name, createHealthIndicator(source)));
return new CompositeReactiveHealthIndicator(this.healthAggregator, registry); return new CompositeReactiveHealthIndicator(this.healthAggregator, registry);
} }
......
...@@ -89,9 +89,11 @@ public class HealthIndicatorAutoConfiguration { ...@@ -89,9 +89,11 @@ public class HealthIndicatorAutoConfiguration {
public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry( public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry(
ObjectProvider<Map<String, ReactiveHealthIndicator>> reactiveHealthIndicators, ObjectProvider<Map<String, ReactiveHealthIndicator>> reactiveHealthIndicators,
ObjectProvider<Map<String, HealthIndicator>> healthIndicators) { ObjectProvider<Map<String, HealthIndicator>> healthIndicators) {
return new ReactiveHealthIndicatorRegistryFactory().createReactiveHealthIndicatorRegistry( return new ReactiveHealthIndicatorRegistryFactory()
reactiveHealthIndicators.getIfAvailable(Collections::emptyMap), .createReactiveHealthIndicatorRegistry(
healthIndicators.getIfAvailable(Collections::emptyMap)); reactiveHealthIndicators
.getIfAvailable(Collections::emptyMap),
healthIndicators.getIfAvailable(Collections::emptyMap));
} }
} }
......
...@@ -57,10 +57,12 @@ public class PropertiesMeterFilter implements MeterFilter { ...@@ -57,10 +57,12 @@ public class PropertiesMeterFilter implements MeterFilter {
private static MeterFilter createMapFilter(Map<String, String> tags) { private static MeterFilter createMapFilter(Map<String, String> tags) {
if (tags.isEmpty()) { if (tags.isEmpty()) {
return new MeterFilter() { }; return new MeterFilter() {
};
} }
Tags commonTags = Tags.of(tags.entrySet().stream().map((entry) -> Tags commonTags = Tags.of(tags.entrySet().stream()
Tag.of(entry.getKey(), entry.getValue())).collect(Collectors.toList())); .map((entry) -> Tag.of(entry.getKey(), entry.getValue()))
.collect(Collectors.toList()));
return MeterFilter.commonTags(commonTags); return MeterFilter.commonTags(commonTags);
} }
......
...@@ -73,8 +73,8 @@ public class CloudFoundryWebEndpointDiscovererTests { ...@@ -73,8 +73,8 @@ public class CloudFoundryWebEndpointDiscovererTests {
return operation; return operation;
} }
} }
throw new IllegalStateException("No main read operation found from " throw new IllegalStateException(
+ endpoint.getOperations()); "No main read operation found from " + endpoint.getOperations());
} }
private void load(Class<?> configuration, private void load(Class<?> configuration,
......
...@@ -61,8 +61,7 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati ...@@ -61,8 +61,7 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati
fieldWithPath("status") fieldWithPath("status")
.description("Status of a specific part of the application"), .description("Status of a specific part of the application"),
subsectionWithPath("details").description( subsectionWithPath("details").description(
"Details of the health of a specific part of the" "Details of the health of a specific part of the" + " application."));
+ " application."));
@Test @Test
public void health() throws Exception { public void health() throws Exception {
...@@ -111,18 +110,17 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati ...@@ -111,18 +110,17 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati
} }
@Bean @Bean
public DataSourceHealthIndicator dbHealthIndicator( public DataSourceHealthIndicator dbHealthIndicator(DataSource dataSource) {
DataSource dataSource) {
return new DataSourceHealthIndicator(dataSource); return new DataSourceHealthIndicator(dataSource);
} }
@Bean @Bean
public CompositeHealthIndicator brokerHealthIndicator() { public CompositeHealthIndicator brokerHealthIndicator() {
Map<String, HealthIndicator> indicators = new LinkedHashMap<>(); Map<String, HealthIndicator> indicators = new LinkedHashMap<>();
indicators.put("us1", () -> Health.up().withDetail("version", "1.0.2") indicators.put("us1",
.build()); () -> Health.up().withDetail("version", "1.0.2").build());
indicators.put("us2", () -> Health.up().withDetail("version", "1.0.4") indicators.put("us2",
.build()); () -> Health.up().withDetail("version", "1.0.4").build());
return new CompositeHealthIndicator(new OrderedHealthAggregator(), return new CompositeHealthIndicator(new OrderedHealthAggregator(),
new DefaultHealthIndicatorRegistry(indicators)); new DefaultHealthIndicatorRegistry(indicators));
} }
......
...@@ -53,8 +53,7 @@ import static org.mockito.Mockito.mock; ...@@ -53,8 +53,7 @@ import static org.mockito.Mockito.mock;
public class HealthEndpointWebExtensionTests { public class HealthEndpointWebExtensionTests {
private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withUserConfiguration(HealthIndicatorsConfiguration.class) .withUserConfiguration(HealthIndicatorsConfiguration.class).withConfiguration(
.withConfiguration(
AutoConfigurations.of(HealthIndicatorAutoConfiguration.class, AutoConfigurations.of(HealthIndicatorAutoConfiguration.class,
HealthEndpointAutoConfiguration.class)); HealthEndpointAutoConfiguration.class));
...@@ -96,8 +95,9 @@ public class HealthEndpointWebExtensionTests { ...@@ -96,8 +95,9 @@ public class HealthEndpointWebExtensionTests {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
assertThat(extension.health(mock(SecurityContext.class)).getBody() assertThat(
.getDetails()).isEmpty(); extension.health(mock(SecurityContext.class)).getBody().getDetails())
.isEmpty();
}); });
} }
...@@ -124,9 +124,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -124,9 +124,8 @@ public class HealthEndpointWebExtensionTests {
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
assertThat( assertThat(extension.health(securityContext).getBody().getDetails())
extension.health(securityContext).getBody().getDetails()) .isNotEmpty();
.isNotEmpty();
}); });
} }
...@@ -165,9 +164,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -165,9 +164,8 @@ public class HealthEndpointWebExtensionTests {
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); given(securityContext.isUserInRole("ACTUATOR")).willReturn(false);
assertThat( assertThat(extension.health(securityContext).getBody().getDetails())
extension.health(securityContext).getBody().getDetails()) .isEmpty();
.isEmpty();
}); });
} }
...@@ -182,9 +180,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -182,9 +180,8 @@ public class HealthEndpointWebExtensionTests {
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); given(securityContext.isUserInRole("ACTUATOR")).willReturn(true);
assertThat( assertThat(extension.health(securityContext).getBody().getDetails())
extension.health(securityContext).getBody().getDetails()) .isNotEmpty();
.isNotEmpty();
}); });
} }
...@@ -193,8 +190,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -193,8 +190,8 @@ public class HealthEndpointWebExtensionTests {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
assertDetailsNotFound(extension.healthForComponent( assertDetailsNotFound(
mock(SecurityContext.class), "simple")); extension.healthForComponent(mock(SecurityContext.class), "simple"));
}); });
} }
...@@ -205,8 +202,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -205,8 +202,8 @@ public class HealthEndpointWebExtensionTests {
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()).willReturn(mock(Principal.class)); given(securityContext.getPrincipal()).willReturn(mock(Principal.class));
assertDetailsNotFound(extension.healthForComponent(securityContext, assertDetailsNotFound(
"simple")); extension.healthForComponent(securityContext, "simple"));
}); });
} }
...@@ -221,8 +218,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -221,8 +218,8 @@ public class HealthEndpointWebExtensionTests {
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
assertSimpleComponent(extension.healthForComponent( assertSimpleComponent(
securityContext, "simple")); extension.healthForComponent(securityContext, "simple"));
}); });
} }
...@@ -244,8 +241,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -244,8 +241,8 @@ public class HealthEndpointWebExtensionTests {
.run((context) -> { .run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
assertDetailsNotFound(extension.healthForComponent( assertDetailsNotFound(extension
mock(SecurityContext.class), "simple")); .healthForComponent(mock(SecurityContext.class), "simple"));
}); });
} }
...@@ -254,15 +251,15 @@ public class HealthEndpointWebExtensionTests { ...@@ -254,15 +251,15 @@ public class HealthEndpointWebExtensionTests {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"management.endpoint.health.show-details=when-authorized", "management.endpoint.health.show-details=when-authorized",
"management.endpoint.health.roles=ACTUATOR").run((context) -> { "management.endpoint.health.roles=ACTUATOR").run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); given(securityContext.isUserInRole("ACTUATOR")).willReturn(false);
assertDetailsNotFound(extension.healthForComponent(securityContext, assertDetailsNotFound(
"simple")); extension.healthForComponent(securityContext, "simple"));
}); });
} }
@Test @Test
...@@ -270,15 +267,15 @@ public class HealthEndpointWebExtensionTests { ...@@ -270,15 +267,15 @@ public class HealthEndpointWebExtensionTests {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"management.endpoint.health.show-details=when-authorized", "management.endpoint.health.show-details=when-authorized",
"management.endpoint.health.roles=ACTUATOR").run((context) -> { "management.endpoint.health.roles=ACTUATOR").run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); given(securityContext.isUserInRole("ACTUATOR")).willReturn(true);
assertSimpleComponent(extension.healthForComponent(securityContext, assertSimpleComponent(
"simple")); extension.healthForComponent(securityContext, "simple"));
}); });
} }
@Test @Test
...@@ -288,8 +285,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -288,8 +285,8 @@ public class HealthEndpointWebExtensionTests {
.run((context) -> { .run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
assertDetailsNotFound(extension.healthForComponent(null, assertDetailsNotFound(
"does-not-exist")); extension.healthForComponent(null, "does-not-exist"));
}); });
} }
...@@ -360,15 +357,15 @@ public class HealthEndpointWebExtensionTests { ...@@ -360,15 +357,15 @@ public class HealthEndpointWebExtensionTests {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"management.endpoint.health.show-details=when-authorized", "management.endpoint.health.show-details=when-authorized",
"management.endpoint.health.roles=ACTUATOR").run((context) -> { "management.endpoint.health.roles=ACTUATOR").run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); given(securityContext.isUserInRole("ACTUATOR")).willReturn(false);
assertDetailsNotFound(extension.healthForComponentInstance(securityContext, assertDetailsNotFound(extension.healthForComponentInstance(
"composite", "one")); securityContext, "composite", "one"));
}); });
} }
@Test @Test
...@@ -376,15 +373,15 @@ public class HealthEndpointWebExtensionTests { ...@@ -376,15 +373,15 @@ public class HealthEndpointWebExtensionTests {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"management.endpoint.health.show-details=when-authorized", "management.endpoint.health.show-details=when-authorized",
"management.endpoint.health.roles=ACTUATOR").run((context) -> { "management.endpoint.health.roles=ACTUATOR").run((context) -> {
HealthEndpointWebExtension extension = context HealthEndpointWebExtension extension = context
.getBean(HealthEndpointWebExtension.class); .getBean(HealthEndpointWebExtension.class);
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); given(securityContext.isUserInRole("ACTUATOR")).willReturn(true);
assertSimpleComponent(extension.healthForComponentInstance(securityContext, assertSimpleComponent(extension.healthForComponentInstance(
"composite", "one")); securityContext, "composite", "one"));
}); });
} }
@Test @Test
...@@ -406,8 +403,7 @@ public class HealthEndpointWebExtensionTests { ...@@ -406,8 +403,7 @@ public class HealthEndpointWebExtensionTests {
private void assertSimpleComponent(WebEndpointResponse<Health> response) { private void assertSimpleComponent(WebEndpointResponse<Health> response) {
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(response.getBody().getDetails()).containsOnly( assertThat(response.getBody().getDetails()).containsOnly(entry("counter", 42));
entry("counter", 42));
} }
@Test @Test
...@@ -421,9 +417,8 @@ public class HealthEndpointWebExtensionTests { ...@@ -421,9 +417,8 @@ public class HealthEndpointWebExtensionTests {
given(securityContext.getPrincipal()) given(securityContext.getPrincipal())
.willReturn(mock(Principal.class)); .willReturn(mock(Principal.class));
given(securityContext.isUserInRole("ADMIN")).willReturn(true); given(securityContext.isUserInRole("ADMIN")).willReturn(true);
assertThat( assertThat(extension.health(securityContext).getBody().getDetails())
extension.health(securityContext).getBody().getDetails()) .isNotEmpty();
.isNotEmpty();
}); });
} }
......
...@@ -220,12 +220,11 @@ public class ReactiveHealthEndpointWebExtensionTests { ...@@ -220,12 +220,11 @@ public class ReactiveHealthEndpointWebExtensionTests {
@Test @Test
public void registryCanBeAltered() { public void registryCanBeAltered() {
this.contextRunner this.contextRunner.withUserConfiguration(HealthIndicatorsConfiguration.class)
.withUserConfiguration(HealthIndicatorsConfiguration.class)
.withPropertyValues("management.endpoint.health.show-details=always") .withPropertyValues("management.endpoint.health.show-details=always")
.run((context) -> { .run((context) -> {
ReactiveHealthIndicatorRegistry registry = context.getBean( ReactiveHealthIndicatorRegistry registry = context
ReactiveHealthIndicatorRegistry.class); .getBean(ReactiveHealthIndicatorRegistry.class);
ReactiveHealthEndpointWebExtension extension = context ReactiveHealthEndpointWebExtension extension = context
.getBean(ReactiveHealthEndpointWebExtension.class); .getBean(ReactiveHealthEndpointWebExtension.class);
assertThat(extension.health(null).block().getBody().getDetails()) assertThat(extension.health(null).block().getBody().getDetails())
......
...@@ -58,13 +58,12 @@ public class MetricsAutoConfigurationIntegrationTests { ...@@ -58,13 +58,12 @@ public class MetricsAutoConfigurationIntegrationTests {
@Test @Test
public void propertyBasedCommonTagsIsAutoConfigured() { public void propertyBasedCommonTagsIsAutoConfigured() {
this.contextRunner.withPropertyValues("management.metrics.tags.region=test", this.contextRunner.withPropertyValues("management.metrics.tags.region=test",
"management.metrics.tags.origin=local") "management.metrics.tags.origin=local").run((context) -> {
.run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class); MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.counter("my.counter", "env", "qa"); registry.counter("my.counter", "env", "qa");
assertThat(registry.find("my.counter").tags("env", "qa") assertThat(registry.find("my.counter").tags("env", "qa")
.tags("region", "test").tags("origin", "local").counter()) .tags("region", "test").tags("origin", "local").counter())
.isNotNull(); .isNotNull();
}); });
} }
......
...@@ -68,8 +68,8 @@ public class CachesEndpoint { ...@@ -68,8 +68,8 @@ public class CachesEndpoint {
new CacheDescriptor(entry.getTarget())); new CacheDescriptor(entry.getTarget()));
}); });
Map<String, CacheManagerDescriptor> cacheManagerDescriptors = new LinkedHashMap<>(); Map<String, CacheManagerDescriptor> cacheManagerDescriptors = new LinkedHashMap<>();
descriptors.forEach((name, entries) -> descriptors.forEach((name, entries) -> cacheManagerDescriptors.put(name,
cacheManagerDescriptors.put(name, new CacheManagerDescriptor(entries))); new CacheManagerDescriptor(entries)));
return new CachesReport(cacheManagerDescriptors); return new CachesReport(cacheManagerDescriptors);
} }
......
...@@ -45,11 +45,10 @@ public class CompositeHealthIndicator implements HealthIndicator { ...@@ -45,11 +45,10 @@ public class CompositeHealthIndicator implements HealthIndicator {
} }
/** /**
* Create a new {@link CompositeHealthIndicator} from the specified * Create a new {@link CompositeHealthIndicator} from the specified indicators.
* indicators.
* @param healthAggregator the health aggregator * @param healthAggregator the health aggregator
* @param indicators a map of {@link HealthIndicator HealthIndicators} with * @param indicators a map of {@link HealthIndicator HealthIndicators} with the key
* the key being used as an indicator name. * being used as an indicator name.
* @deprecated since 2.1.0 in favour of * @deprecated since 2.1.0 in favour of
* {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)} * {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)}
*/ */
...@@ -60,8 +59,8 @@ public class CompositeHealthIndicator implements HealthIndicator { ...@@ -60,8 +59,8 @@ public class CompositeHealthIndicator implements HealthIndicator {
} }
/** /**
* Create a new {@link CompositeHealthIndicator} from the indicators in the * Create a new {@link CompositeHealthIndicator} from the indicators in the given
* given {@code registry}. * {@code registry}.
* @param healthAggregator the health aggregator * @param healthAggregator the health aggregator
* @param registry the registry of {@link HealthIndicator HealthIndicators}. * @param registry the registry of {@link HealthIndicator HealthIndicators}.
*/ */
...@@ -72,12 +71,11 @@ public class CompositeHealthIndicator implements HealthIndicator { ...@@ -72,12 +71,11 @@ public class CompositeHealthIndicator implements HealthIndicator {
} }
/** /**
* Adds the given {@code healthIndicator}, associating it with the given * Adds the given {@code healthIndicator}, associating it with the given {@code name}.
* {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @param indicator the indicator * @param indicator the indicator
* @throws IllegalStateException if an indicator with the given {@code name} * @throws IllegalStateException if an indicator with the given {@code name} is
* is already registered. * already registered.
* @deprecated since 2.1.0 in favour of * @deprecated since 2.1.0 in favour of
* {@link HealthIndicatorRegistry#register(String, HealthIndicator)} * {@link HealthIndicatorRegistry#register(String, HealthIndicator)}
*/ */
......
...@@ -57,8 +57,8 @@ public class CompositeHealthIndicatorFactory { ...@@ -57,8 +57,8 @@ public class CompositeHealthIndicatorFactory {
Assert.notNull(healthIndicators, "HealthIndicators must not be null"); Assert.notNull(healthIndicators, "HealthIndicators must not be null");
HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory( HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory(
this.healthIndicatorNameFactory); this.healthIndicatorNameFactory);
return new CompositeHealthIndicator( return new CompositeHealthIndicator(healthAggregator,
healthAggregator, factory.createHealthIndicatorRegistry(healthIndicators)); factory.createHealthIndicatorRegistry(healthIndicators));
} }
} }
...@@ -91,8 +91,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator ...@@ -91,8 +91,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator
* @param name the name of the health indicator * @param name the name of the health indicator
* @param indicator the health indicator to add * @param indicator the health indicator to add
* @return this instance * @return this instance
* @throws IllegalStateException if an indicator with the given {@code name} * @throws IllegalStateException if an indicator with the given {@code name} is
* is already registered. * already registered.
* @deprecated since 2.1.0 in favour of * @deprecated since 2.1.0 in favour of
* {@link ReactiveHealthIndicatorRegistry#register(String, ReactiveHealthIndicator)} * {@link ReactiveHealthIndicatorRegistry#register(String, ReactiveHealthIndicator)}
*/ */
......
...@@ -43,10 +43,9 @@ public class DefaultHealthIndicatorRegistry implements HealthIndicatorRegistry { ...@@ -43,10 +43,9 @@ public class DefaultHealthIndicatorRegistry implements HealthIndicatorRegistry {
} }
/** /**
* Create a new {@link DefaultHealthIndicatorRegistry} from the specified * Create a new {@link DefaultHealthIndicatorRegistry} from the specified indicators.
* indicators. * @param healthIndicators a map of {@link HealthIndicator}s with the key being used
* @param healthIndicators a map of {@link HealthIndicator}s with the key * as an indicator name.
* being used as an indicator name.
*/ */
public DefaultHealthIndicatorRegistry(Map<String, HealthIndicator> healthIndicators) { public DefaultHealthIndicatorRegistry(Map<String, HealthIndicator> healthIndicators) {
Assert.notNull(healthIndicators, "HealthIndicators must not be null"); Assert.notNull(healthIndicators, "HealthIndicators must not be null");
......
...@@ -46,8 +46,8 @@ public class DefaultReactiveHealthIndicatorRegistry ...@@ -46,8 +46,8 @@ public class DefaultReactiveHealthIndicatorRegistry
/** /**
* Create a new {@link DefaultReactiveHealthIndicatorRegistry} from the specified * Create a new {@link DefaultReactiveHealthIndicatorRegistry} from the specified
* indicators. * indicators.
* @param healthIndicators a map of {@link HealthIndicator}s with the key * @param healthIndicators a map of {@link HealthIndicator}s with the key being used
* being used as an indicator name. * as an indicator name.
*/ */
public DefaultReactiveHealthIndicatorRegistry( public DefaultReactiveHealthIndicatorRegistry(
Map<String, ReactiveHealthIndicator> healthIndicators) { Map<String, ReactiveHealthIndicator> healthIndicators) {
......
...@@ -65,8 +65,8 @@ public class HealthEndpointWebExtension { ...@@ -65,8 +65,8 @@ public class HealthEndpointWebExtension {
public WebEndpointResponse<Health> healthForComponentInstance( public WebEndpointResponse<Health> healthForComponentInstance(
SecurityContext securityContext, @Selector String component, SecurityContext securityContext, @Selector String component,
@Selector String instance) { @Selector String instance) {
Supplier<Health> health = () -> this.delegate.healthForComponentInstance( Supplier<Health> health = () -> this.delegate
component, instance); .healthForComponentInstance(component, instance);
return this.responseMapper.mapDetails(health, securityContext); return this.responseMapper.mapDetails(health, securityContext);
} }
......
...@@ -31,36 +31,35 @@ import java.util.Map; ...@@ -31,36 +31,35 @@ import java.util.Map;
public interface HealthIndicatorRegistry { public interface HealthIndicatorRegistry {
/** /**
* Registers the given {@link HealthIndicator}, associating it with the * Registers the given {@link HealthIndicator}, associating it with the given
* given {@code name}. * {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @param healthIndicator the indicator * @param healthIndicator the indicator
* @throws IllegalStateException if an indicator with the given {@code name} * @throws IllegalStateException if an indicator with the given {@code name} is
* is already registered. * already registered.
*/ */
void register(String name, HealthIndicator healthIndicator); void register(String name, HealthIndicator healthIndicator);
/** /**
* Unregisters the {@link HealthIndicator} previously registered with the * Unregisters the {@link HealthIndicator} previously registered with the given
* given {@code name}. * {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @return the unregistered indicator, or {@code null} if no indicator was * @return the unregistered indicator, or {@code null} if no indicator was found in
* found in the registry for the given {@code name}. * the registry for the given {@code name}.
*/ */
HealthIndicator unregister(String name); HealthIndicator unregister(String name);
/** /**
* Returns the {@link HealthIndicator} registered with the given {@code name}. * Returns the {@link HealthIndicator} registered with the given {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @return the health indicator, or {@code null} if no indicator was * @return the health indicator, or {@code null} if no indicator was registered with
* registered with the given {@code name}. * the given {@code name}.
*/ */
HealthIndicator get(String name); HealthIndicator get(String name);
/** /**
* Returns a snapshot of the registered health indicators and their names. * Returns a snapshot of the registered health indicators and their names. The
* The contents of the map do not reflect subsequent changes to the * contents of the map do not reflect subsequent changes to the registry.
* registry.
* @return the snapshot of registered health indicators * @return the snapshot of registered health indicators
*/ */
Map<String, HealthIndicator> getAll(); Map<String, HealthIndicator> getAll();
......
...@@ -41,10 +41,8 @@ public class HealthIndicatorRegistryFactory { ...@@ -41,10 +41,8 @@ public class HealthIndicatorRegistryFactory {
} }
/** /**
* Create a {@link HealthIndicatorRegistry} based on the specified health * Create a {@link HealthIndicatorRegistry} based on the specified health indicators.
* indicators. * @param healthIndicators the {@link HealthIndicator} instances mapped by name
* @param healthIndicators the {@link HealthIndicator} instances mapped by
* name
* @return a {@link HealthIndicator} that delegates to the specified * @return a {@link HealthIndicator} that delegates to the specified
* {@code healthIndicators}. * {@code healthIndicators}.
*/ */
......
...@@ -31,12 +31,12 @@ import java.util.Map; ...@@ -31,12 +31,12 @@ import java.util.Map;
public interface ReactiveHealthIndicatorRegistry { public interface ReactiveHealthIndicatorRegistry {
/** /**
* Registers the given {@link ReactiveHealthIndicator}, associating it with the * Registers the given {@link ReactiveHealthIndicator}, associating it with the given
* given {@code name}. * {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @param healthIndicator the indicator * @param healthIndicator the indicator
* @throws IllegalStateException if an indicator with the given {@code name} * @throws IllegalStateException if an indicator with the given {@code name} is
* is already registered. * already registered.
*/ */
void register(String name, ReactiveHealthIndicator healthIndicator); void register(String name, ReactiveHealthIndicator healthIndicator);
...@@ -44,23 +44,22 @@ public interface ReactiveHealthIndicatorRegistry { ...@@ -44,23 +44,22 @@ public interface ReactiveHealthIndicatorRegistry {
* Unregisters the {@link ReactiveHealthIndicator} previously registered with the * Unregisters the {@link ReactiveHealthIndicator} previously registered with the
* given {@code name}. * given {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @return the unregistered indicator, or {@code null} if no indicator was * @return the unregistered indicator, or {@code null} if no indicator was found in
* found in the registry for the given {@code name}. * the registry for the given {@code name}.
*/ */
ReactiveHealthIndicator unregister(String name); ReactiveHealthIndicator unregister(String name);
/** /**
* Returns the {@link ReactiveHealthIndicator} registered with the given {@code name}. * Returns the {@link ReactiveHealthIndicator} registered with the given {@code name}.
* @param name the name of the indicator * @param name the name of the indicator
* @return the health indicator, or {@code null} if no indicator was * @return the health indicator, or {@code null} if no indicator was registered with
* registered with the given {@code name}. * the given {@code name}.
*/ */
ReactiveHealthIndicator get(String name); ReactiveHealthIndicator get(String name);
/** /**
* Returns a snapshot of the registered health indicators and their names. * Returns a snapshot of the registered health indicators and their names. The
* The contents of the map do not reflect subsequent changes to the * contents of the map do not reflect subsequent changes to the registry.
* registry.
* @return the snapshot of registered health indicators * @return the snapshot of registered health indicators
*/ */
Map<String, ReactiveHealthIndicator> getAll(); Map<String, ReactiveHealthIndicator> getAll();
......
...@@ -45,7 +45,7 @@ public class CompositeReactiveHealthIndicatorTests { ...@@ -45,7 +45,7 @@ public class CompositeReactiveHealthIndicatorTests {
public void singleIndicator() { public void singleIndicator() {
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator( CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(
this.healthAggregator, new DefaultReactiveHealthIndicatorRegistry( this.healthAggregator, new DefaultReactiveHealthIndicatorRegistry(
Collections.singletonMap("test", () -> Mono.just(HEALTHY)))); Collections.singletonMap("test", () -> Mono.just(HEALTHY))));
StepVerifier.create(indicator.health()).consumeNextWith((h) -> { StepVerifier.create(indicator.health()).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("test"); assertThat(h.getDetails()).containsOnlyKeys("test");
...@@ -64,9 +64,9 @@ public class CompositeReactiveHealthIndicatorTests { ...@@ -64,9 +64,9 @@ public class CompositeReactiveHealthIndicatorTests {
new DefaultReactiveHealthIndicatorRegistry(indicators)); new DefaultReactiveHealthIndicatorRegistry(indicators));
StepVerifier.withVirtualTime(indicator::health).expectSubscription() StepVerifier.withVirtualTime(indicator::health).expectSubscription()
.thenAwait(Duration.ofMillis(10000)).consumeNextWith((h) -> { .thenAwait(Duration.ofMillis(10000)).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).hasSize(50); assertThat(h.getDetails()).hasSize(50);
}).verifyComplete(); }).verifyComplete();
} }
...@@ -78,7 +78,7 @@ public class CompositeReactiveHealthIndicatorTests { ...@@ -78,7 +78,7 @@ public class CompositeReactiveHealthIndicatorTests {
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator( CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(
this.healthAggregator, this.healthAggregator,
new DefaultReactiveHealthIndicatorRegistry(indicators)) new DefaultReactiveHealthIndicatorRegistry(indicators))
.timeoutStrategy(100, UNKNOWN_HEALTH); .timeoutStrategy(100, UNKNOWN_HEALTH);
StepVerifier.create(indicator.health()).consumeNextWith((h) -> { StepVerifier.create(indicator.health()).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("slow", "fast"); assertThat(h.getDetails()).containsOnlyKeys("slow", "fast");
...@@ -95,14 +95,14 @@ public class CompositeReactiveHealthIndicatorTests { ...@@ -95,14 +95,14 @@ public class CompositeReactiveHealthIndicatorTests {
CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator( CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator(
this.healthAggregator, this.healthAggregator,
new DefaultReactiveHealthIndicatorRegistry(indicators)) new DefaultReactiveHealthIndicatorRegistry(indicators))
.timeoutStrategy(20000, null); .timeoutStrategy(20000, null);
StepVerifier.withVirtualTime(indicator::health).expectSubscription() StepVerifier.withVirtualTime(indicator::health).expectSubscription()
.thenAwait(Duration.ofMillis(10000)).consumeNextWith((h) -> { .thenAwait(Duration.ofMillis(10000)).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("slow", "fast"); assertThat(h.getDetails()).containsOnlyKeys("slow", "fast");
assertThat(h.getDetails().get("slow")).isEqualTo(HEALTHY); assertThat(h.getDetails().get("slow")).isEqualTo(HEALTHY);
assertThat(h.getDetails().get("fast")).isEqualTo(HEALTHY); assertThat(h.getDetails().get("fast")).isEqualTo(HEALTHY);
}).verifyComplete(); }).verifyComplete();
} }
static class TimeoutHealth implements ReactiveHealthIndicator { static class TimeoutHealth implements ReactiveHealthIndicator {
......
...@@ -47,10 +47,10 @@ public class DefaultReactiveHealthIndicatorRegistryTests { ...@@ -47,10 +47,10 @@ public class DefaultReactiveHealthIndicatorRegistryTests {
@Before @Before
public void setUp() { public void setUp() {
given(this.one.health()).willReturn(Mono.just( given(this.one.health()).willReturn(
new Health.Builder().unknown().withDetail("1", "1").build())); Mono.just(new Health.Builder().unknown().withDetail("1", "1").build()));
given(this.two.health()).willReturn(Mono.just( given(this.two.health()).willReturn(
new Health.Builder().unknown().withDetail("2", "2").build())); Mono.just(new Health.Builder().unknown().withDetail("2", "2").build()));
this.registry = new DefaultReactiveHealthIndicatorRegistry(); this.registry = new DefaultReactiveHealthIndicatorRegistry();
} }
......
...@@ -59,8 +59,8 @@ public class HealthEndpointTests { ...@@ -59,8 +59,8 @@ public class HealthEndpointTests {
@Test @Test
public void statusForComponentIsExposed() { public void statusForComponentIsExposed() {
HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( HealthEndpoint endpoint = new HealthEndpoint(
Collections.singletonMap("test", one))); createHealthIndicator(Collections.singletonMap("test", one)));
Health health = endpoint.healthForComponent("test"); Health health = endpoint.healthForComponent("test");
assertThat(health).isNotNull(); assertThat(health).isNotNull();
assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getStatus()).isEqualTo(Status.UP);
...@@ -69,8 +69,8 @@ public class HealthEndpointTests { ...@@ -69,8 +69,8 @@ public class HealthEndpointTests {
@Test @Test
public void statusForUnknownComponentReturnNull() { public void statusForUnknownComponentReturnNull() {
HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( HealthEndpoint endpoint = new HealthEndpoint(
Collections.emptyMap())); createHealthIndicator(Collections.emptyMap()));
Health health = endpoint.healthForComponent("does-not-exist"); Health health = endpoint.healthForComponent("does-not-exist");
assertThat(health).isNull(); assertThat(health).isNull();
} }
...@@ -79,7 +79,7 @@ public class HealthEndpointTests { ...@@ -79,7 +79,7 @@ public class HealthEndpointTests {
public void statusForComponentInstanceIsExposed() { public void statusForComponentInstanceIsExposed() {
CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator( CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator(
new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry( new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry(
Collections.singletonMap("sub", () -> Health.down().build()))); Collections.singletonMap("sub", () -> Health.down().build())));
HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator(
Collections.singletonMap("test", compositeIndicator))); Collections.singletonMap("test", compositeIndicator)));
Health health = endpoint.healthForComponentInstance("test", "sub"); Health health = endpoint.healthForComponentInstance("test", "sub");
...@@ -92,7 +92,7 @@ public class HealthEndpointTests { ...@@ -92,7 +92,7 @@ public class HealthEndpointTests {
public void statusForUnknownComponentInstanceReturnNull() { public void statusForUnknownComponentInstanceReturnNull() {
CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator( CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator(
new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry( new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry(
Collections.singletonMap("sub", () -> Health.down().build()))); Collections.singletonMap("sub", () -> Health.down().build())));
HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator(
Collections.singletonMap("test", compositeIndicator))); Collections.singletonMap("test", compositeIndicator)));
Health health = endpoint.healthForComponentInstance("test", "does-not-exist"); Health health = endpoint.healthForComponentInstance("test", "does-not-exist");
......
...@@ -56,9 +56,9 @@ public class HealthEndpointWebIntegrationTests { ...@@ -56,9 +56,9 @@ public class HealthEndpointWebIntegrationTests {
registry.register("charlie", () -> Health.down().build()); registry.register("charlie", () -> Health.down().build());
try { try {
client.get().uri("/actuator/health").exchange().expectStatus() client.get().uri("/actuator/health").exchange().expectStatus()
.isEqualTo(HttpStatus.SERVICE_UNAVAILABLE).expectBody().jsonPath("status") .isEqualTo(HttpStatus.SERVICE_UNAVAILABLE).expectBody()
.isEqualTo("DOWN").jsonPath("details.alpha.status").isEqualTo("UP") .jsonPath("status").isEqualTo("DOWN").jsonPath("details.alpha.status")
.jsonPath("details.bravo.status").isEqualTo("UP") .isEqualTo("UP").jsonPath("details.bravo.status").isEqualTo("UP")
.jsonPath("details.charlie.status").isEqualTo("DOWN"); .jsonPath("details.charlie.status").isEqualTo("DOWN");
} }
finally { finally {
...@@ -71,9 +71,10 @@ public class HealthEndpointWebIntegrationTests { ...@@ -71,9 +71,10 @@ public class HealthEndpointWebIntegrationTests {
HealthIndicatorRegistry registry = context.getBean(HealthIndicatorRegistry.class); HealthIndicatorRegistry registry = context.getBean(HealthIndicatorRegistry.class);
HealthIndicator bravo = registry.unregister("bravo"); HealthIndicator bravo = registry.unregister("bravo");
try { try {
client.get().uri("/actuator/health").exchange().expectStatus().isOk().expectBody() client.get().uri("/actuator/health").exchange().expectStatus().isOk()
.jsonPath("status").isEqualTo("UP").jsonPath("details.alpha.status") .expectBody().jsonPath("status").isEqualTo("UP")
.isEqualTo("UP").jsonPath("details.bravo.status").doesNotExist(); .jsonPath("details.alpha.status").isEqualTo("UP")
.jsonPath("details.bravo.status").doesNotExist();
} }
finally { finally {
registry.register("bravo", bravo); registry.register("bravo", bravo);
......
...@@ -62,7 +62,8 @@ public class HealthWebEndpointResponseMapperTests { ...@@ -62,7 +62,8 @@ public class HealthWebEndpointResponseMapperTests {
@Test @Test
public void mapDetailsWithUnauthorizedUserDoesNotInvokeSupplier() { public void mapDetailsWithUnauthorizedUserDoesNotInvokeSupplier() {
HealthWebEndpointResponseMapper mapper = createMapper(ShowDetails.WHEN_AUTHORIZED); HealthWebEndpointResponseMapper mapper = createMapper(
ShowDetails.WHEN_AUTHORIZED);
Supplier<Health> supplier = mockSupplier(); Supplier<Health> supplier = mockSupplier();
SecurityContext securityContext = mockSecurityContext("USER"); SecurityContext securityContext = mockSecurityContext("USER");
WebEndpointResponse<Health> response = mapper.mapDetails(supplier, WebEndpointResponse<Health> response = mapper.mapDetails(supplier,
...@@ -75,13 +76,15 @@ public class HealthWebEndpointResponseMapperTests { ...@@ -75,13 +76,15 @@ public class HealthWebEndpointResponseMapperTests {
@Test @Test
public void mapDetailsWithAuthorizedUserInvokeSupplier() { public void mapDetailsWithAuthorizedUserInvokeSupplier() {
HealthWebEndpointResponseMapper mapper = createMapper(ShowDetails.WHEN_AUTHORIZED); HealthWebEndpointResponseMapper mapper = createMapper(
ShowDetails.WHEN_AUTHORIZED);
Supplier<Health> supplier = mockSupplier(); Supplier<Health> supplier = mockSupplier();
given(supplier.get()).willReturn(Health.down().build()); given(supplier.get()).willReturn(Health.down().build());
SecurityContext securityContext = mockSecurityContext("ACTUATOR"); SecurityContext securityContext = mockSecurityContext("ACTUATOR");
WebEndpointResponse<Health> response = mapper.mapDetails(supplier, WebEndpointResponse<Health> response = mapper.mapDetails(supplier,
securityContext); securityContext);
assertThat(response.getStatus()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value()); assertThat(response.getStatus())
.isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value());
assertThat(response.getBody().getStatus()).isEqualTo(Status.DOWN); assertThat(response.getBody().getStatus()).isEqualTo(Status.DOWN);
verify(supplier).get(); verify(supplier).get();
verify(securityContext).isUserInRole("ACTUATOR"); verify(securityContext).isUserInRole("ACTUATOR");
...@@ -108,12 +111,12 @@ public class HealthWebEndpointResponseMapperTests { ...@@ -108,12 +111,12 @@ public class HealthWebEndpointResponseMapperTests {
private SecurityContext mockSecurityContext(String... roles) { private SecurityContext mockSecurityContext(String... roles) {
List<String> associatedRoles = Arrays.asList(roles); List<String> associatedRoles = Arrays.asList(roles);
SecurityContext securityContext = mock(SecurityContext.class); SecurityContext securityContext = mock(SecurityContext.class);
given(securityContext.getPrincipal()) given(securityContext.getPrincipal()).willReturn(mock(Principal.class));
.willReturn(mock(Principal.class)); given(securityContext.isUserInRole(anyString()))
given(securityContext.isUserInRole(anyString())).will((Answer<Boolean>) invocation -> { .will((Answer<Boolean>) invocation -> {
String expectedRole = invocation.getArgument(0); String expectedRole = invocation.getArgument(0);
return associatedRoles.contains(expectedRole); return associatedRoles.contains(expectedRole);
}); });
return securityContext; return securityContext;
} }
......
...@@ -39,16 +39,18 @@ public class ReactiveHealthIndicatorRegistryFactoryTests { ...@@ -39,16 +39,18 @@ public class ReactiveHealthIndicatorRegistryFactoryTests {
@Test @Test
public void defaultHealthIndicatorNameFactory() { public void defaultHealthIndicatorNameFactory() {
ReactiveHealthIndicatorRegistry registry = this.factory.createReactiveHealthIndicatorRegistry( ReactiveHealthIndicatorRegistry registry = this.factory
Collections.singletonMap("myHealthIndicator", () -> Mono.just(UP)), null); .createReactiveHealthIndicatorRegistry(Collections
.singletonMap("myHealthIndicator", () -> Mono.just(UP)), null);
assertThat(registry.getAll()).containsOnlyKeys("my"); assertThat(registry.getAll()).containsOnlyKeys("my");
} }
@Test @Test
public void healthIndicatorIsAdapted() { public void healthIndicatorIsAdapted() {
ReactiveHealthIndicatorRegistry registry = this.factory.createReactiveHealthIndicatorRegistry( ReactiveHealthIndicatorRegistry registry = this.factory
Collections.singletonMap("test", () -> Mono.just(UP)), .createReactiveHealthIndicatorRegistry(
Collections.singletonMap("regular", () -> DOWN)); Collections.singletonMap("test", () -> Mono.just(UP)),
Collections.singletonMap("regular", () -> DOWN));
assertThat(registry.getAll()).containsOnlyKeys("test", "regular"); assertThat(registry.getAll()).containsOnlyKeys("test", "regular");
StepVerifier.create(registry.get("regular").health()).consumeNextWith((h) -> { StepVerifier.create(registry.get("regular").health()).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.DOWN); assertThat(h.getStatus()).isEqualTo(Status.DOWN);
......
...@@ -34,4 +34,5 @@ public interface RestClientBuilderCustomizer { ...@@ -34,4 +34,5 @@ public interface RestClientBuilderCustomizer {
* @param builder the builder to customize * @param builder the builder to customize
*/ */
void customize(RestClientBuilder builder); void customize(RestClientBuilder builder);
} }
...@@ -47,8 +47,6 @@ public class RestClientProperties { ...@@ -47,8 +47,6 @@ public class RestClientProperties {
*/ */
private String password; private String password;
public List<String> getUris() { public List<String> getUris() {
return this.uris; return this.uris;
} }
...@@ -72,4 +70,5 @@ public class RestClientProperties { ...@@ -72,4 +70,5 @@ public class RestClientProperties {
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
} }
...@@ -72,8 +72,8 @@ public class JestAutoConfigurationTests { ...@@ -72,8 +72,8 @@ public class JestAutoConfigurationTests {
@Test @Test
public void jestClientOnLocalhostByDefault() { public void jestClientOnLocalhostByDefault() {
this.contextRunner.run((context) -> this.contextRunner
assertThat(context).hasSingleBean(JestClient.class)); .run((context) -> assertThat(context).hasSingleBean(JestClient.class));
} }
@Test @Test
...@@ -130,11 +130,12 @@ public class JestAutoConfigurationTests { ...@@ -130,11 +130,12 @@ public class JestAutoConfigurationTests {
Map<String, String> source = new HashMap<>(); Map<String, String> source = new HashMap<>();
source.put("a", "alpha"); source.put("a", "alpha");
source.put("b", "bravo"); source.put("b", "bravo");
Index index = new Index.Builder(source).index("foo") Index index = new Index.Builder(source).index("foo").type("bar")
.type("bar").id("1").build(); .id("1").build();
execute(client, index); execute(client, index);
Get getRequest = new Get.Builder("foo", "1").build(); Get getRequest = new Get.Builder("foo", "1").build();
assertThat(execute(client, getRequest).getResponseCode()).isEqualTo(200); assertThat(execute(client, getRequest).getResponseCode())
.isEqualTo(200);
})); }));
} }
......
...@@ -100,6 +100,7 @@ public class RestClientAutoConfigurationTests { ...@@ -100,6 +100,7 @@ public class RestClientAutoConfigurationTests {
public RestClient customRestClient() { public RestClient customRestClient() {
return mock(RestClient.class); return mock(RestClient.class);
} }
} }
@Configuration @Configuration
...@@ -109,6 +110,7 @@ public class RestClientAutoConfigurationTests { ...@@ -109,6 +110,7 @@ public class RestClientAutoConfigurationTests {
public RestClientBuilderCustomizer myCustomizer() { public RestClientBuilderCustomizer myCustomizer() {
return (builder) -> builder.setMaxRetryTimeoutMillis(42); return (builder) -> builder.setMaxRetryTimeoutMillis(42);
} }
} }
} }
...@@ -181,15 +181,13 @@ public class LiquibaseAutoConfigurationTests { ...@@ -181,15 +181,13 @@ public class LiquibaseAutoConfigurationTests {
@Test @Test
public void overrideTestRollbackOnUpdate() { public void overrideTestRollbackOnUpdate() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues( .withPropertyValues("spring.liquibase.test-rollback-on-update:true")
"spring.liquibase.test-rollback-on-update:true")
.run((context) -> { .run((context) -> {
SpringLiquibase liquibase = context.getBean(SpringLiquibase.class); SpringLiquibase liquibase = context.getBean(SpringLiquibase.class);
assertThat(liquibase.isTestRollbackOnUpdate()).isTrue(); assertThat(liquibase.isTestRollbackOnUpdate()).isTrue();
}); });
} }
@Test @Test
public void changeLogDoesNotExist() { public void changeLogDoesNotExist() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
......
...@@ -43,8 +43,7 @@ public class WebMvcTestPageableIntegrationTests { ...@@ -43,8 +43,7 @@ public class WebMvcTestPageableIntegrationTests {
@Test @Test
public void shouldSupportPageable() throws Exception { public void shouldSupportPageable() throws Exception {
this.mvc.perform(get("/paged").param("page", "2").param("size", "42")) this.mvc.perform(get("/paged").param("page", "2").param("size", "42"))
.andExpect(status().isOk()) .andExpect(status().isOk()).andExpect(content().string("2:42"));
.andExpect(content().string("2:42"));
} }
} }
...@@ -267,7 +267,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { ...@@ -267,7 +267,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
+ "]"); + "]");
} }
if (hasWorkingDirectorySet()) { if (hasWorkingDirectorySet()) {
getLog().warn("Fork mode disabled, ignoring working directory configuration"); getLog().warn(
"Fork mode disabled, ignoring working directory configuration");
} }
} }
} }
...@@ -475,7 +476,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { ...@@ -475,7 +476,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private void logArguments(String message, String[] args) { private void logArguments(String message, String[] args) {
if (getLog().isDebugEnabled()) { if (getLog().isDebugEnabled()) {
getLog().debug(Arrays.stream(args).collect(Collectors.joining(" ", message, ""))); getLog().debug(
Arrays.stream(args).collect(Collectors.joining(" ", message, "")));
} }
} }
......
...@@ -229,9 +229,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { ...@@ -229,9 +229,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
} }
/** /**
* Return the source {@link Artifact} to repackage. If a classifier is specified * Return the source {@link Artifact} to repackage. If a classifier is specified and
* and an artifact with that classifier exists, it is used. Otherwise, the main * an artifact with that classifier exists, it is used. Otherwise, the main artifact
* artifact is used. * is used.
* @return the source artifact to repackage * @return the source artifact to repackage
*/ */
private Artifact getSourceArtifact() { private Artifact getSourceArtifact() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment