This commit is contained in:
Stéphane Nicoll
2024-01-08 11:16:11 +01:00
parent 8552e149b5
commit 2d3b02a89d
36 changed files with 618 additions and 633 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,12 +40,12 @@ import org.springframework.r2dbc.UncategorizedR2dbcException;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link ConnectionFactoryUtils}.
* Tests for {@link ConnectionFactoryUtils}.
*
* @author Mark Paluch
* @author Juergen Hoeller
*/
class ConnectionFactoryUtilsUnitTests {
class ConnectionFactoryUtilsTests {
@Test
void shouldTranslateTransientResourceException() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,11 +26,11 @@ import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link DelegatingConnectionFactory}.
* Tests for {@link DelegatingConnectionFactory}.
*
* @author Mark Paluch
*/
class DelegatingConnectionFactoryUnitTests {
class DelegatingConnectionFactoryTests {
ConnectionFactory delegate = mock();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,12 +55,12 @@ import static org.mockito.BDDMockito.verifyNoMoreInteractions;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link R2dbcTransactionManager}.
* Tests for {@link R2dbcTransactionManager}.
*
* @author Mark Paluch
* @author Juergen Hoeller
*/
class R2dbcTransactionManagerUnitTests {
class R2dbcTransactionManagerTests {
ConnectionFactory connectionFactoryMock = mock();
@@ -624,7 +624,7 @@ class R2dbcTransactionManagerUnitTests {
private static class TestTransactionSynchronization implements TransactionSynchronization {
private int status;
private final int status;
public boolean beforeCommitCalled;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,11 +33,11 @@ import static org.mockito.BDDMockito.verify;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link SingleConnectionFactory}.
* Tests for {@link SingleConnectionFactory}.
*
* @author Mark Paluch
*/
class SingleConnectionFactoryUnitTests {
class SingleConnectionFactoryTests {
@Test
void shouldAllocateSameConnection() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,12 +38,12 @@ import static org.mockito.BDDMockito.verifyNoInteractions;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link TransactionAwareConnectionFactoryProxy}.
* Tests for {@link TransactionAwareConnectionFactoryProxy}.
*
* @author Mark Paluch
* @author Christoph Strobl
*/
class TransactionAwareConnectionFactoryProxyUnitTests {
class TransactionAwareConnectionFactoryProxyTests {
ConnectionFactory connectionFactoryMock = mock();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,11 +28,11 @@ import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link ConnectionFactoryInitializer}.
* Tests for {@link ConnectionFactoryInitializer}.
*
* @author Mark Paluch
*/
class ConnectionFactoryInitializerUnitTests {
class ConnectionFactoryInitializerTests {
AtomicBoolean called = new AtomicBoolean();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,12 +25,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.mockito.BDDMockito.mock;
/**
* Unit tests for {@link ResourceDatabasePopulator}.
* Tests for {@link ResourceDatabasePopulator}.
*
* @author Sam Brannen
* @author Mark Paluch
*/
class ResourceDatabasePopulatorUnitTests {
class ResourceDatabasePopulatorTests {
private static final Resource script1 = mock();
private static final Resource script2 = mock();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import static org.springframework.r2dbc.connection.init.ScriptUtils.DEFAULT_COMM
import static org.springframework.r2dbc.connection.init.ScriptUtils.DEFAULT_STATEMENT_SEPARATOR;
/**
* Unit tests for {@link ScriptUtils}.
* Tests for {@link ScriptUtils}.
*
* @author Thomas Risberg
* @author Sam Brannen
@@ -44,10 +44,10 @@ import static org.springframework.r2dbc.connection.init.ScriptUtils.DEFAULT_STAT
* @author Mark Paluch
* @since 5.3
*/
public class ScriptUtilsUnitTests {
class ScriptUtilsTests {
@Test
public void splitSqlScriptDelimitedWithSemicolon() {
void splitSqlScriptDelimitedWithSemicolon() {
String rawStatement1 = "insert into customer (id, name)\nvalues (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')";
String cleanedStatement1 = "insert into customer (id, name) values (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')";
String rawStatement2 = "insert into orders(id, order_date, customer_id)\nvalues (1, '2008-01-02', 2)";
@@ -64,7 +64,7 @@ public class ScriptUtilsUnitTests {
}
@Test
public void splitSqlScriptDelimitedWithNewLine() {
void splitSqlScriptDelimitedWithNewLine() {
String statement1 = "insert into customer (id, name) values (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')";
String statement2 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)";
String statement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)";
@@ -78,7 +78,7 @@ public class ScriptUtilsUnitTests {
}
@Test
public void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() {
void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() {
String statement1 = "do something";
String statement2 = "do something else";
@@ -103,7 +103,7 @@ public class ScriptUtilsUnitTests {
}
@Test // SPR-11560
public void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception {
public void readAndSplitScriptWithMultipleNewlinesAsSeparator() {
String script = readScript("db-test-data-multi-newline.sql");
List<String> statements = splitSqlScript(script, "\n\n");
@@ -114,19 +114,19 @@ public class ScriptUtilsUnitTests {
}
@Test
public void readAndSplitScriptContainingComments() throws Exception {
void readAndSplitScriptContainingComments() {
String script = readScript("test-data-with-comments.sql");
splitScriptContainingComments(script, DEFAULT_COMMENT_PREFIXES);
}
@Test
public void readAndSplitScriptContainingCommentsWithWindowsLineEnding() throws Exception {
void readAndSplitScriptContainingCommentsWithWindowsLineEnding() {
String script = readScript("test-data-with-comments.sql").replaceAll("\n", "\r\n");
splitScriptContainingComments(script, DEFAULT_COMMENT_PREFIXES);
}
@Test
public void readAndSplitScriptContainingCommentsWithMultiplePrefixes() throws Exception {
void readAndSplitScriptContainingCommentsWithMultiplePrefixes() {
String script = readScript("test-data-with-multi-prefix-comments.sql");
splitScriptContainingComments(script, "--", "#", "^");
}
@@ -145,7 +145,7 @@ public class ScriptUtilsUnitTests {
}
@Test // SPR-10330
public void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Exception {
public void readAndSplitScriptContainingCommentsWithLeadingTabs() {
String script = readScript("test-data-with-comments-and-leading-tabs.sql");
List<String> statements = splitSqlScript(script, ";");
@@ -157,7 +157,7 @@ public class ScriptUtilsUnitTests {
}
@Test // SPR-9531
public void readAndSplitScriptContainingMultiLineComments() throws Exception {
public void readAndSplitScriptContainingMultiLineComments() {
String script = readScript("test-data-with-multi-line-comments.sql");
List<String> statements = splitSqlScript(script, ";");
@@ -168,7 +168,7 @@ public class ScriptUtilsUnitTests {
}
@Test
public void readAndSplitScriptContainingMultiLineNestedComments() throws Exception {
void readAndSplitScriptContainingMultiLineNestedComments() {
String script = readScript("test-data-with-multi-line-nested-comments.sql");
List<String> statements = splitSqlScript(script, ";");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Unit tests for {@link AbstractRoutingConnectionFactory}.
* Tests for {@link AbstractRoutingConnectionFactory}.
*
* @author Mark Paluch
* @author Jens Schauder
*/
@ExtendWith(MockitoExtension.class)
class AbstractRoutingConnectionFactoryUnitTests {
class AbstractRoutingConnectionFactoryTests {
private static final String ROUTING_KEY = "routingKey";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,12 +32,12 @@ import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link BeanFactoryConnectionFactoryLookup}.
* Tests for {@link BeanFactoryConnectionFactoryLookup}.
*
* @author Mark Paluch
*/
@ExtendWith(MockitoExtension.class)
public class BeanFactoryConnectionFactoryLookupUnitTests {
public class BeanFactoryConnectionFactoryLookupTests {
private static final String CONNECTION_FACTORY_BEAN_NAME = "connectionFactory";
@@ -46,7 +46,7 @@ public class BeanFactoryConnectionFactoryLookupUnitTests {
@Test
public void shouldLookupConnectionFactory() {
void shouldLookupConnectionFactory() {
DummyConnectionFactory expectedConnectionFactory = new DummyConnectionFactory();
when(beanFactory.getBean(CONNECTION_FACTORY_BEAN_NAME, ConnectionFactory.class))
.thenReturn(expectedConnectionFactory);
@@ -60,7 +60,7 @@ public class BeanFactoryConnectionFactoryLookupUnitTests {
}
@Test
public void shouldLookupWhereBeanFactoryYieldsNonConnectionFactoryType() {
void shouldLookupWhereBeanFactoryYieldsNonConnectionFactoryType() {
BeanFactory beanFactory = mock();
when(beanFactory.getBean(CONNECTION_FACTORY_BEAN_NAME, ConnectionFactory.class))
.thenThrow(new BeanNotOfRequiredTypeException(
@@ -72,7 +72,7 @@ public class BeanFactoryConnectionFactoryLookupUnitTests {
}
@Test
public void shouldLookupWhereBeanFactoryHasNotBeenSupplied() {
void shouldLookupWhereBeanFactoryHasNotBeenSupplied() {
BeanFactoryConnectionFactoryLookup lookup = new BeanFactoryConnectionFactoryLookup();
assertThatThrownBy(() -> lookup.getConnectionFactory(CONNECTION_FACTORY_BEAN_NAME))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,17 +26,17 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Unit tests for {@link MapConnectionFactoryLookup}.
* Tests for {@link MapConnectionFactoryLookup}.
*
* @author Mark Paluch
*/
public class MapConnectionFactoryLookupUnitTests {
class MapConnectionFactoryLookupTests {
private static final String CONNECTION_FACTORY_NAME = "connectionFactory";
@Test
public void getConnectionFactoriesReturnsUnmodifiableMap() {
void getConnectionFactoriesReturnsUnmodifiableMap() {
MapConnectionFactoryLookup lookup = new MapConnectionFactoryLookup();
Map<String, ConnectionFactory> connectionFactories = lookup.getConnectionFactories();
@@ -45,7 +45,7 @@ public class MapConnectionFactoryLookupUnitTests {
}
@Test
public void shouldLookupConnectionFactory() {
void shouldLookupConnectionFactory() {
Map<String, ConnectionFactory> connectionFactories = new HashMap<>();
DummyConnectionFactory expectedConnectionFactory = new DummyConnectionFactory();
connectionFactories.put(CONNECTION_FACTORY_NAME, expectedConnectionFactory);
@@ -58,7 +58,7 @@ public class MapConnectionFactoryLookupUnitTests {
}
@Test
public void addingConnectionFactoryPermitsOverride() {
void addingConnectionFactoryPermitsOverride() {
Map<String, ConnectionFactory> connectionFactories = new HashMap<>();
DummyConnectionFactory overriddenConnectionFactory = new DummyConnectionFactory();
DummyConnectionFactory expectedConnectionFactory = new DummyConnectionFactory();
@@ -84,7 +84,7 @@ public class MapConnectionFactoryLookupUnitTests {
}
@Test
public void getConnectionFactoryWhereSuppliedMapHasNoEntryForSpecifiedKey() {
void getConnectionFactoryWhereSuppliedMapHasNoEntryForSpecifiedKey() {
MapConnectionFactoryLookup lookup = new MapConnectionFactoryLookup();
assertThatThrownBy(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
@Test
public void executeInsert() {
void executeInsert() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
databaseClient.sql("INSERT INTO legoset (id, name, manual) VALUES(:id, :name, :manual)")
@@ -97,7 +97,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
}
@Test
public void executeInsertWithMap() {
void executeInsertWithMap() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
databaseClient.sql("INSERT INTO legoset (id, name, manual) VALUES(:id, :name, :manual)")
@@ -118,7 +118,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
}
@Test
public void executeInsertWithRecords() {
void executeInsertWithRecords() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
databaseClient.sql("INSERT INTO legoset (id, name, manual) VALUES(:id, :name, :manual)")
@@ -137,7 +137,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
}
@Test
public void shouldTranslateDuplicateKeyException() {
void shouldTranslateDuplicateKeyException() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
executeInsert();
@@ -156,7 +156,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
}
@Test
public void executeDeferred() {
void executeDeferred() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
databaseClient.sql(() -> "INSERT INTO legoset (id, name, manual) VALUES(:id, :name, :manual)")
@@ -176,7 +176,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
}
@Test
public void shouldEmitGeneratedKey() {
void shouldEmitGeneratedKey() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
databaseClient.sql(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,7 +111,7 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
@Test
public void executeInsertInTransaction() {
void executeInsertInTransaction() {
Flux<Long> longFlux = databaseClient
.sql(getInsertIntoLegosetStatement())
.bind(0, 42055)
@@ -133,7 +133,7 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
}
@Test
public void shouldRollbackTransaction() {
void shouldRollbackTransaction() {
Mono<Object> integerFlux = databaseClient.sql(getInsertIntoLegosetStatement())
.bind(0, 42055)
.bind(1, "SCHAUFELRADBAGGER")
@@ -155,7 +155,7 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
}
@Test
public void shouldRollbackTransactionUsingTransactionalOperator() {
void shouldRollbackTransactionUsingTransactionalOperator() {
DatabaseClient databaseClient = DatabaseClient.create(connectionFactory);
TransactionalOperator transactionalOperator = TransactionalOperator

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ import static org.mockito.BDDMockito.verifyNoMoreInteractions;
import static org.mockito.BDDMockito.when;
/**
* Unit tests for {@link DefaultDatabaseClient}.
* Tests for {@link DefaultDatabaseClient}.
*
* @author Mark Paluch
* @author Ferdinand Jacobs
@@ -68,7 +68,7 @@ import static org.mockito.BDDMockito.when;
* @author Simon Baslé
*/
@MockitoSettings(strictness = Strictness.LENIENT)
class DefaultDatabaseClientUnitTests {
class DefaultDatabaseClientTests {
@Mock
private Connection connection;
@@ -499,21 +499,9 @@ class DefaultDatabaseClientUnitTests {
}
static class ParameterBean {
private final String key;
public ParameterBean(String key) {
this.key = key;
}
public String getKey() {
return key;
}
}
record ParameterBean(String key) {}
record ParameterRecord(String key) {
}
record ParameterRecord(String key) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @since 6.1
*/
public class H2DatabaseClientContextIntegrationTests extends H2DatabaseClientIntegrationTests {
class H2DatabaseClientContextIntegrationTests extends H2DatabaseClientIntegrationTests {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import io.r2dbc.spi.ConnectionFactory;
*
* @author Mark Paluch
*/
public class H2DatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
class H2DatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
private static final String CREATE_TABLE_LEGOSET = """
CREATE TABLE legoset (

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import io.r2dbc.spi.ConnectionFactory;
*
* @author Mark Paluch
*/
public class H2TransactionalDatabaseClientIntegrationTests extends AbstractTransactionalDatabaseClientIntegrationTests {
class H2TransactionalDatabaseClientIntegrationTests extends AbstractTransactionalDatabaseClientIntegrationTests {
private static final String CREATE_TABLE_LEGOSET = """
CREATE TABLE legoset (

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,19 +35,19 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Unit tests for {@link NamedParameterUtils}.
* Tests for {@link NamedParameterUtils}.
*
* @author Mark Paluch
* @author Jens Schauder
* @author Anton Naydenov
*/
public class NamedParameterUtilsUnitTests {
class NamedParameterUtilsTests {
private final BindMarkersFactory BIND_MARKERS = BindMarkersFactory.indexed("$", 1);
@Test
public void shouldParseSql() {
void shouldParseSql() {
String sql = "xxx :a yyyy :b :c :a zzzzz";
ParsedSql psql = NamedParameterUtils.parseSqlStatement(sql);
assertThat(psql.getParameterNames()).containsExactly("a", "b", "c", "a");
@@ -66,7 +66,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void substituteNamedParameters() {
void substituteNamedParameters() {
MapBindParameterSource namedParams = new MapBindParameterSource(new HashMap<>());
namedParams.addValue("a", "a").addValue("b", "b").addValue("c", "c");
@@ -82,7 +82,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void substituteObjectArray() {
void substituteObjectArray() {
MapBindParameterSource namedParams = new MapBindParameterSource(new HashMap<>());
namedParams.addValue("a",
Arrays.asList(new Object[] {"Walter", "Heisenberg"},
@@ -95,7 +95,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void shouldBindObjectArray() {
void shouldBindObjectArray() {
MapBindParameterSource namedParams = new MapBindParameterSource(new HashMap<>());
namedParams.addValue("a",
Arrays.asList(new Object[] {"Walter", "Heisenberg"},
@@ -114,7 +114,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlContainingComments() {
void parseSqlContainingComments() {
String sql1 = "/*+ HINT */ xxx /* comment ? */ :a yyyy :b :c :a zzzzz -- :xx XX\n";
ParsedSql psql1 = NamedParameterUtils.parseSqlStatement(sql1);
@@ -133,7 +133,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithPostgresCasting() {
void parseSqlStatementWithPostgresCasting() {
String expectedSql = "select 'first name' from artists where id = $1 and birth_date=$2::timestamp";
String sql = "select 'first name' from artists where id = :id and birth_date=:birthDate::timestamp";
@@ -145,7 +145,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithPostgresContainedOperator() {
void parseSqlStatementWithPostgresContainedOperator() {
String expectedSql = "select 'first name' from artists where info->'stat'->'albums' = ?? $1 and '[\"1\",\"2\",\"3\"]'::jsonb ?? '4'";
String sql = "select 'first name' from artists where info->'stat'->'albums' = ?? :album and '[\"1\",\"2\",\"3\"]'::jsonb ?? '4'";
@@ -155,7 +155,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithPostgresAnyArrayStringsExistsOperator() {
void parseSqlStatementWithPostgresAnyArrayStringsExistsOperator() {
String expectedSql = "select '[\"3\", \"11\"]'::jsonb ?| '{1,3,11,12,17}'::text[]";
String sql = "select '[\"3\", \"11\"]'::jsonb ?| '{1,3,11,12,17}'::text[]";
@@ -165,7 +165,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithPostgresAllArrayStringsExistsOperator() {
void parseSqlStatementWithPostgresAllArrayStringsExistsOperator() {
String expectedSql = "select '[\"3\", \"11\"]'::jsonb ?& '{1,3,11,12,17}'::text[] AND $1 = 'Back in Black'";
String sql = "select '[\"3\", \"11\"]'::jsonb ?& '{1,3,11,12,17}'::text[] AND :album = 'Back in Black'";
@@ -175,7 +175,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithEscapedColon() {
void parseSqlStatementWithEscapedColon() {
String expectedSql = "select '0\\:0' as a, foo from bar where baz < DATE($1 23:59:59) and baz = $2";
String sql = "select '0\\:0' as a, foo from bar where baz < DATE(:p1 23\\:59\\:59) and baz = :p2";
@@ -185,7 +185,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithBracketDelimitedParameterNames() {
void parseSqlStatementWithBracketDelimitedParameterNames() {
String expectedSql = "select foo from bar where baz = b$1$2z";
String sql = "select foo from bar where baz = b:{p1}:{p2}z";
@@ -195,7 +195,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithEmptyBracketsOrBracketsInQuotes() {
void parseSqlStatementWithEmptyBracketsOrBracketsInQuotes() {
String expectedSql = "select foo from bar where baz = b:{}z";
String sql = "select foo from bar where baz = b:{}z";
@@ -212,7 +212,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithSingleLetterInBrackets() {
void parseSqlStatementWithSingleLetterInBrackets() {
String expectedSql = "select foo from bar where baz = b$1z";
String sql = "select foo from bar where baz = b:{p}z";
@@ -222,7 +222,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithLogicalAnd() {
void parseSqlStatementWithLogicalAnd() {
String expectedSql = "xxx & yyyy";
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(expectedSql);
@@ -230,21 +230,21 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void substituteNamedParametersWithLogicalAnd() {
void substituteNamedParametersWithLogicalAnd() {
String expectedSql = "xxx & yyyy";
assertThat(expand(expectedSql)).isEqualTo(expectedSql);
}
@Test
public void variableAssignmentOperator() {
void variableAssignmentOperator() {
String expectedSql = "x := 1";
assertThat(expand(expectedSql)).isEqualTo(expectedSql);
}
@Test
public void parseSqlStatementWithQuotedSingleQuote() {
void parseSqlStatementWithQuotedSingleQuote() {
String sql = "SELECT ':foo'':doo', :xxx FROM DUAL";
ParsedSql psql = NamedParameterUtils.parseSqlStatement(sql);
@@ -253,7 +253,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithQuotesAndCommentBefore() {
void parseSqlStatementWithQuotesAndCommentBefore() {
String sql = "SELECT /*:doo*/':foo', :xxx FROM DUAL";
ParsedSql psql = NamedParameterUtils.parseSqlStatement(sql);
@@ -262,7 +262,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void parseSqlStatementWithQuotesAndCommentAfter() {
void parseSqlStatementWithQuotesAndCommentAfter() {
String sql2 = "SELECT ':foo'/*:doo*/, :xxx FROM DUAL";
ParsedSql psql2 = NamedParameterUtils.parseSqlStatement(sql2);
@@ -288,7 +288,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void shouldAllowParsingMultipleUseOfParameter() {
void shouldAllowParsingMultipleUseOfParameter() {
String sql = "SELECT * FROM person where name = :id or lastname = :id";
ParsedSql parsed = NamedParameterUtils.parseSqlStatement(sql);
@@ -298,7 +298,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void multipleEqualParameterReferencesBindsValueOnce() {
void multipleEqualParameterReferencesBindsValueOnce() {
String sql = "SELECT * FROM person where name = :id or lastname = :id";
BindMarkersFactory factory = BindMarkersFactory.indexed("$", 0);
@@ -332,7 +332,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void multipleEqualCollectionParameterReferencesBindsValueOnce() {
void multipleEqualCollectionParameterReferencesBindsValueOnce() {
String sql = "SELECT * FROM person where name IN (:ids) or lastname IN (:ids)";
BindMarkersFactory factory = BindMarkersFactory.indexed("$", 0);
@@ -373,7 +373,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void multipleEqualParameterReferencesForAnonymousMarkersBindsValueMultipleTimes() {
void multipleEqualParameterReferencesForAnonymousMarkersBindsValueMultipleTimes() {
String sql = "SELECT * FROM person where name = :id or lastname = :id";
BindMarkersFactory factory = BindMarkersFactory.anonymous("?");
@@ -410,7 +410,7 @@ public class NamedParameterUtilsUnitTests {
}
@Test
public void multipleEqualParameterReferencesBindsNullOnce() {
void multipleEqualParameterReferencesBindsNullOnce() {
String sql = "SELECT * FROM person where name = :id or lastname = :id";
BindMarkersFactory factory = BindMarkersFactory.indexed("$", 0);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,10 +57,9 @@ class R2dbcBeanPropertyRowMapperTests {
@Test
void mappingRowSimpleObject() {
MockRow mockRow = SIMPLE_PERSON_ROW;
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
Person result = mapper.apply(mockRow);
Person result = mapper.apply(SIMPLE_PERSON_ROW);
assertThat(result.firstName).as("firstName").isEqualTo("John");
assertThat(result.lastName).as("lastName").isEqualTo("Doe");
@@ -69,10 +68,9 @@ class R2dbcBeanPropertyRowMapperTests {
@Test
void mappingRowMissingAttributeAccepted() {
MockRow mockRow = SIMPLE_PERSON_ROW;
BeanPropertyRowMapper<ExtendedPerson> mapper = new BeanPropertyRowMapper<>(ExtendedPerson.class);
ExtendedPerson result = mapper.apply(mockRow);
ExtendedPerson result = mapper.apply(SIMPLE_PERSON_ROW);
assertThat(result.firstName).as("firstName").isEqualTo("John");
assertThat(result.lastName).as("lastName").isEqualTo("Doe");
@@ -82,10 +80,9 @@ class R2dbcBeanPropertyRowMapperTests {
@Test
void mappingRowWithDifferentName() {
MockRow mockRow = EMAIL_PERSON_ROW;
BeanPropertyRowMapper<EmailPerson> mapper = new BeanPropertyRowMapper<>(EmailPerson.class);
EmailPerson result = mapper.apply(mockRow);
EmailPerson result = mapper.apply(EMAIL_PERSON_ROW);
assertThat(result.firstName).as("firstName").isEqualTo("John");
assertThat(result.lastName).as("lastName").isEqualTo("Doe");
@@ -95,11 +92,10 @@ class R2dbcBeanPropertyRowMapperTests {
@Test
void rowTypeAndMappingTypeMisaligned() {
MockRow mockRow = EXTENDED_PERSON_ROW;
BeanPropertyRowMapper<TypeMismatchExtendedPerson> mapper = new BeanPropertyRowMapper<>(TypeMismatchExtendedPerson.class);
assertThatExceptionOfType(TypeMismatchException.class)
.isThrownBy(() -> mapper.apply(mockRow))
.isThrownBy(() -> mapper.apply(EXTENDED_PERSON_ROW))
.withMessage("Failed to convert property value of type 'java.lang.String' to required type "
+ "'java.lang.String' for property 'address'; simulating type mismatch for address");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +38,10 @@ class R2dbcDataClassRowMapperTests {
@Test
void staticQueryWithDataClass() {
MockRow mockRow = MOCK_ROW; // uses name, age, birth_date
DataClassRowMapper<ConstructorPerson> mapper = new DataClassRowMapper<>(ConstructorPerson.class);
ConstructorPerson person = mapper.apply(mockRow);
// uses name, age, birth_date
ConstructorPerson person = mapper.apply(MOCK_ROW);
assertThat(person.name).as("name").isEqualTo("Bubba");
assertThat(person.age).as("age").isEqualTo(22L);
@@ -63,9 +63,10 @@ class R2dbcDataClassRowMapperTests {
@Test
void staticQueryWithDataRecord() {
MockRow mockRow = MOCK_ROW; // uses name, age, birth_date, balance
DataClassRowMapper<RecordPerson> mapper = new DataClassRowMapper<>(RecordPerson.class);
RecordPerson person = mapper.apply(mockRow);
// uses name, age, birth_date, balance
RecordPerson person = mapper.apply(MOCK_ROW);
assertThat(person.name()).isEqualTo("Bubba");
assertThat(person.age()).isEqualTo(22L);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,14 +23,14 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Unit tests for {@link AnonymousBindMarkers}.
* Tests for {@link AnonymousBindMarkers}.
*
* @author Mark Paluch
*/
class AnonymousBindMarkersUnitTests {
class AnonymousBindMarkersTests {
@Test
public void shouldCreateNewBindMarkers() {
void shouldCreateNewBindMarkers() {
BindMarkersFactory factory = BindMarkersFactory.anonymous("?");
BindMarkers bindMarkers1 = factory.create();
@@ -41,7 +41,7 @@ class AnonymousBindMarkersUnitTests {
}
@Test
public void shouldBindByIndex() {
void shouldBindByIndex() {
BindTarget bindTarget = mock();
BindMarkers bindMarkers = BindMarkersFactory.anonymous("?").create();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,11 +25,11 @@ import org.reactivestreams.Publisher;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link BindMarkersFactoryResolver}.
* Tests for {@link BindMarkersFactoryResolver}.
*
* @author Mark Paluch
*/
class BindMarkersFactoryResolverUnitTests {
class BindMarkersFactoryResolverTests {
@Test
void shouldReturnBindMarkersFactoryForH2() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,11 +27,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Unit tests for {@link Bindings}.
* Tests for {@link Bindings}.
*
* @author Mark Paluch
*/
class BindingsUnitTests {
class BindingsTests {
BindMarkersFactory markersFactory = BindMarkersFactory.indexed("$", 1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,11 +23,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Unit tests for {@link IndexedBindMarkers}.
* Tests for {@link IndexedBindMarkers}.
*
* @author Mark Paluch
*/
class IndexedBindMarkersUnitTests {
class IndexedBindMarkersTests {
@Test
void shouldCreateNewBindMarkers() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,11 +25,11 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Unit tests for {@link NamedBindMarkers}.
* Tests for {@link NamedBindMarkers}.
*
* @author Mark Paluch
*/
class NamedBindMarkersUnitTests {
class NamedBindMarkersTests {
@Test
void shouldCreateNewBindMarkers() {