From 3702da4573fde4a06bcc25f731e256a2a2b68940 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 25 May 2018 23:52:38 -0700 Subject: [PATCH] Formatting --- ...eReactiveHealthIndicatorConfiguration.java | 4 +- .../HealthIndicatorAutoConfiguration.java | 8 +- .../metrics/PropertiesMeterFilter.java | 8 +- ...loudFoundryWebEndpointDiscovererTests.java | 4 +- .../HealthEndpointDocumentationTests.java | 14 +- .../HealthEndpointWebExtensionTests.java | 123 +++++++++--------- ...activeHealthEndpointWebExtensionTests.java | 7 +- ...ricsAutoConfigurationIntegrationTests.java | 5 +- .../boot/actuate/cache/CachesEndpoint.java | 4 +- .../health/CompositeHealthIndicator.java | 18 ++- .../CompositeHealthIndicatorFactory.java | 4 +- .../CompositeReactiveHealthIndicator.java | 4 +- .../DefaultHealthIndicatorRegistry.java | 7 +- ...efaultReactiveHealthIndicatorRegistry.java | 4 +- .../health/HealthEndpointWebExtension.java | 4 +- .../health/HealthIndicatorRegistry.java | 25 ++-- .../HealthIndicatorRegistryFactory.java | 6 +- .../ReactiveHealthIndicatorRegistry.java | 21 ++- ...CompositeReactiveHealthIndicatorTests.java | 22 ++-- ...tReactiveHealthIndicatorRegistryTests.java | 8 +- .../actuate/health/HealthEndpointTests.java | 12 +- .../HealthEndpointWebIntegrationTests.java | 13 +- .../HealthWebEndpointResponseMapperTests.java | 21 +-- ...veHealthIndicatorRegistryFactoryTests.java | 12 +- .../rest/RestClientBuilderCustomizer.java | 1 + .../rest/RestClientProperties.java | 3 +- .../jest/JestAutoConfigurationTests.java | 11 +- .../RestClientAutoConfigurationTests.java | 2 + .../LiquibaseAutoConfigurationTests.java | 4 +- .../WebMvcTestPageableIntegrationTests.java | 3 +- .../boot/maven/AbstractRunMojo.java | 6 +- .../boot/maven/RepackageMojo.java | 6 +- 32 files changed, 195 insertions(+), 199 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthIndicatorConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthIndicatorConfiguration.java index 5acd02925e9..748c80bc839 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthIndicatorConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthIndicatorConfiguration.java @@ -44,8 +44,8 @@ public abstract class CompositeReactiveHealthIndicatorConfiguration registry.register(name, - createHealthIndicator(source))); + beans.forEach( + (name, source) -> registry.register(name, createHealthIndicator(source))); return new CompositeReactiveHealthIndicator(this.healthAggregator, registry); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java index 43ac74cbf98..f9357967d1a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java @@ -89,9 +89,11 @@ public class HealthIndicatorAutoConfiguration { public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry( ObjectProvider> reactiveHealthIndicators, ObjectProvider> healthIndicators) { - return new ReactiveHealthIndicatorRegistryFactory().createReactiveHealthIndicatorRegistry( - reactiveHealthIndicators.getIfAvailable(Collections::emptyMap), - healthIndicators.getIfAvailable(Collections::emptyMap)); + return new ReactiveHealthIndicatorRegistryFactory() + .createReactiveHealthIndicatorRegistry( + reactiveHealthIndicators + .getIfAvailable(Collections::emptyMap), + healthIndicators.getIfAvailable(Collections::emptyMap)); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java index 85b40cab78b..01a60810fd1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java @@ -57,10 +57,12 @@ public class PropertiesMeterFilter implements MeterFilter { private static MeterFilter createMapFilter(Map tags) { if (tags.isEmpty()) { - return new MeterFilter() { }; + return new MeterFilter() { + }; } - Tags commonTags = Tags.of(tags.entrySet().stream().map((entry) -> - Tag.of(entry.getKey(), entry.getValue())).collect(Collectors.toList())); + Tags commonTags = Tags.of(tags.entrySet().stream() + .map((entry) -> Tag.of(entry.getKey(), entry.getValue())) + .collect(Collectors.toList())); return MeterFilter.commonTags(commonTags); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java index 2d381360f5f..1e771977002 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscovererTests.java @@ -73,8 +73,8 @@ public class CloudFoundryWebEndpointDiscovererTests { return operation; } } - throw new IllegalStateException("No main read operation found from " - + endpoint.getOperations()); + throw new IllegalStateException( + "No main read operation found from " + endpoint.getOperations()); } private void load(Class configuration, diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java index 2e51aabb7c6..3b66e3d564c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java @@ -61,8 +61,7 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati fieldWithPath("status") .description("Status of a specific part of the application"), subsectionWithPath("details").description( - "Details of the health of a specific part of the" - + " application.")); + "Details of the health of a specific part of the" + " application.")); @Test public void health() throws Exception { @@ -111,18 +110,17 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati } @Bean - public DataSourceHealthIndicator dbHealthIndicator( - DataSource dataSource) { + public DataSourceHealthIndicator dbHealthIndicator(DataSource dataSource) { return new DataSourceHealthIndicator(dataSource); } @Bean public CompositeHealthIndicator brokerHealthIndicator() { Map indicators = new LinkedHashMap<>(); - indicators.put("us1", () -> Health.up().withDetail("version", "1.0.2") - .build()); - indicators.put("us2", () -> Health.up().withDetail("version", "1.0.4") - .build()); + indicators.put("us1", + () -> Health.up().withDetail("version", "1.0.2").build()); + indicators.put("us2", + () -> Health.up().withDetail("version", "1.0.4").build()); return new CompositeHealthIndicator(new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry(indicators)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java index 13f7e612e9d..625c3b7989f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java @@ -53,8 +53,7 @@ import static org.mockito.Mockito.mock; public class HealthEndpointWebExtensionTests { private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(HealthIndicatorsConfiguration.class) - .withConfiguration( + .withUserConfiguration(HealthIndicatorsConfiguration.class).withConfiguration( AutoConfigurations.of(HealthIndicatorAutoConfiguration.class, HealthEndpointAutoConfiguration.class)); @@ -96,8 +95,9 @@ public class HealthEndpointWebExtensionTests { this.contextRunner.run((context) -> { HealthEndpointWebExtension extension = context .getBean(HealthEndpointWebExtension.class); - assertThat(extension.health(mock(SecurityContext.class)).getBody() - .getDetails()).isEmpty(); + assertThat( + extension.health(mock(SecurityContext.class)).getBody().getDetails()) + .isEmpty(); }); } @@ -124,9 +124,8 @@ public class HealthEndpointWebExtensionTests { SecurityContext securityContext = mock(SecurityContext.class); given(securityContext.getPrincipal()) .willReturn(mock(Principal.class)); - assertThat( - extension.health(securityContext).getBody().getDetails()) - .isNotEmpty(); + assertThat(extension.health(securityContext).getBody().getDetails()) + .isNotEmpty(); }); } @@ -165,9 +164,8 @@ public class HealthEndpointWebExtensionTests { given(securityContext.getPrincipal()) .willReturn(mock(Principal.class)); given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); - assertThat( - extension.health(securityContext).getBody().getDetails()) - .isEmpty(); + assertThat(extension.health(securityContext).getBody().getDetails()) + .isEmpty(); }); } @@ -182,9 +180,8 @@ public class HealthEndpointWebExtensionTests { given(securityContext.getPrincipal()) .willReturn(mock(Principal.class)); given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); - assertThat( - extension.health(securityContext).getBody().getDetails()) - .isNotEmpty(); + assertThat(extension.health(securityContext).getBody().getDetails()) + .isNotEmpty(); }); } @@ -193,8 +190,8 @@ public class HealthEndpointWebExtensionTests { this.contextRunner.run((context) -> { HealthEndpointWebExtension extension = context .getBean(HealthEndpointWebExtension.class); - assertDetailsNotFound(extension.healthForComponent( - mock(SecurityContext.class), "simple")); + assertDetailsNotFound( + extension.healthForComponent(mock(SecurityContext.class), "simple")); }); } @@ -205,8 +202,8 @@ public class HealthEndpointWebExtensionTests { .getBean(HealthEndpointWebExtension.class); SecurityContext securityContext = mock(SecurityContext.class); given(securityContext.getPrincipal()).willReturn(mock(Principal.class)); - assertDetailsNotFound(extension.healthForComponent(securityContext, - "simple")); + assertDetailsNotFound( + extension.healthForComponent(securityContext, "simple")); }); } @@ -221,8 +218,8 @@ public class HealthEndpointWebExtensionTests { SecurityContext securityContext = mock(SecurityContext.class); given(securityContext.getPrincipal()) .willReturn(mock(Principal.class)); - assertSimpleComponent(extension.healthForComponent( - securityContext, "simple")); + assertSimpleComponent( + extension.healthForComponent(securityContext, "simple")); }); } @@ -244,8 +241,8 @@ public class HealthEndpointWebExtensionTests { .run((context) -> { HealthEndpointWebExtension extension = context .getBean(HealthEndpointWebExtension.class); - assertDetailsNotFound(extension.healthForComponent( - mock(SecurityContext.class), "simple")); + assertDetailsNotFound(extension + .healthForComponent(mock(SecurityContext.class), "simple")); }); } @@ -254,15 +251,15 @@ public class HealthEndpointWebExtensionTests { this.contextRunner.withPropertyValues( "management.endpoint.health.show-details=when-authorized", "management.endpoint.health.roles=ACTUATOR").run((context) -> { - HealthEndpointWebExtension extension = context - .getBean(HealthEndpointWebExtension.class); - SecurityContext securityContext = mock(SecurityContext.class); - given(securityContext.getPrincipal()) - .willReturn(mock(Principal.class)); - given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); - assertDetailsNotFound(extension.healthForComponent(securityContext, - "simple")); - }); + HealthEndpointWebExtension extension = context + .getBean(HealthEndpointWebExtension.class); + SecurityContext securityContext = mock(SecurityContext.class); + given(securityContext.getPrincipal()) + .willReturn(mock(Principal.class)); + given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); + assertDetailsNotFound( + extension.healthForComponent(securityContext, "simple")); + }); } @Test @@ -270,15 +267,15 @@ public class HealthEndpointWebExtensionTests { this.contextRunner.withPropertyValues( "management.endpoint.health.show-details=when-authorized", "management.endpoint.health.roles=ACTUATOR").run((context) -> { - HealthEndpointWebExtension extension = context - .getBean(HealthEndpointWebExtension.class); - SecurityContext securityContext = mock(SecurityContext.class); - given(securityContext.getPrincipal()) - .willReturn(mock(Principal.class)); - given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); - assertSimpleComponent(extension.healthForComponent(securityContext, - "simple")); - }); + HealthEndpointWebExtension extension = context + .getBean(HealthEndpointWebExtension.class); + SecurityContext securityContext = mock(SecurityContext.class); + given(securityContext.getPrincipal()) + .willReturn(mock(Principal.class)); + given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); + assertSimpleComponent( + extension.healthForComponent(securityContext, "simple")); + }); } @Test @@ -288,8 +285,8 @@ public class HealthEndpointWebExtensionTests { .run((context) -> { HealthEndpointWebExtension extension = context .getBean(HealthEndpointWebExtension.class); - assertDetailsNotFound(extension.healthForComponent(null, - "does-not-exist")); + assertDetailsNotFound( + extension.healthForComponent(null, "does-not-exist")); }); } @@ -360,15 +357,15 @@ public class HealthEndpointWebExtensionTests { this.contextRunner.withPropertyValues( "management.endpoint.health.show-details=when-authorized", "management.endpoint.health.roles=ACTUATOR").run((context) -> { - HealthEndpointWebExtension extension = context - .getBean(HealthEndpointWebExtension.class); - SecurityContext securityContext = mock(SecurityContext.class); - given(securityContext.getPrincipal()) - .willReturn(mock(Principal.class)); - given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); - assertDetailsNotFound(extension.healthForComponentInstance(securityContext, - "composite", "one")); - }); + HealthEndpointWebExtension extension = context + .getBean(HealthEndpointWebExtension.class); + SecurityContext securityContext = mock(SecurityContext.class); + given(securityContext.getPrincipal()) + .willReturn(mock(Principal.class)); + given(securityContext.isUserInRole("ACTUATOR")).willReturn(false); + assertDetailsNotFound(extension.healthForComponentInstance( + securityContext, "composite", "one")); + }); } @Test @@ -376,15 +373,15 @@ public class HealthEndpointWebExtensionTests { this.contextRunner.withPropertyValues( "management.endpoint.health.show-details=when-authorized", "management.endpoint.health.roles=ACTUATOR").run((context) -> { - HealthEndpointWebExtension extension = context - .getBean(HealthEndpointWebExtension.class); - SecurityContext securityContext = mock(SecurityContext.class); - given(securityContext.getPrincipal()) - .willReturn(mock(Principal.class)); - given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); - assertSimpleComponent(extension.healthForComponentInstance(securityContext, - "composite", "one")); - }); + HealthEndpointWebExtension extension = context + .getBean(HealthEndpointWebExtension.class); + SecurityContext securityContext = mock(SecurityContext.class); + given(securityContext.getPrincipal()) + .willReturn(mock(Principal.class)); + given(securityContext.isUserInRole("ACTUATOR")).willReturn(true); + assertSimpleComponent(extension.healthForComponentInstance( + securityContext, "composite", "one")); + }); } @Test @@ -406,8 +403,7 @@ public class HealthEndpointWebExtensionTests { private void assertSimpleComponent(WebEndpointResponse response) { assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); - assertThat(response.getBody().getDetails()).containsOnly( - entry("counter", 42)); + assertThat(response.getBody().getDetails()).containsOnly(entry("counter", 42)); } @Test @@ -421,9 +417,8 @@ public class HealthEndpointWebExtensionTests { given(securityContext.getPrincipal()) .willReturn(mock(Principal.class)); given(securityContext.isUserInRole("ADMIN")).willReturn(true); - assertThat( - extension.health(securityContext).getBody().getDetails()) - .isNotEmpty(); + assertThat(extension.health(securityContext).getBody().getDetails()) + .isNotEmpty(); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointWebExtensionTests.java index 873a4a61180..f2bbde29540 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointWebExtensionTests.java @@ -220,12 +220,11 @@ public class ReactiveHealthEndpointWebExtensionTests { @Test public void registryCanBeAltered() { - this.contextRunner - .withUserConfiguration(HealthIndicatorsConfiguration.class) + this.contextRunner.withUserConfiguration(HealthIndicatorsConfiguration.class) .withPropertyValues("management.endpoint.health.show-details=always") .run((context) -> { - ReactiveHealthIndicatorRegistry registry = context.getBean( - ReactiveHealthIndicatorRegistry.class); + ReactiveHealthIndicatorRegistry registry = context + .getBean(ReactiveHealthIndicatorRegistry.class); ReactiveHealthEndpointWebExtension extension = context .getBean(ReactiveHealthEndpointWebExtension.class); assertThat(extension.health(null).block().getBody().getDetails()) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationIntegrationTests.java index 18999833803..d185e9a0e69 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfigurationIntegrationTests.java @@ -58,13 +58,12 @@ public class MetricsAutoConfigurationIntegrationTests { @Test public void propertyBasedCommonTagsIsAutoConfigured() { this.contextRunner.withPropertyValues("management.metrics.tags.region=test", - "management.metrics.tags.origin=local") - .run((context) -> { + "management.metrics.tags.origin=local").run((context) -> { MeterRegistry registry = context.getBean(MeterRegistry.class); registry.counter("my.counter", "env", "qa"); assertThat(registry.find("my.counter").tags("env", "qa") .tags("region", "test").tags("origin", "local").counter()) - .isNotNull(); + .isNotNull(); }); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java index afcdc0c8b42..62b5c43635b 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CachesEndpoint.java @@ -68,8 +68,8 @@ public class CachesEndpoint { new CacheDescriptor(entry.getTarget())); }); Map cacheManagerDescriptors = new LinkedHashMap<>(); - descriptors.forEach((name, entries) -> - cacheManagerDescriptors.put(name, new CacheManagerDescriptor(entries))); + descriptors.forEach((name, entries) -> cacheManagerDescriptors.put(name, + new CacheManagerDescriptor(entries))); return new CachesReport(cacheManagerDescriptors); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java index 04cb30f35d0..804eb2be025 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java @@ -45,11 +45,10 @@ public class CompositeHealthIndicator implements HealthIndicator { } /** - * Create a new {@link CompositeHealthIndicator} from the specified - * indicators. + * Create a new {@link CompositeHealthIndicator} from the specified indicators. * @param healthAggregator the health aggregator - * @param indicators a map of {@link HealthIndicator HealthIndicators} with - * the key being used as an indicator name. + * @param indicators a map of {@link HealthIndicator HealthIndicators} with the key + * being used as an indicator name. * @deprecated since 2.1.0 in favour of * {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)} */ @@ -60,8 +59,8 @@ public class CompositeHealthIndicator implements HealthIndicator { } /** - * Create a new {@link CompositeHealthIndicator} from the indicators in the - * given {@code registry}. + * Create a new {@link CompositeHealthIndicator} from the indicators in the given + * {@code registry}. * @param healthAggregator the health aggregator * @param registry the registry of {@link HealthIndicator HealthIndicators}. */ @@ -72,12 +71,11 @@ public class CompositeHealthIndicator implements HealthIndicator { } /** - * Adds the given {@code healthIndicator}, associating it with the given - * {@code name}. + * Adds the given {@code healthIndicator}, associating it with the given {@code name}. * @param name the name of the indicator * @param indicator the indicator - * @throws IllegalStateException if an indicator with the given {@code name} - * is already registered. + * @throws IllegalStateException if an indicator with the given {@code name} is + * already registered. * @deprecated since 2.1.0 in favour of * {@link HealthIndicatorRegistry#register(String, HealthIndicator)} */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorFactory.java index 8d0c44dac98..f6bcc96bcec 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorFactory.java @@ -57,8 +57,8 @@ public class CompositeHealthIndicatorFactory { Assert.notNull(healthIndicators, "HealthIndicators must not be null"); HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory( this.healthIndicatorNameFactory); - return new CompositeHealthIndicator( - healthAggregator, factory.createHealthIndicatorRegistry(healthIndicators)); + return new CompositeHealthIndicator(healthAggregator, + factory.createHealthIndicatorRegistry(healthIndicators)); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java index a6d291fa6d9..e1c4858bb41 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java @@ -91,8 +91,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator * @param name the name of the health indicator * @param indicator the health indicator to add * @return this instance - * @throws IllegalStateException if an indicator with the given {@code name} - * is already registered. + * @throws IllegalStateException if an indicator with the given {@code name} is + * already registered. * @deprecated since 2.1.0 in favour of * {@link ReactiveHealthIndicatorRegistry#register(String, ReactiveHealthIndicator)} */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultHealthIndicatorRegistry.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultHealthIndicatorRegistry.java index a1296460479..38b9cb7c7e0 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultHealthIndicatorRegistry.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultHealthIndicatorRegistry.java @@ -43,10 +43,9 @@ public class DefaultHealthIndicatorRegistry implements HealthIndicatorRegistry { } /** - * Create a new {@link DefaultHealthIndicatorRegistry} from the specified - * indicators. - * @param healthIndicators a map of {@link HealthIndicator}s with the key - * being used as an indicator name. + * Create a new {@link DefaultHealthIndicatorRegistry} from the specified indicators. + * @param healthIndicators a map of {@link HealthIndicator}s with the key being used + * as an indicator name. */ public DefaultHealthIndicatorRegistry(Map healthIndicators) { Assert.notNull(healthIndicators, "HealthIndicators must not be null"); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistry.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistry.java index 1b9d9145ebc..4bc2aca3198 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistry.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistry.java @@ -46,8 +46,8 @@ public class DefaultReactiveHealthIndicatorRegistry /** * Create a new {@link DefaultReactiveHealthIndicatorRegistry} from the specified * indicators. - * @param healthIndicators a map of {@link HealthIndicator}s with the key - * being used as an indicator name. + * @param healthIndicators a map of {@link HealthIndicator}s with the key being used + * as an indicator name. */ public DefaultReactiveHealthIndicatorRegistry( Map healthIndicators) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java index ae3ac45c095..82c4cf7ced5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java @@ -65,8 +65,8 @@ public class HealthEndpointWebExtension { public WebEndpointResponse healthForComponentInstance( SecurityContext securityContext, @Selector String component, @Selector String instance) { - Supplier health = () -> this.delegate.healthForComponentInstance( - component, instance); + Supplier health = () -> this.delegate + .healthForComponentInstance(component, instance); return this.responseMapper.mapDetails(health, securityContext); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistry.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistry.java index b466b9479e5..9b4df6af9b6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistry.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistry.java @@ -31,36 +31,35 @@ import java.util.Map; public interface HealthIndicatorRegistry { /** - * Registers the given {@link HealthIndicator}, associating it with the - * given {@code name}. + * Registers the given {@link HealthIndicator}, associating it with the given + * {@code name}. * @param name the name of the indicator * @param healthIndicator the indicator - * @throws IllegalStateException if an indicator with the given {@code name} - * is already registered. + * @throws IllegalStateException if an indicator with the given {@code name} is + * already registered. */ void register(String name, HealthIndicator healthIndicator); /** - * Unregisters the {@link HealthIndicator} previously registered with the - * given {@code name}. + * Unregisters the {@link HealthIndicator} previously registered with the given + * {@code name}. * @param name the name of the indicator - * @return the unregistered indicator, or {@code null} if no indicator was - * found in the registry for the given {@code name}. + * @return the unregistered indicator, or {@code null} if no indicator was found in + * the registry for the given {@code name}. */ HealthIndicator unregister(String name); /** * Returns the {@link HealthIndicator} registered with the given {@code name}. * @param name the name of the indicator - * @return the health indicator, or {@code null} if no indicator was - * registered with the given {@code name}. + * @return the health indicator, or {@code null} if no indicator was registered with + * the given {@code name}. */ HealthIndicator get(String name); /** - * Returns a snapshot of the registered health indicators and their names. - * The contents of the map do not reflect subsequent changes to the - * registry. + * Returns a snapshot of the registered health indicators and their names. The + * contents of the map do not reflect subsequent changes to the registry. * @return the snapshot of registered health indicators */ Map getAll(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistryFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistryFactory.java index 6fff7a1ed2f..4c2f2edc4a5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistryFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicatorRegistryFactory.java @@ -41,10 +41,8 @@ public class HealthIndicatorRegistryFactory { } /** - * Create a {@link HealthIndicatorRegistry} based on the specified health - * indicators. - * @param healthIndicators the {@link HealthIndicator} instances mapped by - * name + * Create a {@link HealthIndicatorRegistry} based on the specified health indicators. + * @param healthIndicators the {@link HealthIndicator} instances mapped by name * @return a {@link HealthIndicator} that delegates to the specified * {@code healthIndicators}. */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistry.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistry.java index 1121cd332c2..41e90558613 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistry.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistry.java @@ -31,12 +31,12 @@ import java.util.Map; public interface ReactiveHealthIndicatorRegistry { /** - * Registers the given {@link ReactiveHealthIndicator}, associating it with the - * given {@code name}. + * Registers the given {@link ReactiveHealthIndicator}, associating it with the given + * {@code name}. * @param name the name of the indicator * @param healthIndicator the indicator - * @throws IllegalStateException if an indicator with the given {@code name} - * is already registered. + * @throws IllegalStateException if an indicator with the given {@code name} is + * already registered. */ void register(String name, ReactiveHealthIndicator healthIndicator); @@ -44,23 +44,22 @@ public interface ReactiveHealthIndicatorRegistry { * Unregisters the {@link ReactiveHealthIndicator} previously registered with the * given {@code name}. * @param name the name of the indicator - * @return the unregistered indicator, or {@code null} if no indicator was - * found in the registry for the given {@code name}. + * @return the unregistered indicator, or {@code null} if no indicator was found in + * the registry for the given {@code name}. */ ReactiveHealthIndicator unregister(String name); /** * Returns the {@link ReactiveHealthIndicator} registered with the given {@code name}. * @param name the name of the indicator - * @return the health indicator, or {@code null} if no indicator was - * registered with the given {@code name}. + * @return the health indicator, or {@code null} if no indicator was registered with + * the given {@code name}. */ ReactiveHealthIndicator get(String name); /** - * Returns a snapshot of the registered health indicators and their names. - * The contents of the map do not reflect subsequent changes to the - * registry. + * Returns a snapshot of the registered health indicators and their names. The + * contents of the map do not reflect subsequent changes to the registry. * @return the snapshot of registered health indicators */ Map getAll(); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorTests.java index 7e63f176d03..95aa93eb25f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorTests.java @@ -45,7 +45,7 @@ public class CompositeReactiveHealthIndicatorTests { public void singleIndicator() { CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator( this.healthAggregator, new DefaultReactiveHealthIndicatorRegistry( - Collections.singletonMap("test", () -> Mono.just(HEALTHY)))); + Collections.singletonMap("test", () -> Mono.just(HEALTHY)))); StepVerifier.create(indicator.health()).consumeNextWith((h) -> { assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getDetails()).containsOnlyKeys("test"); @@ -64,9 +64,9 @@ public class CompositeReactiveHealthIndicatorTests { new DefaultReactiveHealthIndicatorRegistry(indicators)); StepVerifier.withVirtualTime(indicator::health).expectSubscription() .thenAwait(Duration.ofMillis(10000)).consumeNextWith((h) -> { - assertThat(h.getStatus()).isEqualTo(Status.UP); - assertThat(h.getDetails()).hasSize(50); - }).verifyComplete(); + assertThat(h.getStatus()).isEqualTo(Status.UP); + assertThat(h.getDetails()).hasSize(50); + }).verifyComplete(); } @@ -78,7 +78,7 @@ public class CompositeReactiveHealthIndicatorTests { CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator( this.healthAggregator, new DefaultReactiveHealthIndicatorRegistry(indicators)) - .timeoutStrategy(100, UNKNOWN_HEALTH); + .timeoutStrategy(100, UNKNOWN_HEALTH); StepVerifier.create(indicator.health()).consumeNextWith((h) -> { assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getDetails()).containsOnlyKeys("slow", "fast"); @@ -95,14 +95,14 @@ public class CompositeReactiveHealthIndicatorTests { CompositeReactiveHealthIndicator indicator = new CompositeReactiveHealthIndicator( this.healthAggregator, new DefaultReactiveHealthIndicatorRegistry(indicators)) - .timeoutStrategy(20000, null); + .timeoutStrategy(20000, null); StepVerifier.withVirtualTime(indicator::health).expectSubscription() .thenAwait(Duration.ofMillis(10000)).consumeNextWith((h) -> { - assertThat(h.getStatus()).isEqualTo(Status.UP); - assertThat(h.getDetails()).containsOnlyKeys("slow", "fast"); - assertThat(h.getDetails().get("slow")).isEqualTo(HEALTHY); - assertThat(h.getDetails().get("fast")).isEqualTo(HEALTHY); - }).verifyComplete(); + assertThat(h.getStatus()).isEqualTo(Status.UP); + assertThat(h.getDetails()).containsOnlyKeys("slow", "fast"); + assertThat(h.getDetails().get("slow")).isEqualTo(HEALTHY); + assertThat(h.getDetails().get("fast")).isEqualTo(HEALTHY); + }).verifyComplete(); } static class TimeoutHealth implements ReactiveHealthIndicator { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistryTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistryTests.java index e8b4adc66c6..63aa766a587 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistryTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/DefaultReactiveHealthIndicatorRegistryTests.java @@ -47,10 +47,10 @@ public class DefaultReactiveHealthIndicatorRegistryTests { @Before public void setUp() { - given(this.one.health()).willReturn(Mono.just( - new Health.Builder().unknown().withDetail("1", "1").build())); - given(this.two.health()).willReturn(Mono.just( - new Health.Builder().unknown().withDetail("2", "2").build())); + given(this.one.health()).willReturn( + Mono.just(new Health.Builder().unknown().withDetail("1", "1").build())); + given(this.two.health()).willReturn( + Mono.just(new Health.Builder().unknown().withDetail("2", "2").build())); this.registry = new DefaultReactiveHealthIndicatorRegistry(); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java index ca387000cae..2b5a56510bc 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java @@ -59,8 +59,8 @@ public class HealthEndpointTests { @Test public void statusForComponentIsExposed() { - HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( - Collections.singletonMap("test", one))); + HealthEndpoint endpoint = new HealthEndpoint( + createHealthIndicator(Collections.singletonMap("test", one))); Health health = endpoint.healthForComponent("test"); assertThat(health).isNotNull(); assertThat(health.getStatus()).isEqualTo(Status.UP); @@ -69,8 +69,8 @@ public class HealthEndpointTests { @Test public void statusForUnknownComponentReturnNull() { - HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( - Collections.emptyMap())); + HealthEndpoint endpoint = new HealthEndpoint( + createHealthIndicator(Collections.emptyMap())); Health health = endpoint.healthForComponent("does-not-exist"); assertThat(health).isNull(); } @@ -79,7 +79,7 @@ public class HealthEndpointTests { public void statusForComponentInstanceIsExposed() { CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator( new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry( - Collections.singletonMap("sub", () -> Health.down().build()))); + Collections.singletonMap("sub", () -> Health.down().build()))); HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( Collections.singletonMap("test", compositeIndicator))); Health health = endpoint.healthForComponentInstance("test", "sub"); @@ -92,7 +92,7 @@ public class HealthEndpointTests { public void statusForUnknownComponentInstanceReturnNull() { CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator( new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry( - Collections.singletonMap("sub", () -> Health.down().build()))); + Collections.singletonMap("sub", () -> Health.down().build()))); HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( Collections.singletonMap("test", compositeIndicator))); Health health = endpoint.healthForComponentInstance("test", "does-not-exist"); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java index d8e90c59fb9..186c3af3b4a 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointWebIntegrationTests.java @@ -56,9 +56,9 @@ public class HealthEndpointWebIntegrationTests { registry.register("charlie", () -> Health.down().build()); try { client.get().uri("/actuator/health").exchange().expectStatus() - .isEqualTo(HttpStatus.SERVICE_UNAVAILABLE).expectBody().jsonPath("status") - .isEqualTo("DOWN").jsonPath("details.alpha.status").isEqualTo("UP") - .jsonPath("details.bravo.status").isEqualTo("UP") + .isEqualTo(HttpStatus.SERVICE_UNAVAILABLE).expectBody() + .jsonPath("status").isEqualTo("DOWN").jsonPath("details.alpha.status") + .isEqualTo("UP").jsonPath("details.bravo.status").isEqualTo("UP") .jsonPath("details.charlie.status").isEqualTo("DOWN"); } finally { @@ -71,9 +71,10 @@ public class HealthEndpointWebIntegrationTests { HealthIndicatorRegistry registry = context.getBean(HealthIndicatorRegistry.class); HealthIndicator bravo = registry.unregister("bravo"); try { - client.get().uri("/actuator/health").exchange().expectStatus().isOk().expectBody() - .jsonPath("status").isEqualTo("UP").jsonPath("details.alpha.status") - .isEqualTo("UP").jsonPath("details.bravo.status").doesNotExist(); + client.get().uri("/actuator/health").exchange().expectStatus().isOk() + .expectBody().jsonPath("status").isEqualTo("UP") + .jsonPath("details.alpha.status").isEqualTo("UP") + .jsonPath("details.bravo.status").doesNotExist(); } finally { registry.register("bravo", bravo); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapperTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapperTests.java index ef6de57a611..3740db55c9f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapperTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthWebEndpointResponseMapperTests.java @@ -62,7 +62,8 @@ public class HealthWebEndpointResponseMapperTests { @Test public void mapDetailsWithUnauthorizedUserDoesNotInvokeSupplier() { - HealthWebEndpointResponseMapper mapper = createMapper(ShowDetails.WHEN_AUTHORIZED); + HealthWebEndpointResponseMapper mapper = createMapper( + ShowDetails.WHEN_AUTHORIZED); Supplier supplier = mockSupplier(); SecurityContext securityContext = mockSecurityContext("USER"); WebEndpointResponse response = mapper.mapDetails(supplier, @@ -75,13 +76,15 @@ public class HealthWebEndpointResponseMapperTests { @Test public void mapDetailsWithAuthorizedUserInvokeSupplier() { - HealthWebEndpointResponseMapper mapper = createMapper(ShowDetails.WHEN_AUTHORIZED); + HealthWebEndpointResponseMapper mapper = createMapper( + ShowDetails.WHEN_AUTHORIZED); Supplier supplier = mockSupplier(); given(supplier.get()).willReturn(Health.down().build()); SecurityContext securityContext = mockSecurityContext("ACTUATOR"); WebEndpointResponse response = mapper.mapDetails(supplier, securityContext); - assertThat(response.getStatus()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value()); + assertThat(response.getStatus()) + .isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value()); assertThat(response.getBody().getStatus()).isEqualTo(Status.DOWN); verify(supplier).get(); verify(securityContext).isUserInRole("ACTUATOR"); @@ -108,12 +111,12 @@ public class HealthWebEndpointResponseMapperTests { private SecurityContext mockSecurityContext(String... roles) { List associatedRoles = Arrays.asList(roles); SecurityContext securityContext = mock(SecurityContext.class); - given(securityContext.getPrincipal()) - .willReturn(mock(Principal.class)); - given(securityContext.isUserInRole(anyString())).will((Answer) invocation -> { - String expectedRole = invocation.getArgument(0); - return associatedRoles.contains(expectedRole); - }); + given(securityContext.getPrincipal()).willReturn(mock(Principal.class)); + given(securityContext.isUserInRole(anyString())) + .will((Answer) invocation -> { + String expectedRole = invocation.getArgument(0); + return associatedRoles.contains(expectedRole); + }); return securityContext; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistryFactoryTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistryFactoryTests.java index 824d0d6180f..dcb7b3a5bc9 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistryFactoryTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/ReactiveHealthIndicatorRegistryFactoryTests.java @@ -39,16 +39,18 @@ public class ReactiveHealthIndicatorRegistryFactoryTests { @Test public void defaultHealthIndicatorNameFactory() { - ReactiveHealthIndicatorRegistry registry = this.factory.createReactiveHealthIndicatorRegistry( - Collections.singletonMap("myHealthIndicator", () -> Mono.just(UP)), null); + ReactiveHealthIndicatorRegistry registry = this.factory + .createReactiveHealthIndicatorRegistry(Collections + .singletonMap("myHealthIndicator", () -> Mono.just(UP)), null); assertThat(registry.getAll()).containsOnlyKeys("my"); } @Test public void healthIndicatorIsAdapted() { - ReactiveHealthIndicatorRegistry registry = this.factory.createReactiveHealthIndicatorRegistry( - Collections.singletonMap("test", () -> Mono.just(UP)), - Collections.singletonMap("regular", () -> DOWN)); + ReactiveHealthIndicatorRegistry registry = this.factory + .createReactiveHealthIndicatorRegistry( + Collections.singletonMap("test", () -> Mono.just(UP)), + Collections.singletonMap("regular", () -> DOWN)); assertThat(registry.getAll()).containsOnlyKeys("test", "regular"); StepVerifier.create(registry.get("regular").health()).consumeNextWith((h) -> { assertThat(h.getStatus()).isEqualTo(Status.DOWN); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientBuilderCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientBuilderCustomizer.java index 8ed0f1f7771..69a5baa0296 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientBuilderCustomizer.java @@ -34,4 +34,5 @@ public interface RestClientBuilderCustomizer { * @param builder the builder to customize */ void customize(RestClientBuilder builder); + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientProperties.java index 33d876b3848..7990bd829c8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientProperties.java @@ -47,8 +47,6 @@ public class RestClientProperties { */ private String password; - - public List getUris() { return this.uris; } @@ -72,4 +70,5 @@ public class RestClientProperties { public void setPassword(String password) { this.password = password; } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java index 58aff9a8227..395b24e83a6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java @@ -72,8 +72,8 @@ public class JestAutoConfigurationTests { @Test public void jestClientOnLocalhostByDefault() { - this.contextRunner.run((context) -> - assertThat(context).hasSingleBean(JestClient.class)); + this.contextRunner + .run((context) -> assertThat(context).hasSingleBean(JestClient.class)); } @Test @@ -130,11 +130,12 @@ public class JestAutoConfigurationTests { Map source = new HashMap<>(); source.put("a", "alpha"); source.put("b", "bravo"); - Index index = new Index.Builder(source).index("foo") - .type("bar").id("1").build(); + Index index = new Index.Builder(source).index("foo").type("bar") + .id("1").build(); execute(client, index); Get getRequest = new Get.Builder("foo", "1").build(); - assertThat(execute(client, getRequest).getResponseCode()).isEqualTo(200); + assertThat(execute(client, getRequest).getResponseCode()) + .isEqualTo(200); })); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientAutoConfigurationTests.java index e2bd0fed32d..1fe8e2f7229 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/rest/RestClientAutoConfigurationTests.java @@ -100,6 +100,7 @@ public class RestClientAutoConfigurationTests { public RestClient customRestClient() { return mock(RestClient.class); } + } @Configuration @@ -109,6 +110,7 @@ public class RestClientAutoConfigurationTests { public RestClientBuilderCustomizer myCustomizer() { return (builder) -> builder.setMaxRetryTimeoutMillis(42); } + } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java index 3e9b2490ea0..137ea6da095 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java @@ -181,15 +181,13 @@ public class LiquibaseAutoConfigurationTests { @Test public void overrideTestRollbackOnUpdate() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues( - "spring.liquibase.test-rollback-on-update:true") + .withPropertyValues("spring.liquibase.test-rollback-on-update:true") .run((context) -> { SpringLiquibase liquibase = context.getBean(SpringLiquibase.class); assertThat(liquibase.isTestRollbackOnUpdate()).isTrue(); }); } - @Test public void changeLogDoesNotExist() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java index e1950a0ff6c..cdb2651e35a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java @@ -43,8 +43,7 @@ public class WebMvcTestPageableIntegrationTests { @Test public void shouldSupportPageable() throws Exception { this.mvc.perform(get("/paged").param("page", "2").param("size", "42")) - .andExpect(status().isOk()) - .andExpect(content().string("2:42")); + .andExpect(status().isOk()).andExpect(content().string("2:42")); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 0c4d1f9d1ca..da9161a4f9f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -267,7 +267,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { + "]"); } 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 { private void logArguments(String message, String[] args) { if (getLog().isDebugEnabled()) { - getLog().debug(Arrays.stream(args).collect(Collectors.joining(" ", message, ""))); + getLog().debug( + Arrays.stream(args).collect(Collectors.joining(" ", message, ""))); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index f43fe800add..031888f93b1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -229,9 +229,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { } /** - * Return the source {@link Artifact} to repackage. If a classifier is specified - * and an artifact with that classifier exists, it is used. Otherwise, the main - * artifact is used. + * Return the source {@link Artifact} to repackage. If a classifier is specified and + * an artifact with that classifier exists, it is used. Otherwise, the main artifact + * is used. * @return the source artifact to repackage */ private Artifact getSourceArtifact() {