Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish #44447

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Polish #44447

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.springframework.boot.actuate.autoconfigure.data.redis;

import java.util.Map;

import reactor.core.publisher.Flux;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
Expand Down Expand Up @@ -51,8 +49,7 @@
public class RedisReactiveHealthContributorAutoConfiguration extends
CompositeReactiveHealthContributorConfiguration<RedisReactiveHealthIndicator, ReactiveRedisConnectionFactory> {

RedisReactiveHealthContributorAutoConfiguration(
Map<String, ReactiveRedisConnectionFactory> redisConnectionFactories) {
RedisReactiveHealthContributorAutoConfiguration() {
super(RedisReactiveHealthIndicator::new);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,11 @@ TestBean standard() {
@Bean(defaultCandidate = false)
TestBean nonDefault() {
return new TestBean();

}

@Bean(autowireCandidate = false)
TestBean nonAutowire() {
return new TestBean();

}

}
Expand All @@ -145,7 +143,6 @@ TestBean standard() {
@Bean(autowireCandidate = false)
TestBean nonAutowire() {
return new TestBean();

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void applyUnlessFilteredWhenHasFilterTestingFalseReturnsUnfiltered() {
void ifLikelySensitiveFiltersExpected() {
SanitizingFunction function = SanitizingFunction.sanitizeValue().ifLikelySensitive();
assertThat(function).satisfies(this::likelyCredentialChecks, this::likelyUriChecks,
this::likelySenstivePropertyChecks, this::vcapServicesChecks);
this::likelySensitivePropertyChecks, this::vcapServicesChecks);
}

@Test
Expand Down Expand Up @@ -103,10 +103,10 @@ private void likelyUriChecks(SanitizingFunction function) {
@Test
void ifLikelySensitivePropertyFiltersExpected() {
SanitizingFunction function = SanitizingFunction.sanitizeValue().ifLikelySensitiveProperty();
assertThat(function).satisfies(this::likelySenstivePropertyChecks);
assertThat(function).satisfies(this::likelySensitivePropertyChecks);
}

private void likelySenstivePropertyChecks(SanitizingFunction function) {
private void likelySensitivePropertyChecks(SanitizingFunction function) {
assertThatApplyingToKey(function, "sun.java.command").has(sanitizedValue());
assertThatApplyingToKey(function, "spring.application.json").has(sanitizedValue());
assertThatApplyingToKey(function, "SPRING_APPLICATION_JSON").has(sanitizedValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public @interface AutoConfigureBefore {

/**
* The auto-configure classes that should have not yet been applied.
* The auto-configuration classes that should have not yet been applied.
* @return the classes
*/
Class<?>[] value() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void entityScanShouldSetManagedTypes() {
@Test
void userTypeResolverShouldBeSet() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(CassandraConverter.class);
assertThat(context).hasSingleBean(CassandraConverter.class);
assertThat(context.getBean(CassandraConverter.class)).extracting("userTypeResolver")
.isInstanceOf(SimpleUserTypeResolver.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ void objectDirectoryMapperExists() {
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:389").run((context) -> {
assertThat(context).hasSingleBean(ObjectDirectoryMapper.class);
ObjectDirectoryMapper objectDirectoryMapper = context.getBean(ObjectDirectoryMapper.class);
ApplicationConversionService conversionService = assertThat(objectDirectoryMapper)
.extracting("converterManager")
.extracting("conversionService")
.asInstanceOf(InstanceOfAssertFactories.type(ApplicationConversionService.class))
.actual();
assertThat(conversionService.canConvert(String.class, Name.class)).isTrue();
assertThat(conversionService.canConvert(Name.class, String.class)).isTrue();
assertThat(objectDirectoryMapper).extracting("converterManager")
.extracting("conversionService", InstanceOfAssertFactories.type(ApplicationConversionService.class))
.satisfies((conversionService) -> {
assertThat(conversionService.canConvert(String.class, Name.class)).isTrue();
assertThat(conversionService.canConvert(Name.class, String.class)).isTrue();
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public void log(String message) {
}

/**
* Creates{@link DockerLog} instance based on the provided {@link BuildLog}.
* Creates {@link DockerLog} instance based on the provided {@link BuildLog}.
* <p>
* If the provided {@link BuildLog} instance is an {@link AbstractBuildLog}, the
* method returns a {@link BuildLogAdapter}, otherwise it returns a default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class DockerApi {
* Create a new {@link DockerApi} instance.
*/
public DockerApi() {
this(HttpTransport.create(null), DockerLog.toSystemOut());
this(null);
}

/**
Expand All @@ -96,7 +96,7 @@ public DockerApi() {
* @since 2.4.0
*/
public DockerApi(DockerHostConfiguration dockerHost) {
this(HttpTransport.create(dockerHost), DockerLog.toSystemOut());
this(dockerHost, DockerLog.toSystemOut());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public interface DockerLog {
void log(String message);

/**
* Factory method that returns a {@link DockerLog} the outputs to {@link System#out}.
* Factory method that returns a {@link DockerLog} that outputs to {@link System#out}.
* @return {@link DockerLog} instance that logs to system out
*/
static DockerLog toSystemOut() {
return to(System.out);
}

/**
* Factory method that returns a {@link DockerLog} the outputs to a given
* Factory method that returns a {@link DockerLog} that outputs to a given
* {@link PrintStream}.
* @param out the print stream used to output the log
* @return {@link DockerLog} instance that logs to the given print stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
Expand All @@ -73,14 +74,12 @@ void createWhenLogIsNullThrowsException() {

@Test
void createWithDockerConfiguration() {
Builder builder = new Builder(BuildLog.toSystemOut());
assertThat(builder).isNotNull();
assertThatNoException().isThrownBy(() -> new Builder(BuildLog.toSystemOut()));
}

@Test
void createDockerApiWithLogDockerLogDelegate() {
Builder builder = new Builder(BuildLog.toSystemOut());
assertThat(builder).isNotNull();
assertThat(builder).extracting("docker")
.extracting("system")
.extracting("log")
Expand All @@ -90,7 +89,6 @@ void createDockerApiWithLogDockerLogDelegate() {
@Test
void createDockerApiWithLogDockerSystemOutDelegate() {
Builder builder = new Builder(mock(BuildLog.class));
assertThat(builder).isNotNull();
assertThat(builder).extracting("docker")
.extracting("system")
.extracting("log")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void cleanUp() {
super.cleanUp();
LoggerContext loggerContext = getLoggerContext();
markAsUninitialized(loggerContext);
StatusConsoleListener listener = (StatusConsoleListener) getLoggerContext().getObject(STATUS_LISTENER_KEY);
StatusConsoleListener listener = (StatusConsoleListener) loggerContext.getObject(STATUS_LISTENER_KEY);
if (listener != null) {
StatusLogger.getLogger().removeListener(listener);
loggerContext.removeObject(STATUS_LISTENER_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ public final void refresh() throws BeansException, IllegalStateException {
super.refresh();
}
catch (RuntimeException ex) {
try {
WebServer webServer = this.webServer;
if (webServer != null) {
WebServer webServer = this.webServer;
if (webServer != null) {
try {
webServer.stop();
webServer.destroy();
}
}
catch (RuntimeException stopOrDestroyEx) {
ex.addSuppressed(stopOrDestroyEx);
catch (RuntimeException stopOrDestroyEx) {
ex.addSuppressed(stopOrDestroyEx);
}
}
throw ex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void createPrinterWhenClassNameInjectsConfiguredPrinter() {
}

@Test
void shouldReturnFalseWhenPrinterIsEmpty() {
void hasCustomPrinterShouldReturnFalseWhenPrinterIsEmpty() {
StackTrace stackTrace = new StackTrace("", null, null, null, null, null);
assertThat(stackTrace.hasCustomPrinter()).isFalse();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.BDDMockito.then;
import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;

/**
Expand Down Expand Up @@ -148,7 +149,7 @@ void whenContextRefreshFailedThenWebServerStopFailedCatchStopException() {
.withStackTraceContaining("WebServer has failed to stop");
WebServer webServer = this.context.getWebServer();
then(webServer).should().stop();
then(webServer).should(times(0)).destroy();
then(webServer).should(never()).destroy();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.withSettings;

Expand Down Expand Up @@ -236,7 +237,7 @@ void whenContextRefreshFailedThenWebServerStopFailedCatchStopException() {
.withStackTraceContaining("WebServer has failed to stop");
WebServer webServer = this.context.getWebServer();
then(webServer).should().stop();
then(webServer).should(times(0)).destroy();
then(webServer).should(never()).destroy();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.never;

/**
* Base for testing classes that extends {@link AbstractServletWebServerFactory}.
Expand Down Expand Up @@ -1183,7 +1183,7 @@ protected void servletContextListenerContextDestroyedIsNotCalledWhenContainerIsS
this.webServer = getFactory().getWebServer((servletContext) -> servletContext.addListener(listener));
this.webServer.start();
this.webServer.stop();
then(listener).should(times(0)).contextDestroyed(any(ServletContextEvent.class));
then(listener).should(never()).contextDestroyed(any(ServletContextEvent.class));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id "org.springframework.boot.docker-test"
}

description = "Spring Boot Data ElasticSearch smoke test"
description = "Spring Boot Data Elasticsearch smoke test"

dependencies {
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
@Testcontainers(disabledWithoutDocker = true)
@DataElasticsearchTest
class SampleElasticSearch8ApplicationTests {
class SampleElasticsearch8ApplicationTests {

@Container
@ServiceConnection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
@Testcontainers(disabledWithoutDocker = true)
@DataElasticsearchTest
class SampleElasticSearchApplicationTests {
class SampleElasticsearchApplicationTests {

@Container
@ServiceConnection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Testcontainers(disabledWithoutDocker = true)
@DataElasticsearchTest(
properties = { "spring.elasticsearch.connection-timeout=120s", "spring.elasticsearch.socket-timeout=120s" })
class SampleElasticSearchSslApplicationTests {
class SampleElasticsearchSslApplicationTests {

@Container
@ServiceConnection
Expand Down