From 7fbb5749d15570579d251e388551e9bc02db4374 Mon Sep 17 00:00:00 2001 From: izeye Date: Thu, 23 Dec 2021 22:44:16 +0900 Subject: [PATCH] Polish See gh-29157 --- ...ackdriverPropertiesConfigAdapterTests.java | 2 +- .../cache/CachingOperationInvokerTests.java | 32 +++++++++---------- .../health/AbstractHealthIndicatorTests.java | 4 +-- .../web/servlet/WebMvcMetricsFilterTests.java | 8 ++--- .../amqp/RabbitStreamConfigurationTests.java | 2 +- .../IntegrationAutoConfigurationTests.java | 10 +++--- .../src/docs/asciidoc/io/validation.adoc | 2 +- .../orm/jpa/TestEntityManager.java | 2 +- .../context/ImportsContextCustomizer.java | 4 +-- .../ImportsContextCustomizerTests.java | 10 +++--- 10 files changed, 39 insertions(+), 37 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/stackdriver/StackdriverPropertiesConfigAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/stackdriver/StackdriverPropertiesConfigAdapterTests.java index d04b5410af..6018cbc91f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/stackdriver/StackdriverPropertiesConfigAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/stackdriver/StackdriverPropertiesConfigAdapterTests.java @@ -56,7 +56,7 @@ class StackdriverPropertiesConfigAdapterTests { } @Test - void whenPropertiesUseSemanticMetricTypesIsSetAdapterResourceTypeReturnsIt() { + void whenPropertiesUseSemanticMetricTypesIsSetAdapterUseSemanticMetricTypesReturnsIt() { StackdriverProperties properties = new StackdriverProperties(); properties.setUseSemanticMetricTypes(true); assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue(); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java index 4e0727cc7e..692609fcd2 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvokerTests.java @@ -234,32 +234,32 @@ class CachingOperationInvokerTests { given(target.invoke(contextV2)).willReturn(expectedV2); given(target.invoke(contextV3)).willReturn(expectedV3); CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL); - Object response = invoker.invoke(contextV2); - assertThat(response).isSameAs(expectedV2); + Object responseV2 = invoker.invoke(contextV2); + assertThat(responseV2).isSameAs(expectedV2); verify(target, times(1)).invoke(contextV2); - Object cachedResponse = invoker.invoke(contextV3); - assertThat(cachedResponse).isNotSameAs(response); + Object responseV3 = invoker.invoke(contextV3); + assertThat(responseV3).isNotSameAs(responseV2); verify(target, times(1)).invoke(contextV3); } @Test void targetInvokedWithDifferentWebServerNamespace() { OperationInvoker target = mock(OperationInvoker.class); - Object expectedV2 = new Object(); - Object expectedV3 = new Object(); - InvocationContext contextV2 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(), + Object expectedServer = new Object(); + Object expectedManagement = new Object(); + InvocationContext contextServer = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(), new WebServerNamespaceArgumentResolver(WebServerNamespace.SERVER)); - InvocationContext contextV3 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(), + InvocationContext contextManagement = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(), new WebServerNamespaceArgumentResolver(WebServerNamespace.MANAGEMENT)); - given(target.invoke(contextV2)).willReturn(expectedV2); - given(target.invoke(contextV3)).willReturn(expectedV3); + given(target.invoke(contextServer)).willReturn(expectedServer); + given(target.invoke(contextManagement)).willReturn(expectedManagement); CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL); - Object response = invoker.invoke(contextV2); - assertThat(response).isSameAs(expectedV2); - verify(target, times(1)).invoke(contextV2); - Object cachedResponse = invoker.invoke(contextV3); - assertThat(cachedResponse).isNotSameAs(response); - verify(target, times(1)).invoke(contextV3); + Object responseServer = invoker.invoke(contextServer); + assertThat(responseServer).isSameAs(expectedServer); + verify(target, times(1)).invoke(contextServer); + Object responseManagement = invoker.invoke(contextManagement); + assertThat(responseManagement).isNotSameAs(responseServer); + verify(target, times(1)).invoke(contextManagement); } private static class MonoOperationInvoker implements OperationInvoker { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/AbstractHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/AbstractHealthIndicatorTests.java index 09950b7e5f..c193b36cc7 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/AbstractHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/AbstractHealthIndicatorTests.java @@ -45,7 +45,7 @@ class AbstractHealthIndicatorTests { } @Test - void healthCheckWhenDownWithExceptionThrownDoesNotLogHealthCheckFailedMessage(CapturedOutput output) { + void healthCheckWhenDownWithExceptionThrownLogsHealthCheckFailedMessage(CapturedOutput output) { TestHealthIndicator indicator = new TestHealthIndicator("Test message", (builder) -> { throw new IllegalStateException("Test exception"); }); @@ -55,7 +55,7 @@ class AbstractHealthIndicatorTests { } @Test - void healthCheckWhenDownWithExceptionConfiguredDoesNotLogHealthCheckFailedMessage(CapturedOutput output) { + void healthCheckWhenDownWithExceptionConfiguredLogsHealthCheckFailedMessage(CapturedOutput output) { Health heath = new TestHealthIndicator("Test message", (builder) -> builder.down().withException(new IllegalStateException("Test exception"))).health(); assertThat(heath.getStatus()).isEqualTo(Status.DOWN); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java index 85d6ab16e7..9faa8cb724 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java @@ -182,7 +182,7 @@ class WebMvcMetricsFilterTests { @Test void unhandledError() { - assertThatCode(() -> this.mvc.perform(get("/api/c1/unhandledError/10")).andExpect(status().isOk())) + assertThatCode(() -> this.mvc.perform(get("/api/c1/unhandledError/10"))) .hasRootCauseInstanceOf(RuntimeException.class); assertThat(this.registry.get("http.server.requests").tags("exception", "RuntimeException").timer().count()) .isEqualTo(1L); @@ -191,8 +191,8 @@ class WebMvcMetricsFilterTests { @Test void unhandledServletException() { assertThatCode(() -> this.mvc - .perform(get("/api/filterError").header(CustomBehaviorFilter.TEST_SERVLET_EXCEPTION_HEADER, "throw")) - .andExpect(status().isOk())).isInstanceOf(ServletException.class); + .perform(get("/api/filterError").header(CustomBehaviorFilter.TEST_SERVLET_EXCEPTION_HEADER, "throw"))) + .isInstanceOf(ServletException.class); Id meterId = this.registry.get("http.server.requests").tags("exception", "ServletException").timer().getId(); assertThat(meterId.getTag("status")).isEqualTo("500"); } @@ -372,7 +372,7 @@ class WebMvcMetricsFilterTests { } @Bean - CustomBehaviorFilter redirectAndNotFoundFilter() { + CustomBehaviorFilter customBehaviorFilter() { return new CustomBehaviorFilter(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitStreamConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitStreamConfigurationTests.java index f002d1c09b..9c285dab13 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitStreamConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitStreamConfigurationTests.java @@ -85,7 +85,7 @@ class RabbitStreamConfigurationTests { } @Test - void whenCustomMessageListenerContainerIsDefinedThenAutoConfiguredContainerBacksOff() { + void whenCustomMessageListenerContainerFactoryIsDefinedThenAutoConfiguredContainerFactoryBacksOff() { this.contextRunner.withUserConfiguration(CustomMessageListenerContainerFactoryConfiguration.class) .run((context) -> { assertThat(context).hasSingleBean(RabbitListenerContainerFactory.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java index 9c963c1dd8..b2d7878d75 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java @@ -27,6 +27,7 @@ import io.rsocket.transport.ClientTransport; import io.rsocket.transport.netty.client.TcpClientTransport; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; import org.springframework.beans.DirectFieldAccessor; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -58,8 +59,10 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.context.IntegrationContextUtils; +import org.springframework.integration.core.MessageSource; import org.springframework.integration.endpoint.MessageProcessorMessageSource; import org.springframework.integration.gateway.RequestReplyExchanger; +import org.springframework.integration.handler.MessageProcessor; import org.springframework.integration.rsocket.ClientRSocketConnector; import org.springframework.integration.rsocket.IntegrationRSocketEndpoint; import org.springframework.integration.rsocket.ServerRSocketConnector; @@ -526,9 +529,8 @@ class IntegrationAutoConfigurationTests { static class MessageSourceConfiguration { @Bean - org.springframework.integration.core.MessageSource myMessageSource() { - return new MessageProcessorMessageSource( - mock(org.springframework.integration.handler.MessageProcessor.class)); + MessageSource myMessageSource() { + return new MessageProcessorMessageSource(mock(MessageProcessor.class)); } } @@ -541,7 +543,7 @@ class IntegrationAutoConfigurationTests { return new IntegrationRSocketEndpoint() { @Override - public reactor.core.publisher.Mono handleMessage(Message message) { + public Mono handleMessage(Message message) { return null; } diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/validation.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/validation.adoc index e1a72ae358..50781c2371 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/validation.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/validation.adoc @@ -11,6 +11,6 @@ For instance, the following service triggers the validation of the first argumen include::{docs-java}/io/validation/MyBean.java[] ---- -The application's `MessageSource` is used when resolving +`{parameters}`+ in constraint messages. +The application's `MessageSource` is used when resolving `+{parameters}+` in constraint messages. This allows you to use <> for Bean Validation messages. Once the parameters have been resolved, message interpolation is completed using Bean Validation's default interpolator. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java index 0a6c993074..1b0d2d0d51 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java @@ -234,7 +234,7 @@ public class TestEntityManager { */ public final EntityManager getEntityManager() { EntityManager manager = EntityManagerFactoryUtils.getTransactionalEntityManager(this.entityManagerFactory); - Assert.state(manager != null, "No transactional EntityManager found, is your test running in a transactional?"); + Assert.state(manager != null, "No transactional EntityManager found, is your test running in a transaction?"); return manager; } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index c793915edf..e068632bd2 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -223,7 +223,7 @@ class ImportsContextCustomizer implements ContextCustomizer { filters.add(new JavaLangAnnotationFilter()); filters.add(new KotlinAnnotationFilter()); filters.add(new SpockAnnotationFilter()); - filters.add(new JunitAnnotationFilter()); + filters.add(new JUnitAnnotationFilter()); ANNOTATION_FILTERS = Collections.unmodifiableSet(filters); } @@ -389,7 +389,7 @@ class ImportsContextCustomizer implements ContextCustomizer { /** * {@link AnnotationFilter} for JUnit annotations. */ - private static final class JunitAnnotationFilter implements AnnotationFilter { + private static final class JUnitAnnotationFilter implements AnnotationFilter { @Override public boolean isIgnored(Annotation annotation) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/ImportsContextCustomizerTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/ImportsContextCustomizerTests.java index 4f8239bc33..28673bb532 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/ImportsContextCustomizerTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/ImportsContextCustomizerTests.java @@ -75,9 +75,9 @@ class ImportsContextCustomizerTests { } @Test - void customizersForTestClassesWithDifferentJunitAnnotationsAreEqual() { - assertThat(new ImportsContextCustomizer(FirstJunitAnnotatedTestClass.class)) - .isEqualTo(new ImportsContextCustomizer(SecondJunitAnnotatedTestClass.class)); + void customizersForTestClassesWithDifferentJUnitAnnotationsAreEqual() { + assertThat(new ImportsContextCustomizer(FirstJUnitAnnotatedTestClass.class)) + .isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class)); } @Import(TestImportSelector.class) @@ -142,13 +142,13 @@ class ImportsContextCustomizerTests { @Nested @Import(TestImportSelector.class) - static class FirstJunitAnnotatedTestClass { + static class FirstJUnitAnnotatedTestClass { } @Tag("test") @Import(TestImportSelector.class) - static class SecondJunitAnnotatedTestClass { + static class SecondJUnitAnnotatedTestClass { }