mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-06 17:29:19 +00:00
Polish "Use static imports for Assertions.assertThat() consistently"
See gh-48630
This commit is contained in:
+8
-11
@@ -26,7 +26,6 @@ import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AbstractObjectArrayAssert;
|
||||
import org.assertj.core.api.AbstractObjectAssert;
|
||||
import org.assertj.core.api.AbstractThrowableAssert;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.assertj.core.api.MapAssert;
|
||||
import org.assertj.core.error.BasicErrorMessageFactory;
|
||||
|
||||
@@ -223,8 +222,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
if (this.startupFailure != null) {
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to get beans names with type:%n <%s>", type));
|
||||
}
|
||||
return Assertions.assertThat(getApplicationContext().getBeanNamesForType(type))
|
||||
.as("Bean names of type <%s> from <%s>", type, getApplicationContext());
|
||||
return assertThat(getApplicationContext().getBeanNamesForType(type)).as("Bean names of type <%s> from <%s>",
|
||||
type, getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +276,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
getApplicationContext(), type, names));
|
||||
}
|
||||
T bean = (name != null) ? getApplicationContext().getBean(name, type) : null;
|
||||
return Assertions.assertThat(bean).as("Bean of type <%s> from <%s>", type, getApplicationContext());
|
||||
return assertThat(bean).as("Bean of type <%s> from <%s>", type, getApplicationContext());
|
||||
}
|
||||
|
||||
private String getPrimary(String[] names, Scope scope) {
|
||||
@@ -328,7 +327,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to contain a bean of name:%n <%s>", name));
|
||||
}
|
||||
Object bean = findBean(name);
|
||||
return Assertions.assertThat(bean).as("Bean of name <%s> from <%s>", name, getApplicationContext());
|
||||
return assertThat(bean).as("Bean of name <%s> from <%s>", name, getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,8 +359,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
"%nExpecting:%n <%s>%nto contain a bean of name:%n <%s> (%s)%nbut found:%n <%s> of type <%s>",
|
||||
getApplicationContext(), name, type, bean, bean.getClass()));
|
||||
}
|
||||
return Assertions.assertThat((T) bean)
|
||||
.as("Bean of name <%s> and type <%s> from <%s>", name, type, getApplicationContext());
|
||||
return assertThat((T) bean).as("Bean of name <%s> and type <%s> from <%s>", name, type,
|
||||
getApplicationContext());
|
||||
}
|
||||
|
||||
private Object findBean(String name) {
|
||||
@@ -411,8 +410,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
if (this.startupFailure != null) {
|
||||
throwAssertionError(contextFailedToStartWhenExpecting("to get beans of type:%n <%s>", type));
|
||||
}
|
||||
return Assertions.assertThat(scope.getBeansOfType(getApplicationContext(), type))
|
||||
.as("Beans of type <%s> from <%s>", type, getApplicationContext());
|
||||
return assertThat(scope.getBeansOfType(getApplicationContext(), type)).as("Beans of type <%s> from <%s>", type,
|
||||
getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,7 +481,6 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
* Limited to the current context.
|
||||
*/
|
||||
NO_ANCESTORS {
|
||||
|
||||
@Override
|
||||
String[] getBeanNamesForType(ApplicationContext applicationContext, Class<?> type) {
|
||||
return applicationContext.getBeanNamesForType(type);
|
||||
@@ -499,7 +497,6 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
* Consider the ancestor contexts as well as the current context.
|
||||
*/
|
||||
INCLUDE_ANCESTORS {
|
||||
|
||||
@Override
|
||||
String[] getBeanNamesForType(ApplicationContext applicationContext, Class<?> type) {
|
||||
return BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext, type);
|
||||
|
||||
+2
-3
@@ -32,7 +32,6 @@ import io.rsocket.SocketAcceptor;
|
||||
import io.rsocket.transport.netty.client.TcpClientTransport;
|
||||
import io.rsocket.transport.netty.client.WebsocketClientTransport;
|
||||
import io.rsocket.util.DefaultPayload;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InOrder;
|
||||
@@ -375,7 +374,7 @@ class NettyRSocketServerFactoryTests {
|
||||
}
|
||||
|
||||
private HttpClient createHttpClient() {
|
||||
Assertions.assertThat(this.server).isNotNull();
|
||||
assertThat(this.server).isNotNull();
|
||||
InetSocketAddress address = this.server.address();
|
||||
return HttpClient.create().host(address.getHostName()).port(address.getPort());
|
||||
}
|
||||
@@ -389,7 +388,7 @@ class NettyRSocketServerFactoryTests {
|
||||
}
|
||||
|
||||
private TcpClient createTcpClient() {
|
||||
Assertions.assertThat(this.server).isNotNull();
|
||||
assertThat(this.server).isNotNull();
|
||||
InetSocketAddress address = this.server.address();
|
||||
return TcpClient.create().host(address.getHostName()).port(address.getPort());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user