Migrate to Mockito.mock(T...) where feasible
This commit is contained in:
@@ -32,9 +32,9 @@ import static org.mockito.BDDMockito.when;
|
||||
*/
|
||||
class DelegatingConnectionFactoryUnitTests {
|
||||
|
||||
ConnectionFactory delegate = mock(ConnectionFactory.class);
|
||||
ConnectionFactory delegate = mock();
|
||||
|
||||
Connection connectionMock = mock(Connection.class);
|
||||
Connection connectionMock = mock();
|
||||
|
||||
DelegatingConnectionFactory connectionFactory = new ExampleConnectionFactory(delegate);
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ import static org.mockito.BDDMockito.when;
|
||||
*/
|
||||
class R2dbcTransactionManagerUnitTests {
|
||||
|
||||
ConnectionFactory connectionFactoryMock = mock(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactoryMock = mock();
|
||||
|
||||
Connection connectionMock = mock(Connection.class);
|
||||
Connection connectionMock = mock();
|
||||
|
||||
private R2dbcTransactionManager tm;
|
||||
|
||||
@@ -226,7 +226,7 @@ class R2dbcTransactionManagerUnitTests {
|
||||
void appliesReadOnly() {
|
||||
when(connectionMock.commitTransaction()).thenReturn(Mono.empty());
|
||||
when(connectionMock.setTransactionIsolationLevel(any())).thenReturn(Mono.empty());
|
||||
Statement statement = mock(Statement.class);
|
||||
Statement statement = mock();
|
||||
when(connectionMock.createStatement(anyString())).thenReturn(statement);
|
||||
when(statement.execute()).thenReturn(Mono.empty());
|
||||
tm.setEnforceReadOnly(true);
|
||||
|
||||
@@ -103,8 +103,8 @@ class SingleConnectionFactoryUnitTests {
|
||||
|
||||
@Test
|
||||
void releaseConnectionShouldNotCloseConnection() {
|
||||
Connection connectionMock = mock(Connection.class);
|
||||
ConnectionFactoryMetadata metadata = mock(ConnectionFactoryMetadata.class);
|
||||
Connection connectionMock = mock();
|
||||
ConnectionFactoryMetadata metadata = mock();
|
||||
|
||||
SingleConnectionFactory factory = new SingleConnectionFactory(connectionMock, metadata, true);
|
||||
|
||||
@@ -119,9 +119,9 @@ class SingleConnectionFactoryUnitTests {
|
||||
|
||||
@Test
|
||||
void releaseConnectionShouldCloseUnrelatedConnection() {
|
||||
Connection connectionMock = mock(Connection.class);
|
||||
Connection otherConnection = mock(Connection.class);
|
||||
ConnectionFactoryMetadata metadata = mock(ConnectionFactoryMetadata.class);
|
||||
Connection connectionMock = mock();
|
||||
Connection otherConnection = mock();
|
||||
ConnectionFactoryMetadata metadata = mock();
|
||||
when(otherConnection.close()).thenReturn(Mono.empty());
|
||||
|
||||
SingleConnectionFactory factory = new SingleConnectionFactory(connectionMock, metadata, false);
|
||||
|
||||
@@ -45,13 +45,13 @@ import static org.mockito.BDDMockito.when;
|
||||
*/
|
||||
class TransactionAwareConnectionFactoryProxyUnitTests {
|
||||
|
||||
ConnectionFactory connectionFactoryMock = mock(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactoryMock = mock();
|
||||
|
||||
Connection connectionMock1 = mock(Connection.class);
|
||||
Connection connectionMock1 = mock();
|
||||
|
||||
Connection connectionMock2 = mock(Connection.class);
|
||||
Connection connectionMock2 = mock();
|
||||
|
||||
Connection connectionMock3 = mock(Connection.class);
|
||||
Connection connectionMock3 = mock();
|
||||
|
||||
R2dbcTransactionManager tm;
|
||||
|
||||
|
||||
@@ -39,11 +39,11 @@ import static org.mockito.BDDMockito.when;
|
||||
*/
|
||||
class CompositeDatabasePopulatorTests {
|
||||
|
||||
Connection mockedConnection = mock(Connection.class);
|
||||
Connection mockedConnection = mock();
|
||||
|
||||
DatabasePopulator mockedDatabasePopulator1 = mock(DatabasePopulator.class);
|
||||
DatabasePopulator mockedDatabasePopulator1 = mock();
|
||||
|
||||
DatabasePopulator mockedDatabasePopulator2 = mock(DatabasePopulator.class);
|
||||
DatabasePopulator mockedDatabasePopulator2 = mock();
|
||||
|
||||
|
||||
@BeforeEach
|
||||
|
||||
@@ -36,7 +36,7 @@ class ConnectionFactoryInitializerUnitTests {
|
||||
|
||||
AtomicBoolean called = new AtomicBoolean();
|
||||
|
||||
DatabasePopulator populator = mock(DatabasePopulator.class);
|
||||
DatabasePopulator populator = mock();
|
||||
|
||||
MockConnection connection = MockConnection.builder().build();
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ import static org.mockito.BDDMockito.mock;
|
||||
*/
|
||||
class ResourceDatabasePopulatorUnitTests {
|
||||
|
||||
private static final Resource script1 = mock(Resource.class);
|
||||
private static final Resource script2 = mock(Resource.class);
|
||||
private static final Resource script3 = mock(Resource.class);
|
||||
private static final Resource script1 = mock();
|
||||
private static final Resource script2 = mock();
|
||||
private static final Resource script3 = mock();
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -62,7 +62,7 @@ public class BeanFactoryConnectionFactoryLookupUnitTests {
|
||||
|
||||
@Test
|
||||
public void shouldLookupWhereBeanFactoryYieldsNonConnectionFactoryType() {
|
||||
BeanFactory beanFactory = mock(BeanFactory.class);
|
||||
BeanFactory beanFactory = mock();
|
||||
|
||||
when(beanFactory.getBean(CONNECTION_FACTORY_BEAN_NAME,
|
||||
ConnectionFactory.class)).thenThrow(
|
||||
|
||||
@@ -76,7 +76,7 @@ class DefaultDatabaseClientUnitTests {
|
||||
@BeforeEach
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
void before() {
|
||||
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactory = mock();
|
||||
|
||||
when(connectionFactory.create()).thenReturn((Publisher) Mono.just(connection));
|
||||
when(connection.close()).thenReturn(Mono.empty());
|
||||
@@ -88,7 +88,7 @@ class DefaultDatabaseClientUnitTests {
|
||||
|
||||
@Test
|
||||
void connectionFactoryIsExposed() {
|
||||
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactory = mock();
|
||||
DatabaseClient databaseClient = DatabaseClient.builder()
|
||||
.connectionFactory(connectionFactory)
|
||||
.bindMarkers(BindMarkersFactory.anonymous("?")).build();
|
||||
@@ -224,7 +224,7 @@ class DefaultDatabaseClientUnitTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void rowsUpdatedShouldEmitSingleValue() {
|
||||
Result result = mock(Result.class);
|
||||
Result result = mock();
|
||||
when(result.getRowsUpdated()).thenReturn(Mono.empty(), Mono.just(2L), Flux.just(1L, 2L, 3L));
|
||||
mockStatementFor("DROP TABLE tab;", result);
|
||||
|
||||
@@ -399,7 +399,7 @@ class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
private Statement mockStatementFor(@Nullable String sql, @Nullable Result result) {
|
||||
Statement statement = mock(Statement.class);
|
||||
Statement statement = mock();
|
||||
when(connection.createStatement(sql == null ? anyString() : eq(sql))).thenReturn(statement);
|
||||
when(statement.returnGeneratedValues(anyString())).thenReturn(statement);
|
||||
when(statement.returnGeneratedValues()).thenReturn(statement);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
namedParams.addValue("a", Arrays.asList(new Object[] { "Walter", "Heisenberg" },
|
||||
new Object[] { "Walt Jr.", "Flynn" }));
|
||||
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
PreparedOperation<?> operation = NamedParameterUtils.substituteNamedParameters(
|
||||
"xxx :a", BIND_MARKERS, namedParams);
|
||||
|
||||
@@ -42,7 +42,7 @@ class AnonymousBindMarkersUnitTests {
|
||||
|
||||
@Test
|
||||
public void shouldBindByIndex() {
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
BindMarkers bindMarkers = BindMarkersFactory.anonymous("?").create();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
|
||||
class BindingsUnitTests {
|
||||
|
||||
BindMarkersFactory markersFactory = BindMarkersFactory.indexed("$", 1);
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
@Test
|
||||
void shouldCreateBindings() {
|
||||
|
||||
@@ -42,7 +42,7 @@ class IndexedBindMarkersUnitTests {
|
||||
|
||||
@Test
|
||||
void shouldCreateNewBindMarkersWithOffset() {
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
BindMarkers bindMarkers = BindMarkersFactory.indexed("$", 1).create();
|
||||
|
||||
@@ -77,7 +77,7 @@ class IndexedBindMarkersUnitTests {
|
||||
@Test
|
||||
void bindValueShouldBindByIndex() {
|
||||
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
BindMarkers bindMarkers = BindMarkersFactory.indexed("$", 0).create();
|
||||
|
||||
@@ -90,7 +90,7 @@ class IndexedBindMarkersUnitTests {
|
||||
|
||||
@Test
|
||||
void bindNullShouldBindByIndex() {
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
BindMarkers bindMarkers = BindMarkersFactory.indexed("$", 0).create();
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class NamedBindMarkersUnitTests {
|
||||
|
||||
@Test
|
||||
void bindValueShouldBindByName() {
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
BindMarkers bindMarkers = BindMarkersFactory.named("@", "p", 32).create();
|
||||
|
||||
@@ -102,7 +102,7 @@ class NamedBindMarkersUnitTests {
|
||||
|
||||
@Test
|
||||
void bindNullShouldBindByName() {
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
BindTarget bindTarget = mock();
|
||||
|
||||
BindMarkers bindMarkers = BindMarkersFactory.named("@", "p", 32).create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user