#467 - Migrate tests to JUnit 5.
Migrate also ExternalDatabase from JUnit rule to BeforeAllCallback and RegisterExtension.
This commit is contained in:
@@ -23,7 +23,7 @@ import de.schauderhaft.degraph.configuration.NamedPattern;
|
||||
import scala.runtime.AbstractFunction1;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test package dependencies for violations.
|
||||
|
||||
@@ -22,7 +22,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class AuditingUnitTests {
|
||||
class AuditingUnitTests {
|
||||
|
||||
@EnableR2dbcAuditing(auditorAwareRef = "myAuditor")
|
||||
static class AuditingConfiguration {
|
||||
@@ -58,7 +58,7 @@ public class AuditingUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-281
|
||||
public void enablesAuditingAndSetsPropertiesAccordingly() throws Exception {
|
||||
void enablesAuditingAndSetsPropertiesAccordingly() throws Exception {
|
||||
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AuditingConfiguration.class);
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ import lombok.NoArgsConstructor;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@@ -40,24 +40,24 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.r2dbc.core.DatabaseClient;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration test for {@link DatabaseClient} and repositories using H2.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class H2IntegrationTests {
|
||||
class H2IntegrationTests {
|
||||
|
||||
private JdbcTemplate jdbc = new JdbcTemplate(H2TestSupport.createDataSource());
|
||||
private final JdbcTemplate jdbc = new JdbcTemplate(H2TestSupport.createDataSource());
|
||||
|
||||
@Autowired DatabaseClient databaseClient;
|
||||
@Autowired H2Repository repository;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
try {
|
||||
jdbc.execute("DROP TABLE legoset");
|
||||
@@ -66,7 +66,7 @@ public class H2IntegrationTests {
|
||||
}
|
||||
|
||||
@Test // gh-109
|
||||
public void shouldSelectCountWithDatabaseClient() {
|
||||
void shouldSelectCountWithDatabaseClient() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (id, name, manual) VALUES(42055, 'SCHAUFELRADBAGGER', 12)");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class H2IntegrationTests {
|
||||
}
|
||||
|
||||
@Test // gh-109
|
||||
public void shouldSelectCountWithRepository() {
|
||||
void shouldSelectCountWithRepository() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (id, name, manual) VALUES(42055, 'SCHAUFELRADBAGGER', 12)");
|
||||
|
||||
|
||||
@@ -17,10 +17,12 @@ package org.springframework.data.r2dbc.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
@@ -30,21 +32,22 @@ import org.springframework.core.type.AnnotationMetadata;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class R2dbcAuditingRegistrarUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class R2dbcAuditingRegistrarUnitTests {
|
||||
|
||||
private R2dbcAuditingRegistrar registrar = new R2dbcAuditingRegistrar();
|
||||
private final R2dbcAuditingRegistrar registrar = new R2dbcAuditingRegistrar();
|
||||
|
||||
@Mock AnnotationMetadata metadata;
|
||||
@Mock BeanDefinitionRegistry registry;
|
||||
|
||||
@Test // gh-281
|
||||
public void rejectsNullAnnotationMetadata() {
|
||||
void rejectsNullAnnotationMetadata() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(null, registry));
|
||||
}
|
||||
|
||||
@Test // gh-281
|
||||
public void rejectsNullBeanDefinitionRegistry() {
|
||||
void rejectsNullBeanDefinitionRegistry() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(metadata, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.r2dbc.h2.H2ConnectionConfiguration;
|
||||
import io.r2dbc.h2.H2ConnectionFactory;
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -34,10 +34,10 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class R2dbcConfigurationIntegrationTests {
|
||||
class R2dbcConfigurationIntegrationTests {
|
||||
|
||||
@Test // gh-95
|
||||
public void shouldLookupConnectionFactoryThroughLocalCall() {
|
||||
void shouldLookupConnectionFactoryThroughLocalCall() {
|
||||
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
NonBeanConnectionFactoryConfiguration.class);
|
||||
@@ -53,7 +53,7 @@ public class R2dbcConfigurationIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // gh-95
|
||||
public void shouldLookupConnectionFactoryThroughLocalCallForExistingCustomBeans() {
|
||||
void shouldLookupConnectionFactoryThroughLocalCallForExistingCustomBeans() {
|
||||
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
CustomConnectionFactoryBeanNameConfiguration.class);
|
||||
@@ -73,7 +73,7 @@ public class R2dbcConfigurationIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // gh-95
|
||||
public void shouldRegisterConnectionFactory() {
|
||||
void shouldRegisterConnectionFactory() {
|
||||
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
BeanConnectionFactoryConfiguration.class);
|
||||
|
||||
@@ -22,8 +22,7 @@ import io.r2dbc.spi.Connection;
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.r2dbc.connectionfactory.DelegatingConnectionFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DelegatingConnectionFactory}.
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.r2dbc.spi.Wrapped;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SingleConnectionConnectionFactory}.
|
||||
|
||||
@@ -25,8 +25,8 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TransactionAwareConnectionFactoryProxyUnitTests {
|
||||
|
||||
private R2dbcTransactionManager tm;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
when(connectionFactoryMock.create()).thenReturn((Mono) Mono.just(connectionMock1),
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.r2dbc.connectionfactory.init;
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassRelativeResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -29,13 +29,13 @@ import org.springframework.data.r2dbc.core.DatabaseClient;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public abstract class AbstractDatabaseInitializationTests {
|
||||
abstract class AbstractDatabaseInitializationTests {
|
||||
|
||||
ClassRelativeResourceLoader resourceLoader = new ClassRelativeResourceLoader(getClass());
|
||||
private final ClassRelativeResourceLoader resourceLoader = new ClassRelativeResourceLoader(getClass());
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
|
||||
@Test
|
||||
public void scriptWithSingleLineCommentsAndFailedDrop() {
|
||||
void scriptWithSingleLineCommentsAndFailedDrop() {
|
||||
|
||||
databasePopulator.addScript(resource("db-schema-failed-drop-comments.sql"));
|
||||
databasePopulator.addScript(resource("db-test-data.sql"));
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractDatabaseInitializationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptWithStandardEscapedLiteral() {
|
||||
void scriptWithStandardEscapedLiteral() {
|
||||
|
||||
databasePopulator.addScript(defaultSchema());
|
||||
databasePopulator.addScript(resource("db-test-data-escaped-literal.sql"));
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractDatabaseInitializationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptWithMySqlEscapedLiteral() {
|
||||
void scriptWithMySqlEscapedLiteral() {
|
||||
|
||||
databasePopulator.addScript(defaultSchema());
|
||||
databasePopulator.addScript(resource("db-test-data-mysql-escaped-literal.sql"));
|
||||
@@ -75,7 +75,7 @@ public abstract class AbstractDatabaseInitializationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptWithMultipleStatements() {
|
||||
void scriptWithMultipleStatements() {
|
||||
|
||||
databasePopulator.addScript(defaultSchema());
|
||||
databasePopulator.addScript(resource("db-test-data-multiple.sql"));
|
||||
@@ -86,7 +86,7 @@ public abstract class AbstractDatabaseInitializationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptWithMultipleStatementsAndLongSeparator() {
|
||||
void scriptWithMultipleStatementsAndLongSeparator() {
|
||||
|
||||
databasePopulator.addScript(defaultSchema());
|
||||
databasePopulator.addScript(resource("db-test-data-endings.sql"));
|
||||
|
||||
@@ -24,31 +24,31 @@ import reactor.test.StepVerifier;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link CompositeDatabasePopulator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class CompositeDatabasePopulatorTests {
|
||||
class CompositeDatabasePopulatorTests {
|
||||
|
||||
Connection mockedConnection = mock(Connection.class);
|
||||
private final Connection mockedConnection = mock(Connection.class);
|
||||
|
||||
DatabasePopulator mockedDatabasePopulator1 = mock(DatabasePopulator.class);
|
||||
private final DatabasePopulator mockedDatabasePopulator1 = mock(DatabasePopulator.class);
|
||||
|
||||
DatabasePopulator mockedDatabasePopulator2 = mock(DatabasePopulator.class);
|
||||
private final DatabasePopulator mockedDatabasePopulator2 = mock(DatabasePopulator.class);
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
when(mockedDatabasePopulator1.populate(mockedConnection)).thenReturn(Mono.empty());
|
||||
when(mockedDatabasePopulator2.populate(mockedConnection)).thenReturn(Mono.empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPopulators() {
|
||||
void addPopulators() {
|
||||
|
||||
CompositeDatabasePopulator populator = new CompositeDatabasePopulator();
|
||||
populator.addPopulators(mockedDatabasePopulator1, mockedDatabasePopulator2);
|
||||
@@ -60,7 +60,7 @@ public class CompositeDatabasePopulatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setPopulatorsWithMultiple() {
|
||||
void setPopulatorsWithMultiple() {
|
||||
|
||||
CompositeDatabasePopulator populator = new CompositeDatabasePopulator();
|
||||
populator.setPopulators(mockedDatabasePopulator1, mockedDatabasePopulator2); // multiple
|
||||
@@ -72,7 +72,7 @@ public class CompositeDatabasePopulatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setPopulatorsForOverride() {
|
||||
void setPopulatorsForOverride() {
|
||||
|
||||
CompositeDatabasePopulator populator = new CompositeDatabasePopulator();
|
||||
populator.setPopulators(mockedDatabasePopulator1);
|
||||
@@ -85,7 +85,7 @@ public class CompositeDatabasePopulatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructWithVarargs() {
|
||||
void constructWithVarargs() {
|
||||
|
||||
CompositeDatabasePopulator populator = new CompositeDatabasePopulator(mockedDatabasePopulator1,
|
||||
mockedDatabasePopulator2);
|
||||
@@ -97,7 +97,7 @@ public class CompositeDatabasePopulatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructWithCollection() {
|
||||
void constructWithCollection() {
|
||||
|
||||
Set<DatabasePopulator> populators = new LinkedHashSet<>();
|
||||
populators.add(mockedDatabasePopulator1);
|
||||
|
||||
@@ -24,22 +24,23 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ConnectionFactoryInitializer}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ConnectionFactoryInitializerUnitTests {
|
||||
class ConnectionFactoryInitializerUnitTests {
|
||||
|
||||
AtomicBoolean called = new AtomicBoolean();
|
||||
DatabasePopulator populator = mock(DatabasePopulator.class);
|
||||
MockConnection connection = MockConnection.builder().build();
|
||||
MockConnectionFactory connectionFactory = MockConnectionFactory.builder().connection(connection).build();
|
||||
private final AtomicBoolean called = new AtomicBoolean();
|
||||
private final DatabasePopulator populator = mock(DatabasePopulator.class);
|
||||
private final MockConnection connection = MockConnection.builder().build();
|
||||
private final MockConnectionFactory connectionFactory = MockConnectionFactory.builder().connection(connection)
|
||||
.build();
|
||||
|
||||
@Test // gh-216
|
||||
public void shouldInitializeConnectionFactory() {
|
||||
void shouldInitializeConnectionFactory() {
|
||||
|
||||
when(populator.populate(any())).thenReturn(Mono.<Void> empty().doOnSubscribe(subscription -> called.set(true)));
|
||||
|
||||
@@ -53,7 +54,7 @@ public class ConnectionFactoryInitializerUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-216
|
||||
public void shouldCleanConnectionFactory() {
|
||||
void shouldCleanConnectionFactory() {
|
||||
|
||||
when(populator.populate(any())).thenReturn(Mono.<Void> empty().doOnSubscribe(subscription -> called.set(true)));
|
||||
|
||||
|
||||
@@ -21,18 +21,18 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link DatabasePopulator} using H2.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class H2DatabasePopulatorIntegrationTests extends AbstractDatabaseInitializationTests {
|
||||
class H2DatabasePopulatorIntegrationTests extends AbstractDatabaseInitializationTests {
|
||||
|
||||
UUID databaseName = UUID.randomUUID();
|
||||
private final UUID databaseName = UUID.randomUUID();
|
||||
|
||||
ConnectionFactory connectionFactory = ConnectionFactories
|
||||
private final ConnectionFactory connectionFactory = ConnectionFactories
|
||||
.get("r2dbc:h2:mem:///" + databaseName + "?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
|
||||
|
||||
@Override
|
||||
@@ -41,7 +41,7 @@ public class H2DatabasePopulatorIntegrationTests extends AbstractDatabaseInitial
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRunScript() {
|
||||
void shouldRunScript() {
|
||||
|
||||
databasePopulator.addScript(usersSchema());
|
||||
databasePopulator.addScript(resource("db-test-data-h2.sql"));
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.r2dbc.connectionfactory.init;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
@@ -27,38 +27,38 @@ import org.springframework.core.io.Resource;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ResourceDatabasePopulatorUnitTests {
|
||||
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);
|
||||
|
||||
@Test
|
||||
public void constructWithNullResource() {
|
||||
void constructWithNullResource() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ResourceDatabasePopulator((Resource) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructWithNullResourceArray() {
|
||||
void constructWithNullResourceArray() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ResourceDatabasePopulator((Resource[]) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructWithResource() {
|
||||
void constructWithResource() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(script1);
|
||||
assertThat(databasePopulator.scripts.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructWithMultipleResources() {
|
||||
void constructWithMultipleResources() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(script1, script2);
|
||||
assertThat(databasePopulator.scripts.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructWithMultipleResourcesAndThenAddScript() {
|
||||
void constructWithMultipleResourcesAndThenAddScript() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(script1, script2);
|
||||
assertThat(databasePopulator.scripts.size()).isEqualTo(2);
|
||||
@@ -68,35 +68,35 @@ public class ResourceDatabasePopulatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addScriptsWithNullResource() {
|
||||
void addScriptsWithNullResource() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> databasePopulator.addScripts((Resource) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addScriptsWithNullResourceArray() {
|
||||
void addScriptsWithNullResourceArray() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> databasePopulator.addScripts((Resource[]) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setScriptsWithNullResource() {
|
||||
void setScriptsWithNullResource() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> databasePopulator.setScripts((Resource) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setScriptsWithNullResourceArray() {
|
||||
void setScriptsWithNullResourceArray() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> databasePopulator.setScripts((Resource[]) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setScriptsAndThenAddScript() {
|
||||
void setScriptsAndThenAddScript() {
|
||||
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
assertThat(databasePopulator.scripts.size()).isEqualTo(0);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.assertj.core.util.Strings;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
@@ -32,10 +32,10 @@ import org.springframework.core.io.support.EncodedResource;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ScriptUtilsUnitTests {
|
||||
class ScriptUtilsUnitTests {
|
||||
|
||||
@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')";
|
||||
@@ -53,7 +53,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)";
|
||||
@@ -68,7 +68,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() {
|
||||
void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() {
|
||||
|
||||
String statement1 = "do something";
|
||||
String statement2 = "do something else";
|
||||
@@ -84,7 +84,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitScriptWithSingleQuotesNestedInsideDoubleQuotes() {
|
||||
void splitScriptWithSingleQuotesNestedInsideDoubleQuotes() {
|
||||
|
||||
String statement1 = "select '1' as \"Dogbert's owner's\" from dual";
|
||||
String statement2 = "select '2' as \"Dilbert's\" from dual";
|
||||
@@ -99,7 +99,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptWithMultipleNewlinesAsSeparator() {
|
||||
void readAndSplitScriptWithMultipleNewlinesAsSeparator() {
|
||||
|
||||
String script = readScript("db-test-data-multi-newline.sql");
|
||||
List<String> statements = new ArrayList<>();
|
||||
@@ -114,13 +114,13 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptContainingComments() {
|
||||
void readAndSplitScriptContainingComments() {
|
||||
String script = readScript("test-data-with-comments.sql");
|
||||
splitScriptContainingComments(script);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptContainingCommentsWithWindowsLineEnding() {
|
||||
void readAndSplitScriptContainingCommentsWithWindowsLineEnding() {
|
||||
String script = readScript("test-data-with-comments.sql").replaceAll("\n", "\r\n");
|
||||
splitScriptContainingComments(script);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptContainingCommentsWithLeadingTabs() {
|
||||
void readAndSplitScriptContainingCommentsWithLeadingTabs() {
|
||||
|
||||
String script = readScript("test-data-with-comments-and-leading-tabs.sql");
|
||||
List<String> statements = new ArrayList<>();
|
||||
@@ -153,7 +153,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptContainingMultiLineComments() {
|
||||
void readAndSplitScriptContainingMultiLineComments() {
|
||||
|
||||
String script = readScript("test-data-with-multi-line-comments.sql");
|
||||
List<String> statements = new ArrayList<>();
|
||||
@@ -166,7 +166,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAndSplitScriptContainingMultiLineNestedComments() {
|
||||
void readAndSplitScriptContainingMultiLineNestedComments() {
|
||||
|
||||
String script = readScript("test-data-with-multi-line-nested-comments.sql");
|
||||
List<String> statements = new ArrayList<>();
|
||||
@@ -179,7 +179,7 @@ public class ScriptUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsDelimiters() {
|
||||
void containsDelimiters() {
|
||||
|
||||
assertThat(ScriptUtils.containsSqlScriptDelimiters("select 1\n select ';'", ";")).isFalse();
|
||||
assertThat(ScriptUtils.containsSqlScriptDelimiters("select 1; select 2", ";")).isTrue();
|
||||
|
||||
@@ -23,11 +23,11 @@ import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import reactor.util.context.Context;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractRoutingConnectionFactory}.
|
||||
@@ -35,25 +35,25 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AbstractRoutingConnectionFactoryUnitTests {
|
||||
|
||||
private static final String ROUTING_KEY = "routingKey";
|
||||
|
||||
@Mock ConnectionFactory defaultConnectionFactory;
|
||||
@Mock ConnectionFactory routedConnectionFactory;
|
||||
|
||||
DummyRoutingConnectionFactory connectionFactory;
|
||||
private DummyRoutingConnectionFactory connectionFactory;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
connectionFactory = new DummyRoutingConnectionFactory();
|
||||
connectionFactory.setDefaultTargetConnectionFactory(defaultConnectionFactory);
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldDetermineRoutedFactory() {
|
||||
void shouldDetermineRoutedFactory() {
|
||||
|
||||
connectionFactory.setTargetConnectionFactories(singletonMap("key", routedConnectionFactory));
|
||||
connectionFactory.setConnectionFactoryLookup(new MapConnectionFactoryLookup());
|
||||
@@ -67,7 +67,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldFallbackToDefaultConnectionFactory() {
|
||||
void shouldFallbackToDefaultConnectionFactory() {
|
||||
|
||||
connectionFactory.setTargetConnectionFactories(singletonMap("key", routedConnectionFactory));
|
||||
connectionFactory.afterPropertiesSet();
|
||||
@@ -79,7 +79,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void initializationShouldFailUnsupportedLookupKey() {
|
||||
void initializationShouldFailUnsupportedLookupKey() {
|
||||
|
||||
connectionFactory.setTargetConnectionFactories(singletonMap("key", new Object()));
|
||||
|
||||
@@ -87,7 +87,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void initializationShouldFailUnresolvableKey() {
|
||||
void initializationShouldFailUnresolvableKey() {
|
||||
|
||||
connectionFactory.setTargetConnectionFactories(singletonMap("key", "value"));
|
||||
connectionFactory.setConnectionFactoryLookup(new MapConnectionFactoryLookup());
|
||||
@@ -98,7 +98,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void unresolvableConnectionFactoryRetrievalShouldFail() {
|
||||
void unresolvableConnectionFactoryRetrievalShouldFail() {
|
||||
|
||||
connectionFactory.setLenientFallback(false);
|
||||
connectionFactory.setConnectionFactoryLookup(new MapConnectionFactoryLookup());
|
||||
@@ -112,7 +112,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void connectionFactoryRetrievalWithUnknownLookupKeyShouldReturnDefaultConnectionFactory() {
|
||||
void connectionFactoryRetrievalWithUnknownLookupKeyShouldReturnDefaultConnectionFactory() {
|
||||
|
||||
connectionFactory.setTargetConnectionFactories(singletonMap("key", routedConnectionFactory));
|
||||
connectionFactory.setDefaultTargetConnectionFactory(defaultConnectionFactory);
|
||||
@@ -126,7 +126,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void connectionFactoryRetrievalWithoutLookupKeyShouldReturnDefaultConnectionFactory() {
|
||||
void connectionFactoryRetrievalWithoutLookupKeyShouldReturnDefaultConnectionFactory() {
|
||||
|
||||
connectionFactory.setTargetConnectionFactories(singletonMap("key", routedConnectionFactory));
|
||||
connectionFactory.setDefaultTargetConnectionFactory(defaultConnectionFactory);
|
||||
@@ -140,7 +140,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldLookupFromMap() {
|
||||
void shouldLookupFromMap() {
|
||||
|
||||
MapConnectionFactoryLookup lookup = new MapConnectionFactoryLookup("lookup-key", routedConnectionFactory);
|
||||
|
||||
@@ -156,7 +156,7 @@ public class AbstractRoutingConnectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldAllowModificationsAfterInitialization() {
|
||||
void shouldAllowModificationsAfterInitialization() {
|
||||
|
||||
MapConnectionFactoryLookup lookup = new MapConnectionFactoryLookup();
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
|
||||
@@ -33,15 +33,15 @@ import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BeanFactoryConnectionFactoryLookupUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class BeanFactoryConnectionFactoryLookupUnitTests {
|
||||
|
||||
private static final String CONNECTION_FACTORY_BEAN_NAME = "connectionFactory";
|
||||
|
||||
@Mock BeanFactory beanFactory;
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldLookupConnectionFactory() {
|
||||
void shouldLookupConnectionFactory() {
|
||||
|
||||
DummyConnectionFactory expectedConnectionFactory = new DummyConnectionFactory();
|
||||
when(beanFactory.getBean(CONNECTION_FACTORY_BEAN_NAME, ConnectionFactory.class))
|
||||
@@ -57,7 +57,7 @@ public class BeanFactoryConnectionFactoryLookupUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldLookupWhereBeanFactoryYieldsNonConnectionFactoryType() {
|
||||
void shouldLookupWhereBeanFactoryYieldsNonConnectionFactoryType() {
|
||||
|
||||
BeanFactory beanFactory = mock(BeanFactory.class);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class BeanFactoryConnectionFactoryLookupUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-98
|
||||
public void shouldLookupWhereBeanFactoryHasNotBeenSupplied() {
|
||||
void shouldLookupWhereBeanFactoryHasNotBeenSupplied() {
|
||||
|
||||
BeanFactoryConnectionFactoryLookup lookup = new BeanFactoryConnectionFactoryLookup();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MapConnectionFactoryLookup}.
|
||||
|
||||
@@ -12,10 +12,10 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.core.DefaultReactiveDataAccessStrategy;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
@@ -26,7 +26,7 @@ import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class EntityRowMapperUnitTests {
|
||||
|
||||
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE);
|
||||
@@ -35,7 +35,7 @@ public class EntityRowMapperUnitTests {
|
||||
RowMetadata metadata = mock(RowMetadata.class);
|
||||
Collection<String> columns = mock(Collection.class);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
when(columns.contains(anyString())).thenReturn(true);
|
||||
@@ -159,7 +159,7 @@ public class EntityRowMapperUnitTests {
|
||||
}
|
||||
|
||||
enum MyEnum {
|
||||
ONE, TWO, THREE;
|
||||
ONE, TWO, THREE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
@@ -57,7 +57,7 @@ public class MappingR2dbcConverterUnitTests {
|
||||
RelationalMappingContext mappingContext = new R2dbcMappingContext();
|
||||
MappingR2dbcConverter converter = new MappingR2dbcConverter(mappingContext);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
R2dbcCustomConversions conversions = new R2dbcCustomConversions(
|
||||
@@ -335,7 +335,7 @@ public class MappingR2dbcConverterUnitTests {
|
||||
|
||||
static class WithSpelExpression {
|
||||
|
||||
private long id;
|
||||
private final long id;
|
||||
@Transient String hello;
|
||||
@Transient String world;
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.convert.CustomConversions;
|
||||
@@ -49,7 +49,7 @@ public class PostgresMappingR2dbcConverterUnitTests {
|
||||
RelationalMappingContext mappingContext = new R2dbcMappingContext();
|
||||
MappingR2dbcConverter converter = new MappingR2dbcConverter(mappingContext);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
List<Object> converters = new ArrayList<>(PostgresDialect.INSTANCE.getConverters());
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.r2dbc.convert.R2dbcConverters.RowToBooleanConverter;
|
||||
|
||||
@@ -26,18 +26,18 @@ import reactor.test.StepVerifier;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.query.Update;
|
||||
import org.springframework.data.r2dbc.testing.R2dbcIntegrationTestSupport;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.query.Update;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractDatabaseClientIntegrationTests extends R2dbcIntegr
|
||||
|
||||
private JdbcTemplate jdbc;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
connectionFactory = createConnectionFactory();
|
||||
|
||||
@@ -26,8 +26,8 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -65,7 +65,7 @@ public abstract class AbstractTransactionalDatabaseClientIntegrationTests extend
|
||||
R2dbcTransactionManager transactionManager;
|
||||
TransactionalOperator rxtx;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
connectionFactory = createConnectionFactory();
|
||||
@@ -293,7 +293,7 @@ public abstract class AbstractTransactionalDatabaseClientIntegrationTests extend
|
||||
|
||||
static class TransactionalService {
|
||||
|
||||
private DatabaseClient databaseClient;
|
||||
private final DatabaseClient databaseClient;
|
||||
|
||||
public TransactionalService(DatabaseClient databaseClient) {
|
||||
this.databaseClient = databaseClient;
|
||||
|
||||
@@ -34,13 +34,15 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscription;
|
||||
|
||||
@@ -59,14 +61,15 @@ import org.springframework.lang.Nullable;
|
||||
* @author Jens Schauder
|
||||
* @author Zsombor Gegesy
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
public class DefaultDatabaseClientUnitTests {
|
||||
|
||||
@Mock Connection connection;
|
||||
private DatabaseClient.Builder databaseClientBuilder;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
ConnectionFactory connectionFactory = Mockito.mock(ConnectionFactory.class);
|
||||
|
||||
@@ -79,7 +82,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-48
|
||||
public void shouldCloseConnectionOnlyOnce() {
|
||||
void shouldCloseConnectionOnlyOnce() {
|
||||
|
||||
DefaultDatabaseClient databaseClient = (DefaultDatabaseClient) databaseClientBuilder.build();
|
||||
|
||||
@@ -110,7 +113,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-128
|
||||
public void executeShouldBindNullValues() {
|
||||
void executeShouldBindNullValues() {
|
||||
|
||||
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
|
||||
|
||||
@@ -134,7 +137,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-162
|
||||
public void executeShouldBindSettableValues() {
|
||||
void executeShouldBindSettableValues() {
|
||||
|
||||
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
|
||||
|
||||
@@ -158,7 +161,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-128
|
||||
public void executeShouldBindNamedNullValues() {
|
||||
void executeShouldBindNamedNullValues() {
|
||||
|
||||
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
@@ -173,7 +176,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-178
|
||||
public void executeShouldBindNamedValuesFromIndexes() {
|
||||
void executeShouldBindNamedValuesFromIndexes() {
|
||||
|
||||
Statement statement = mockStatementFor("SELECT id, name, manual FROM legoset WHERE name IN ($1, $2, $3)");
|
||||
|
||||
@@ -193,7 +196,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-128, gh-162
|
||||
public void executeShouldBindValues() {
|
||||
void executeShouldBindValues() {
|
||||
|
||||
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
|
||||
|
||||
@@ -217,7 +220,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-162
|
||||
public void insertShouldAcceptNullValues() {
|
||||
void insertShouldAcceptNullValues() {
|
||||
|
||||
Statement statement = mockStatementFor("INSERT INTO foo (first, second) VALUES ($1, $2)");
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
@@ -234,7 +237,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-162
|
||||
public void insertShouldAcceptSettableValue() {
|
||||
void insertShouldAcceptSettableValue() {
|
||||
|
||||
Statement statement = mockStatementFor("INSERT INTO foo (first, second) VALUES ($1, $2)");
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
@@ -251,7 +254,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-390
|
||||
public void insertShouldWorkWithoutValues() {
|
||||
void insertShouldWorkWithoutValues() {
|
||||
|
||||
Statement statement = mockStatementFor("INSERT INTO id_only VALUES ()");
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
@@ -267,7 +270,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-128
|
||||
public void executeShouldBindNamedValuesByIndex() {
|
||||
void executeShouldBindNamedValuesByIndex() {
|
||||
|
||||
Statement statement = mockStatementFor("SELECT * FROM table WHERE key = $1");
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
@@ -282,7 +285,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-177
|
||||
public void deleteNotInShouldRenderCorrectQuery() {
|
||||
void deleteNotInShouldRenderCorrectQuery() {
|
||||
|
||||
Statement statement = mockStatementFor("DELETE FROM tab WHERE tab.pole = $1 AND tab.id NOT IN ($2, $3)");
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
@@ -298,7 +301,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-243
|
||||
public void rowsUpdatedShouldEmitSingleValue() {
|
||||
void rowsUpdatedShouldEmitSingleValue() {
|
||||
|
||||
Result result = mock(Result.class);
|
||||
when(result.getRowsUpdated()).thenReturn(Mono.empty(), Mono.just(2), Flux.just(1, 2, 3));
|
||||
@@ -329,7 +332,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-250
|
||||
public void shouldThrowExceptionForSingleColumnObjectUpdate() {
|
||||
void shouldThrowExceptionForSingleColumnObjectUpdate() {
|
||||
|
||||
DatabaseClient databaseClient = databaseClientBuilder.build();
|
||||
|
||||
@@ -340,7 +343,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-260
|
||||
public void shouldProjectGenericExecuteAs() {
|
||||
void shouldProjectGenericExecuteAs() {
|
||||
|
||||
MockResult result = mockSingleColumnResult(MockRow.builder().identified(0, Object.class, "Walter"));
|
||||
mockStatement(result);
|
||||
@@ -364,7 +367,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-260
|
||||
public void shouldProjectGenericSelectAs() {
|
||||
void shouldProjectGenericSelectAs() {
|
||||
|
||||
MockResult result = mockSingleColumnResult(MockRow.builder().identified(0, Object.class, "Walter"));
|
||||
mockStatement(result);
|
||||
@@ -389,7 +392,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-260
|
||||
public void shouldProjectTypedSelectAs() {
|
||||
void shouldProjectTypedSelectAs() {
|
||||
|
||||
MockResult result = mockSingleColumnResult(MockRow.builder().identified("name", Object.class, "Walter"));
|
||||
mockStatement(result);
|
||||
@@ -412,7 +415,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-189
|
||||
public void shouldApplyExecuteFunction() {
|
||||
void shouldApplyExecuteFunction() {
|
||||
|
||||
Statement statement = mockStatement();
|
||||
MockResult result = mockSingleColumnResult(MockRow.builder().identified(0, Object.class, "Walter"));
|
||||
@@ -430,7 +433,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-189
|
||||
public void shouldApplyStatementFilterFunctions() {
|
||||
void shouldApplyStatementFilterFunctions() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder()
|
||||
.columnMetadata(MockColumnMetadata.builder().name("name").build()).build();
|
||||
@@ -455,7 +458,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-189
|
||||
public void shouldApplyStatementFilterFunctionsToTypedExecute() {
|
||||
void shouldApplyStatementFilterFunctionsToTypedExecute() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder()
|
||||
.columnMetadata(MockColumnMetadata.builder().name("name").build()).build();
|
||||
@@ -479,7 +482,7 @@ public class DefaultDatabaseClientUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-189
|
||||
public void shouldApplySimpleStatementFilterFunctions() {
|
||||
void shouldApplySimpleStatementFilterFunctions() {
|
||||
|
||||
MockResult result = mockSingleColumnEmptyResult();
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
*/
|
||||
public class JasyncMySqlDatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.time.Duration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
||||
public class JasyncMySqlTransactionalDatabaseClientIntegrationTests
|
||||
extends AbstractTransactionalDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.util.UUID;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -36,10 +36,10 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.data.r2dbc.dialect.MySqlDialect;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MariaDbTestSupport;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
*/
|
||||
public class MariaDbDatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MariaDbTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MariaDbTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.time.Duration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MariaDbTestSupport;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
||||
public class MariaDbTransactionalDatabaseClientIntegrationTests
|
||||
extends AbstractTransactionalDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MariaDbTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MariaDbTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.util.UUID;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -36,10 +36,10 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.data.r2dbc.dialect.MySqlDialect;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
*/
|
||||
public class MySqlDatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.time.Duration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
@@ -36,7 +36,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
||||
public class MySqlTransactionalDatabaseClientIntegrationTests
|
||||
extends AbstractTransactionalDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.r2dbc.dialect.BindTarget;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
@@ -40,12 +40,12 @@ import org.springframework.util.MultiValueMap;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public class NamedParameterUtilsUnitTests {
|
||||
class NamedParameterUtilsUnitTests {
|
||||
|
||||
private final BindMarkersFactory BIND_MARKERS = PostgresDialect.INSTANCE.getBindMarkersFactory();
|
||||
|
||||
@Test // gh-23
|
||||
public void shouldParseSql() {
|
||||
void shouldParseSql() {
|
||||
|
||||
String sql = "xxx :a yyyy :b :c :a zzzzz";
|
||||
ParsedSql psql = NamedParameterUtils.parseSqlStatement(sql);
|
||||
@@ -65,7 +65,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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 // gh-23
|
||||
public void substituteObjectArray() {
|
||||
void substituteObjectArray() {
|
||||
|
||||
MapBindParameterSource namedParams = new MapBindParameterSource(new HashMap<>());
|
||||
namedParams.addValue("a",
|
||||
@@ -94,7 +94,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23, gh-105
|
||||
public void shouldBindObjectArray() {
|
||||
void shouldBindObjectArray() {
|
||||
|
||||
MapBindParameterSource namedParams = new MapBindParameterSource(new HashMap<>());
|
||||
namedParams.addValue("a",
|
||||
@@ -112,7 +112,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void parseSqlContainingComments() {
|
||||
void parseSqlContainingComments() {
|
||||
|
||||
String sql1 = "/*+ HINT */ xxx /* comment ? */ :a yyyy :b :c :a zzzzz -- :xx XX\n";
|
||||
|
||||
@@ -130,7 +130,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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";
|
||||
@@ -143,7 +143,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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 // gh-23
|
||||
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[]";
|
||||
@@ -167,7 +167,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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'";
|
||||
@@ -178,7 +178,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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";
|
||||
@@ -190,7 +190,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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";
|
||||
@@ -201,7 +201,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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";
|
||||
@@ -220,7 +220,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
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";
|
||||
@@ -231,7 +231,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void parseSqlStatementWithLogicalAnd() {
|
||||
void parseSqlStatementWithLogicalAnd() {
|
||||
|
||||
String expectedSql = "xxx & yyyy";
|
||||
|
||||
@@ -241,7 +241,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void substituteNamedParametersWithLogicalAnd() {
|
||||
void substituteNamedParametersWithLogicalAnd() {
|
||||
|
||||
String expectedSql = "xxx & yyyy";
|
||||
|
||||
@@ -249,7 +249,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void variableAssignmentOperator() {
|
||||
void variableAssignmentOperator() {
|
||||
|
||||
String expectedSql = "x := 1";
|
||||
|
||||
@@ -257,7 +257,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void parseSqlStatementWithQuotedSingleQuote() {
|
||||
void parseSqlStatementWithQuotedSingleQuote() {
|
||||
|
||||
String sql = "SELECT ':foo'':doo', :xxx FROM DUAL";
|
||||
|
||||
@@ -268,7 +268,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void parseSqlStatementWithQuotesAndCommentBefore() {
|
||||
void parseSqlStatementWithQuotesAndCommentBefore() {
|
||||
|
||||
String sql = "SELECT /*:doo*/':foo', :xxx FROM DUAL";
|
||||
|
||||
@@ -279,7 +279,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-23
|
||||
public void parseSqlStatementWithQuotesAndCommentAfter() {
|
||||
void parseSqlStatementWithQuotesAndCommentAfter() {
|
||||
|
||||
String sql2 = "SELECT ':foo'/*:doo*/, :xxx FROM DUAL";
|
||||
|
||||
@@ -290,7 +290,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-138
|
||||
public void shouldAllowParsingMultipleUseOfParameter() {
|
||||
void shouldAllowParsingMultipleUseOfParameter() {
|
||||
|
||||
String sql = "SELECT * FROM person where name = :id or lastname = :id";
|
||||
|
||||
@@ -302,7 +302,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-138
|
||||
public void multipleEqualParameterReferencesBindsValueOnce() {
|
||||
void multipleEqualParameterReferencesBindsValueOnce() {
|
||||
|
||||
String sql = "SELECT * FROM person where name = :id or lastname = :id";
|
||||
|
||||
@@ -338,7 +338,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-310
|
||||
public void multipleEqualCollectionParameterReferencesBindsValueOnce() {
|
||||
void multipleEqualCollectionParameterReferencesBindsValueOnce() {
|
||||
|
||||
String sql = "SELECT * FROM person where name IN (:ids) or lastname IN (:ids)";
|
||||
|
||||
@@ -384,7 +384,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-138
|
||||
public void multipleEqualParameterReferencesForAnonymousMarkersBindsValueMultipleTimes() {
|
||||
void multipleEqualParameterReferencesForAnonymousMarkersBindsValueMultipleTimes() {
|
||||
|
||||
String sql = "SELECT * FROM person where name = :id or lastname = :id";
|
||||
|
||||
@@ -423,7 +423,7 @@ public class NamedParameterUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-138
|
||||
public void multipleEqualParameterReferencesBindsNullOnce() {
|
||||
void multipleEqualParameterReferencesBindsNullOnce() {
|
||||
|
||||
String sql = "SELECT * FROM person where name = :id or lastname = :id";
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.PostgresTestSupport;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.data.r2dbc.testing.PostgresTestSupport;
|
||||
*/
|
||||
public class PostgresDatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -41,9 +41,9 @@ import java.util.function.Consumer;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -63,15 +63,15 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
*/
|
||||
public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
|
||||
DataSource dataSource = PostgresTestSupport.createDataSource(database);
|
||||
ConnectionFactory connectionFactory = PostgresTestSupport.createConnectionFactory(database);
|
||||
JdbcTemplate template = createJdbcTemplate(dataSource);
|
||||
DatabaseClient client = DatabaseClient.create(connectionFactory);
|
||||
private final DataSource dataSource = PostgresTestSupport.createDataSource(database);
|
||||
private final ConnectionFactory connectionFactory = PostgresTestSupport.createConnectionFactory(database);
|
||||
private final JdbcTemplate template = createJdbcTemplate(dataSource);
|
||||
private final DatabaseClient client = DatabaseClient.create(connectionFactory);
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
template.execute("DROP TABLE IF EXISTS with_arrays");
|
||||
template.execute("CREATE TABLE with_arrays (" //
|
||||
@@ -83,7 +83,7 @@ public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldReadAndWritePrimitiveSingleDimensionArrays() {
|
||||
void shouldReadAndWritePrimitiveSingleDimensionArrays() {
|
||||
|
||||
EntityWithArrays withArrays = new EntityWithArrays(null, null, new int[] { 1, 2, 3 }, null, null);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldReadAndWriteBoxedSingleDimensionArrays() {
|
||||
void shouldReadAndWriteBoxedSingleDimensionArrays() {
|
||||
|
||||
EntityWithArrays withArrays = new EntityWithArrays(null, new Integer[] { 1, 2, 3 }, null, null, null);
|
||||
|
||||
@@ -108,7 +108,7 @@ public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldReadAndWriteConvertedDimensionArrays() {
|
||||
void shouldReadAndWriteConvertedDimensionArrays() {
|
||||
|
||||
EntityWithArrays withArrays = new EntityWithArrays(null, null, null, null, Arrays.asList(5, 6, 7));
|
||||
|
||||
@@ -120,7 +120,7 @@ public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldReadAndWriteMultiDimensionArrays() {
|
||||
void shouldReadAndWriteMultiDimensionArrays() {
|
||||
|
||||
EntityWithArrays withArrays = new EntityWithArrays(null, null, null, new int[][] { { 1, 2, 3 }, { 4, 5, 6 } },
|
||||
null);
|
||||
@@ -139,7 +139,7 @@ public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
}
|
||||
|
||||
@Test // gh-411
|
||||
public void shouldWriteAndReadEnumValuesUsingDriverInternals() {
|
||||
void shouldWriteAndReadEnumValuesUsingDriverInternals() {
|
||||
|
||||
CodecRegistrar codecRegistrar = EnumCodec.builder().withEnum("state_enum", State.class).build();
|
||||
|
||||
@@ -184,12 +184,12 @@ public class PostgresIntegrationTests extends R2dbcIntegrationTestSupport {
|
||||
Good, Bad
|
||||
}
|
||||
|
||||
static class StateConverter extends EnumWriteSupport<State> {
|
||||
private static class StateConverter extends EnumWriteSupport<State> {
|
||||
|
||||
}
|
||||
|
||||
@Test // gh-423
|
||||
public void shouldReadAndWriteGeoTypes() {
|
||||
void shouldReadAndWriteGeoTypes() {
|
||||
|
||||
GeoType geoType = new GeoType();
|
||||
geoType.thePoint = Point.of(1, 2);
|
||||
|
||||
@@ -25,13 +25,12 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
import org.springframework.data.r2dbc.mapping.OutboundRow;
|
||||
import org.springframework.data.r2dbc.mapping.SettableValue;
|
||||
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
import org.springframework.r2dbc.core.Parameter;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-161
|
||||
public void shouldConvertPrimitiveMultidimensionArrayToWrapper() {
|
||||
void shouldConvertPrimitiveMultidimensionArrayToWrapper() {
|
||||
|
||||
OutboundRow row = strategy.getOutboundRow(new WithMultidimensionalArray(new int[][] { { 1, 2, 3 }, { 4, 5 } }));
|
||||
|
||||
@@ -59,7 +58,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-161
|
||||
public void shouldConvertNullArrayToDriverArrayType() {
|
||||
void shouldConvertNullArrayToDriverArrayType() {
|
||||
|
||||
OutboundRow row = strategy.getOutboundRow(new WithMultidimensionalArray(null));
|
||||
|
||||
@@ -68,7 +67,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-161
|
||||
public void shouldConvertCollectionToArray() {
|
||||
void shouldConvertCollectionToArray() {
|
||||
|
||||
OutboundRow row = strategy.getOutboundRow(new WithIntegerCollection(Arrays.asList(1, 2, 3)));
|
||||
|
||||
@@ -78,7 +77,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-139
|
||||
public void shouldConvertToArray() {
|
||||
void shouldConvertToArray() {
|
||||
|
||||
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE);
|
||||
|
||||
@@ -94,7 +93,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-139
|
||||
public void shouldApplyCustomConversion() {
|
||||
void shouldApplyCustomConversion() {
|
||||
|
||||
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE,
|
||||
Collections.singletonList(MyObjectsToStringConverter.INSTANCE));
|
||||
@@ -109,7 +108,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-139
|
||||
public void shouldApplyCustomConversionForNull() {
|
||||
void shouldApplyCustomConversionForNull() {
|
||||
|
||||
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE,
|
||||
Collections.singletonList(MyObjectsToStringConverter.INSTANCE));
|
||||
@@ -128,7 +127,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-252
|
||||
public void shouldConvertSetOfEnumToString() {
|
||||
void shouldConvertSetOfEnumToString() {
|
||||
|
||||
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE,
|
||||
Collections.singletonList(MyObjectsToStringConverter.INSTANCE));
|
||||
@@ -145,7 +144,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
@Test // gh-252
|
||||
public void shouldConvertArrayOfEnumToString() {
|
||||
void shouldConvertArrayOfEnumToString() {
|
||||
|
||||
DefaultReactiveDataAccessStrategy strategy = new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE,
|
||||
Collections.singletonList(MyObjectsToStringConverter.INSTANCE));
|
||||
@@ -193,7 +192,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
static class MyObject {
|
||||
String foo;
|
||||
|
||||
public MyObject(String foo) {
|
||||
MyObject(String foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
|
||||
@@ -204,7 +203,7 @@ public class PostgresReactiveDataAccessStrategyTests extends ReactiveDataAccessS
|
||||
}
|
||||
|
||||
enum MyEnum {
|
||||
ONE, TWO, THREE;
|
||||
ONE, TWO, THREE
|
||||
}
|
||||
|
||||
@WritingConverter
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.PostgresTestSupport;
|
||||
@@ -17,7 +17,7 @@ import org.springframework.data.r2dbc.testing.PostgresTestSupport;
|
||||
public class PostgresTransactionalDatabaseClientIntegrationTests
|
||||
extends AbstractTransactionalDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
@@ -74,7 +74,7 @@ public class R2dbcEntityTemplateUnitTests {
|
||||
R2dbcEntityTemplate entityTemplate;
|
||||
StatementRecorder recorder;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
recorder = StatementRecorder.newInstance();
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
import org.springframework.data.r2dbc.dialect.R2dbcDialect;
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
|
||||
@@ -22,12 +22,11 @@ import static org.springframework.data.relational.core.query.Query.*;
|
||||
import io.r2dbc.spi.test.MockResult;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
import org.springframework.data.r2dbc.mapping.SettableValue;
|
||||
import org.springframework.data.r2dbc.testing.StatementRecorder;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.r2dbc.core.Parameter;
|
||||
@@ -39,12 +38,12 @@ import org.springframework.r2dbc.core.Parameter;
|
||||
*/
|
||||
public class ReactiveDeleteOperationUnitTests {
|
||||
|
||||
DatabaseClient client;
|
||||
R2dbcEntityTemplate entityTemplate;
|
||||
StatementRecorder recorder;
|
||||
private DatabaseClient client;
|
||||
private R2dbcEntityTemplate entityTemplate;
|
||||
private StatementRecorder recorder;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
recorder = StatementRecorder.newInstance();
|
||||
client = DatabaseClient.builder().connectionFactory(recorder)
|
||||
@@ -53,7 +52,7 @@ public class ReactiveDeleteOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-410
|
||||
public void shouldDelete() {
|
||||
void shouldDelete() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
@@ -71,7 +70,7 @@ public class ReactiveDeleteOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-410
|
||||
public void shouldDeleteWithTable() {
|
||||
void shouldDeleteWithTable() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
@@ -89,7 +88,7 @@ public class ReactiveDeleteOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldDeleteWithQuery() {
|
||||
void shouldDeleteWithQuery() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
@@ -109,7 +108,7 @@ public class ReactiveDeleteOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldDeleteInTable() {
|
||||
void shouldDeleteInTable() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
|
||||
@@ -23,12 +23,11 @@ import io.r2dbc.spi.test.MockRow;
|
||||
import io.r2dbc.spi.test.MockRowMetadata;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
import org.springframework.data.r2dbc.mapping.SettableValue;
|
||||
import org.springframework.data.r2dbc.testing.StatementRecorder;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.r2dbc.core.Parameter;
|
||||
@@ -40,12 +39,12 @@ import org.springframework.r2dbc.core.Parameter;
|
||||
*/
|
||||
public class ReactiveInsertOperationUnitTests {
|
||||
|
||||
DatabaseClient client;
|
||||
R2dbcEntityTemplate entityTemplate;
|
||||
StatementRecorder recorder;
|
||||
private DatabaseClient client;
|
||||
private R2dbcEntityTemplate entityTemplate;
|
||||
private StatementRecorder recorder;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
recorder = StatementRecorder.newInstance();
|
||||
client = DatabaseClient.builder().connectionFactory(recorder)
|
||||
@@ -54,7 +53,7 @@ public class ReactiveInsertOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldInsert() {
|
||||
void shouldInsert() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -82,7 +81,7 @@ public class ReactiveInsertOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldUpdateInTable() {
|
||||
void shouldUpdateInTable() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
|
||||
@@ -25,8 +25,8 @@ import io.r2dbc.spi.test.MockRow;
|
||||
import io.r2dbc.spi.test.MockRowMetadata;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
@@ -40,12 +40,12 @@ import org.springframework.data.relational.core.mapping.Column;
|
||||
*/
|
||||
public class ReactiveSelectOperationUnitTests {
|
||||
|
||||
DatabaseClient client;
|
||||
R2dbcEntityTemplate entityTemplate;
|
||||
StatementRecorder recorder;
|
||||
private DatabaseClient client;
|
||||
private R2dbcEntityTemplate entityTemplate;
|
||||
private StatementRecorder recorder;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
recorder = StatementRecorder.newInstance();
|
||||
client = DatabaseClient.builder().connectionFactory(recorder)
|
||||
@@ -54,7 +54,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectAll() {
|
||||
void shouldSelectAll() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -77,7 +77,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectAs() {
|
||||
void shouldSelectAs() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -100,7 +100,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectFromTable() {
|
||||
void shouldSelectFromTable() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -123,7 +123,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectFirst() {
|
||||
void shouldSelectFirst() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -145,7 +145,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectOne() {
|
||||
void shouldSelectOne() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -167,7 +167,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectExists() {
|
||||
void shouldSelectExists() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
@@ -189,7 +189,7 @@ public class ReactiveSelectOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldSelectCount() {
|
||||
void shouldSelectCount() {
|
||||
|
||||
MockRowMetadata metadata = MockRowMetadata.builder().columnMetadata(MockColumnMetadata.builder().name("id").build())
|
||||
.build();
|
||||
|
||||
@@ -22,12 +22,11 @@ import static org.springframework.data.relational.core.query.Query.*;
|
||||
import io.r2dbc.spi.test.MockResult;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.r2dbc.dialect.PostgresDialect;
|
||||
import org.springframework.data.r2dbc.mapping.SettableValue;
|
||||
import org.springframework.data.r2dbc.testing.StatementRecorder;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
import org.springframework.data.relational.core.query.Update;
|
||||
@@ -40,12 +39,12 @@ import org.springframework.r2dbc.core.Parameter;
|
||||
*/
|
||||
public class ReactiveUpdateOperationUnitTests {
|
||||
|
||||
DatabaseClient client;
|
||||
R2dbcEntityTemplate entityTemplate;
|
||||
StatementRecorder recorder;
|
||||
private DatabaseClient client;
|
||||
private R2dbcEntityTemplate entityTemplate;
|
||||
private StatementRecorder recorder;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
recorder = StatementRecorder.newInstance();
|
||||
client = DatabaseClient.builder().connectionFactory(recorder)
|
||||
@@ -54,7 +53,7 @@ public class ReactiveUpdateOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-410
|
||||
public void shouldUpdate() {
|
||||
void shouldUpdate() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
@@ -73,7 +72,7 @@ public class ReactiveUpdateOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-410
|
||||
public void shouldUpdateWithTable() {
|
||||
void shouldUpdateWithTable() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
@@ -92,7 +91,7 @@ public class ReactiveUpdateOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldUpdateWithQuery() {
|
||||
void shouldUpdateWithQuery() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
@@ -113,7 +112,7 @@ public class ReactiveUpdateOperationUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-220
|
||||
public void shouldUpdateInTable() {
|
||||
void shouldUpdateInTable() {
|
||||
|
||||
MockResult result = MockResult.builder().rowsUpdated(1).build();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
|
||||
*/
|
||||
public class SqlServerDatabaseClientIntegrationTests extends AbstractDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
|
||||
@@ -17,7 +17,7 @@ import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
|
||||
public class SqlServerTransactionalDatabaseClientIntegrationTests
|
||||
extends AbstractTransactionalDatabaseClientIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
|
||||
@Override
|
||||
protected DataSource createDataSource() {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.r2dbc.core;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
@@ -22,20 +22,20 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Bindings}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class BindingsUnitTests {
|
||||
class BindingsUnitTests {
|
||||
|
||||
BindMarkersFactory markersFactory = BindMarkersFactory.indexed("$", 1);
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
private final BindMarkersFactory markersFactory = BindMarkersFactory.indexed("$", 1);
|
||||
private final BindTarget bindTarget = mock(BindTarget.class);
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldCreateBindings() {
|
||||
void shouldCreateBindings() {
|
||||
|
||||
MutableBindings bindings = new MutableBindings(markersFactory.create());
|
||||
|
||||
@@ -46,7 +46,7 @@ public class BindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldApplyValueBinding() {
|
||||
void shouldApplyValueBinding() {
|
||||
|
||||
MutableBindings bindings = new MutableBindings(markersFactory.create());
|
||||
|
||||
@@ -57,7 +57,7 @@ public class BindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldApplySimpleValueBinding() {
|
||||
void shouldApplySimpleValueBinding() {
|
||||
|
||||
MutableBindings bindings = new MutableBindings(markersFactory.create());
|
||||
|
||||
@@ -69,7 +69,7 @@ public class BindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldApplyNullBinding() {
|
||||
void shouldApplyNullBinding() {
|
||||
|
||||
MutableBindings bindings = new MutableBindings(markersFactory.create());
|
||||
|
||||
@@ -81,7 +81,7 @@ public class BindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldApplySimpleNullBinding() {
|
||||
void shouldApplySimpleNullBinding() {
|
||||
|
||||
MutableBindings bindings = new MutableBindings(markersFactory.create());
|
||||
|
||||
@@ -93,7 +93,7 @@ public class BindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldConsumeBindings() {
|
||||
void shouldConsumeBindings() {
|
||||
|
||||
MutableBindings bindings = new MutableBindings(markersFactory.create());
|
||||
|
||||
@@ -122,7 +122,7 @@ public class BindingsUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldMergeBindings() {
|
||||
void shouldMergeBindings() {
|
||||
|
||||
BindMarkers markers = markersFactory.create();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.data.relational.core.dialect.LimitClause;
|
||||
@@ -37,7 +37,7 @@ import com.github.jasync.sql.db.mysql.pool.MySQLConnectionFactory;
|
||||
public class DialectResolverUnitTests {
|
||||
|
||||
@Test // gh-20, gh-104
|
||||
public void shouldResolveDatabaseType() {
|
||||
void shouldResolveDatabaseType() {
|
||||
|
||||
PostgresqlConnectionFactory postgres = new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
|
||||
.host("localhost").database("foo").username("bar").password("password").build());
|
||||
@@ -56,13 +56,13 @@ public class DialectResolverUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-20, gh-104
|
||||
public void shouldNotResolveUnknownDatabase() {
|
||||
void shouldNotResolveUnknownDatabase() {
|
||||
assertThatThrownBy(() -> DialectResolver.getDialect(new ExternalConnectionFactory("unknown")))
|
||||
.isInstanceOf(DialectResolver.NoDialectException.class);
|
||||
}
|
||||
|
||||
@Test // gh-104
|
||||
public void shouldResolveExternalDialect() {
|
||||
void shouldResolveExternalDialect() {
|
||||
assertThat(DialectResolver.getDialect(new ExternalConnectionFactory("external")))
|
||||
.isEqualTo(ExternalDialect.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import static org.assertj.core.api.SoftAssertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.relational.core.dialect.ArrayColumns;
|
||||
@@ -17,10 +17,10 @@ import org.springframework.r2dbc.core.binding.BindMarkers;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class PostgresDialectUnitTests {
|
||||
class PostgresDialectUnitTests {
|
||||
|
||||
@Test // gh-20
|
||||
public void shouldUsePostgresPlaceholders() {
|
||||
void shouldUsePostgresPlaceholders() {
|
||||
|
||||
BindMarkers bindMarkers = PostgresDialect.INSTANCE.getBindMarkersFactory().create();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PostgresDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldConsiderSimpleTypes() {
|
||||
void shouldConsiderSimpleTypes() {
|
||||
|
||||
SimpleTypeHolder holder = PostgresDialect.INSTANCE.getSimpleTypeHolder();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PostgresDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldSupportArrays() {
|
||||
void shouldSupportArrays() {
|
||||
|
||||
ArrayColumns arrayColumns = PostgresDialect.INSTANCE.getArraySupport();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PostgresDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldUseBoxedArrayTypesForPrimitiveTypes() {
|
||||
void shouldUseBoxedArrayTypesForPrimitiveTypes() {
|
||||
|
||||
ArrayColumns arrayColumns = PostgresDialect.INSTANCE.getArraySupport();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PostgresDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldRejectNonSimpleArrayTypes() {
|
||||
void shouldRejectNonSimpleArrayTypes() {
|
||||
|
||||
ArrayColumns arrayColumns = PostgresDialect.INSTANCE.getArraySupport();
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PostgresDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldRejectNestedCollections() {
|
||||
void shouldRejectNestedCollections() {
|
||||
|
||||
ArrayColumns arrayColumns = PostgresDialect.INSTANCE.getArraySupport();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.relational.core.dialect.ArrayColumns;
|
||||
import org.springframework.r2dbc.core.binding.BindMarker;
|
||||
@@ -15,10 +15,10 @@ import org.springframework.r2dbc.core.binding.BindMarkers;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SqlServerDialectUnitTests {
|
||||
class SqlServerDialectUnitTests {
|
||||
|
||||
@Test // gh-20
|
||||
public void shouldUseNamedPlaceholders() {
|
||||
void shouldUseNamedPlaceholders() {
|
||||
|
||||
BindMarkers bindMarkers = SqlServerDialect.INSTANCE.getBindMarkersFactory().create();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class SqlServerDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldConsiderUuidAsSimple() {
|
||||
void shouldConsiderUuidAsSimple() {
|
||||
|
||||
SimpleTypeHolder holder = SqlServerDialect.INSTANCE.getSimpleTypeHolder();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SqlServerDialectUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-30
|
||||
public void shouldNotSupportArrays() {
|
||||
void shouldNotSupportArrays() {
|
||||
|
||||
ArrayColumns arrayColumns = SqlServerDialect.INSTANCE.getArraySupport();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.convert.CustomConversions;
|
||||
|
||||
@@ -17,18 +17,17 @@ package org.springframework.data.r2dbc.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.r2dbc.mapping.SettableValue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SettableValue}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SettableValueUnitTests {
|
||||
class SettableValueUnitTests {
|
||||
|
||||
@Test // gh-59
|
||||
public void shouldCreateSettableValue() {
|
||||
void shouldCreateSettableValue() {
|
||||
|
||||
SettableValue value = SettableValue.from("foo");
|
||||
|
||||
@@ -38,7 +37,7 @@ public class SettableValueUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-59
|
||||
public void shouldCreateEmpty() {
|
||||
void shouldCreateEmpty() {
|
||||
|
||||
SettableValue value = SettableValue.empty(Object.class);
|
||||
|
||||
@@ -49,7 +48,7 @@ public class SettableValueUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-59
|
||||
public void shouldCreatePotentiallyEmpty() {
|
||||
void shouldCreatePotentiallyEmpty() {
|
||||
|
||||
assertThat(SettableValue.fromOrEmpty("foo", Object.class).isEmpty()).isFalse();
|
||||
assertThat(SettableValue.fromOrEmpty(null, Object.class).isEmpty()).isTrue();
|
||||
|
||||
@@ -17,13 +17,13 @@ package org.springframework.data.r2dbc.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.relational.core.query.Criteria.*;
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
|
||||
/**
|
||||
@@ -32,10 +32,10 @@ import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
* @author Mark Paluch
|
||||
* @author Mingyuan Wu
|
||||
*/
|
||||
public class CriteriaUnitTests {
|
||||
class CriteriaUnitTests {
|
||||
|
||||
@Test // gh-289
|
||||
public void fromCriteria() {
|
||||
void fromCriteria() {
|
||||
|
||||
Criteria nested1 = where("foo").isNotNull();
|
||||
Criteria nested2 = where("foo").isNull();
|
||||
@@ -47,7 +47,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-289
|
||||
public void fromCriteriaOptimized() {
|
||||
void fromCriteriaOptimized() {
|
||||
|
||||
Criteria nested = where("foo").is("bar").and("baz").isNotNull();
|
||||
Criteria criteria = Criteria.from(nested);
|
||||
@@ -56,7 +56,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-289
|
||||
public void isEmpty() {
|
||||
void isEmpty() {
|
||||
|
||||
SoftAssertions.assertSoftly(softly -> {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void andChainedCriteria() {
|
||||
void andChainedCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").is("bar").and("baz").isNotNull();
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-289
|
||||
public void andGroupedCriteria() {
|
||||
void andGroupedCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").is("bar").and(where("foo").is("baz"));
|
||||
|
||||
@@ -114,7 +114,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void orChainedCriteria() {
|
||||
void orChainedCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").is("bar").or("baz").isNotNull();
|
||||
|
||||
@@ -129,7 +129,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-289
|
||||
public void orGroupedCriteria() {
|
||||
void orGroupedCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").is("bar").or(where("foo").is("baz"));
|
||||
|
||||
@@ -147,7 +147,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildEqualsCriteria() {
|
||||
void shouldBuildEqualsCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").is("bar");
|
||||
|
||||
@@ -157,7 +157,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBuildEqualsIgnoreCaseCriteria() {
|
||||
void shouldBuildEqualsIgnoreCaseCriteria() {
|
||||
Criteria criteria = where("foo").is("bar").ignoreCase(true);
|
||||
|
||||
assertThat(criteria.getColumn()).isEqualTo(SqlIdentifier.unquoted("foo"));
|
||||
@@ -167,7 +167,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildNotEqualsCriteria() {
|
||||
void shouldBuildNotEqualsCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").not("bar");
|
||||
|
||||
@@ -177,7 +177,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildInCriteria() {
|
||||
void shouldBuildInCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").in("bar", "baz");
|
||||
|
||||
@@ -187,7 +187,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildNotInCriteria() {
|
||||
void shouldBuildNotInCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").notIn("bar", "baz");
|
||||
|
||||
@@ -197,7 +197,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildGtCriteria() {
|
||||
void shouldBuildGtCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").greaterThan(1);
|
||||
|
||||
@@ -207,7 +207,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildGteCriteria() {
|
||||
void shouldBuildGteCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").greaterThanOrEquals(1);
|
||||
|
||||
@@ -217,7 +217,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildLtCriteria() {
|
||||
void shouldBuildLtCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").lessThan(1);
|
||||
|
||||
@@ -227,7 +227,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildLteCriteria() {
|
||||
void shouldBuildLteCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").lessThanOrEquals(1);
|
||||
|
||||
@@ -237,7 +237,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildLikeCriteria() {
|
||||
void shouldBuildLikeCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").like("hello%");
|
||||
|
||||
@@ -247,7 +247,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBuildNotLikeCriteria() {
|
||||
void shouldBuildNotLikeCriteria() {
|
||||
Criteria criteria = where("foo").notLike("hello%");
|
||||
|
||||
assertThat(criteria.getColumn()).isEqualTo(SqlIdentifier.unquoted("foo"));
|
||||
@@ -256,7 +256,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildIsNullCriteria() {
|
||||
void shouldBuildIsNullCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").isNull();
|
||||
|
||||
@@ -265,7 +265,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldBuildIsNotNullCriteria() {
|
||||
void shouldBuildIsNotNullCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").isNotNull();
|
||||
|
||||
@@ -274,7 +274,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void shouldBuildIsTrueCriteria() {
|
||||
void shouldBuildIsTrueCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").isTrue();
|
||||
|
||||
@@ -283,7 +283,7 @@ public class CriteriaUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void shouldBuildIsFalseCriteria() {
|
||||
void shouldBuildIsFalseCriteria() {
|
||||
|
||||
Criteria criteria = where("foo").isFalse();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.springframework.data.domain.Sort.Order.*;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.convert.MappingR2dbcConverter;
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.r2dbc.convert.MappingR2dbcConverter;
|
||||
import org.springframework.data.r2dbc.convert.R2dbcConverter;
|
||||
@@ -46,12 +46,12 @@ import org.springframework.data.relational.core.sql.Table;
|
||||
*/
|
||||
public class UpdateMapperUnitTests {
|
||||
|
||||
R2dbcConverter converter = new MappingR2dbcConverter(new R2dbcMappingContext());
|
||||
UpdateMapper mapper = new UpdateMapper(PostgresDialect.INSTANCE, converter);
|
||||
BindTarget bindTarget = mock(BindTarget.class);
|
||||
private final R2dbcConverter converter = new MappingR2dbcConverter(new R2dbcMappingContext());
|
||||
private final UpdateMapper mapper = new UpdateMapper(PostgresDialect.INSTANCE, converter);
|
||||
private final BindTarget bindTarget = mock(BindTarget.class);
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldMapFieldNamesInUpdate() {
|
||||
void shouldMapFieldNamesInUpdate() {
|
||||
|
||||
Update update = Update.update("alternative", "foo");
|
||||
|
||||
@@ -64,7 +64,7 @@ public class UpdateMapperUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldUpdateToSettableValue() {
|
||||
void shouldUpdateToSettableValue() {
|
||||
|
||||
Update update = Update.update("alternative", SettableValue.empty(String.class));
|
||||
|
||||
@@ -80,7 +80,7 @@ public class UpdateMapperUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-64
|
||||
public void shouldUpdateToNull() {
|
||||
void shouldUpdateToNull() {
|
||||
|
||||
Update update = Update.update("alternative", null);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class UpdateMapperUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-195
|
||||
public void shouldMapMultipleFields() {
|
||||
void shouldMapMultipleFields() {
|
||||
|
||||
Update update = Update.update("c1", "a").set("c2", "b").set("c3", "c");
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ import java.util.stream.IntStream;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -63,8 +63,8 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
@Autowired private ConnectionFactory connectionFactory;
|
||||
protected JdbcTemplate jdbc;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
this.jdbc = createJdbcTemplate(createDataSource());
|
||||
|
||||
@@ -104,7 +104,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
protected abstract Class<? extends LegoSetRepository> getRepositoryInterfaceType();
|
||||
|
||||
@Test
|
||||
public void shouldInsertNewItems() {
|
||||
void shouldInsertNewItems() {
|
||||
|
||||
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12);
|
||||
LegoSet legoSet2 = new LegoSet(null, "FORSCHUNGSSCHIFF", 13);
|
||||
@@ -116,7 +116,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindItemsByManual() {
|
||||
void shouldFindItemsByManual() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindItemsByNameLike() {
|
||||
void shouldFindItemsByNameLike() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -143,7 +143,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindApplyingProjection() {
|
||||
void shouldFindApplyingProjection() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-344
|
||||
public void shouldFindApplyingDistinctProjection() {
|
||||
void shouldFindApplyingDistinctProjection() {
|
||||
|
||||
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12);
|
||||
LegoSet legoSet2 = new LegoSet(null, "SCHAUFELRADBAGGER", 13);
|
||||
@@ -177,7 +177,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-41
|
||||
public void shouldFindApplyingSimpleTypeProjection() {
|
||||
void shouldFindApplyingSimpleTypeProjection() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -190,7 +190,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeleteUsingQueryMethod() {
|
||||
void shouldDeleteUsingQueryMethod() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -203,7 +203,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-335
|
||||
public void shouldFindByPageable() {
|
||||
void shouldFindByPageable() {
|
||||
|
||||
Flux<LegoSet> sets = Flux.fromStream(IntStream.range(0, 100).mapToObj(value -> {
|
||||
return new LegoSet(null, "Set " + value, value);
|
||||
@@ -232,7 +232,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-335
|
||||
public void shouldFindTop10() {
|
||||
void shouldFindTop10() {
|
||||
|
||||
Flux<LegoSet> sets = Flux.fromStream(IntStream.range(0, 100).mapToObj(value -> {
|
||||
return new LegoSet(null, "Set " + value, value);
|
||||
@@ -250,7 +250,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-341
|
||||
public void shouldDeleteAll() {
|
||||
void shouldDeleteAll() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -286,7 +286,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-363
|
||||
public void derivedQueryWithCountProjection() {
|
||||
void derivedQueryWithCountProjection() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -297,7 +297,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
}
|
||||
|
||||
@Test // gh-421
|
||||
public void shouldDeleteAllAndReturnCount() {
|
||||
void shouldDeleteAllAndReturnCount() {
|
||||
|
||||
shouldInsertNewItems();
|
||||
|
||||
@@ -351,12 +351,12 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
|
||||
@Setter
|
||||
@Table("legoset")
|
||||
@NoArgsConstructor
|
||||
static class LegoSet extends Lego {
|
||||
public static class LegoSet extends Lego {
|
||||
String name;
|
||||
Integer manual;
|
||||
|
||||
@PersistenceConstructor
|
||||
public LegoSet(Integer id, String name, Integer manual) {
|
||||
LegoSet(Integer id, String name, Integer manual) {
|
||||
super(id);
|
||||
this.name = name;
|
||||
this.manual = manual;
|
||||
|
||||
@@ -29,9 +29,9 @@ import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@@ -44,20 +44,19 @@ import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
|
||||
import org.springframework.data.r2dbc.mapping.OutboundRow;
|
||||
import org.springframework.data.r2dbc.mapping.SettableValue;
|
||||
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
|
||||
import org.springframework.data.r2dbc.testing.H2TestSupport;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.r2dbc.core.Parameter;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ConvertedRepository} that uses {@link Converter}s on entity-level.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
public class ConvertingR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@Autowired private ConvertedRepository repository;
|
||||
@@ -79,7 +78,7 @@ public class ConvertingR2dbcRepositoryIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
this.jdbc = new JdbcTemplate(createDataSource());
|
||||
|
||||
@@ -29,8 +29,8 @@ import java.util.Arrays;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -45,7 +45,7 @@ import org.springframework.data.r2dbc.testing.H2TestSupport;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against H2.
|
||||
@@ -53,7 +53,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @author Mark Paluch
|
||||
* @author Zsombor Gegesy
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class H2R2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
@@ -34,7 +34,7 @@ import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against MySQL using Jasync
|
||||
@@ -42,11 +42,11 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class JasyncMySqlR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
|
||||
@Configuration
|
||||
@EnableR2dbcRepositories(considerNestedRepositories = true,
|
||||
|
||||
@@ -21,8 +21,8 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
@@ -34,18 +34,18 @@ import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.MariaDbTestSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against MariaDB.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class MariaDbR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MariaDbTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MariaDbTestSupport.database();
|
||||
|
||||
@Configuration
|
||||
@EnableR2dbcRepositories(considerNestedRepositories = true,
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.time.LocalDateTime;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -45,18 +45,18 @@ import org.springframework.data.r2dbc.testing.MySqlTestSupport;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against MySQL.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class MySqlR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = MySqlTestSupport.database();
|
||||
|
||||
@Autowired DateTestsRepository dateTestsRepository;
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -46,18 +46,18 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.r2dbc.core.DatabaseClient;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against Postgres.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class PostgresR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
|
||||
@Autowired JsonPersonRepository jsonPersonRepository;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class PostgresR2dbcRepositoryIntegrationTests extends AbstractR2dbcReposi
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSaveAndLoadJson() {
|
||||
void shouldSaveAndLoadJson() {
|
||||
|
||||
JdbcTemplate template = new JdbcTemplate(createDataSource());
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
@@ -35,18 +35,18 @@ import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LegoSetRepository} using {@link R2dbcRepositoryFactory} against Microsoft SQL Server.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class SqlServerR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
|
||||
@Configuration
|
||||
@EnableR2dbcRepositories(considerNestedRepositories = true,
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -43,7 +43,7 @@ import org.springframework.r2dbc.core.binding.BindMarkersFactory;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class R2dbcRepositoriesRegistrarTests {
|
||||
class R2dbcRepositoriesRegistrarTests {
|
||||
|
||||
@Configuration
|
||||
@EnableR2dbcRepositories(basePackages = "org.springframework.data.r2dbc.repository.config")
|
||||
@@ -128,7 +128,7 @@ public class R2dbcRepositoriesRegistrarTests {
|
||||
}
|
||||
|
||||
@Test // gh-13
|
||||
public void testConfigurationUsingDatabaseClient() {
|
||||
void testConfigurationUsingDatabaseClient() {
|
||||
|
||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EnableWithDatabaseClient.class)) {
|
||||
@@ -138,7 +138,7 @@ public class R2dbcRepositoriesRegistrarTests {
|
||||
}
|
||||
|
||||
@Test // gh-406
|
||||
public void testConfigurationUsingEntityOperations() {
|
||||
void testConfigurationUsingEntityOperations() {
|
||||
|
||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
EnableWithEntityOperations.class)) {
|
||||
@@ -148,7 +148,7 @@ public class R2dbcRepositoriesRegistrarTests {
|
||||
}
|
||||
|
||||
@Test // gh-406
|
||||
public void testMultipleDatabases() {
|
||||
void testMultipleDatabases() {
|
||||
|
||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MySQLConfiguration.class,
|
||||
SQLServerConfiguration.class)) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -41,32 +41,33 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class R2dbcRepositoryConfigurationExtensionUnitTests {
|
||||
class R2dbcRepositoryConfigurationExtensionUnitTests {
|
||||
|
||||
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true);
|
||||
ResourceLoader loader = new PathMatchingResourcePatternResolver();
|
||||
Environment environment = new StandardEnvironment();
|
||||
BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
|
||||
private final StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true);
|
||||
private final ResourceLoader loader = new PathMatchingResourcePatternResolver();
|
||||
private final Environment environment = new StandardEnvironment();
|
||||
private final BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
|
||||
|
||||
RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata,
|
||||
private final RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(
|
||||
metadata,
|
||||
EnableR2dbcRepositories.class, loader, environment, registry);
|
||||
|
||||
@Test // gh-13
|
||||
public void isStrictMatchIfDomainTypeIsAnnotatedWithDocument() {
|
||||
void isStrictMatchIfDomainTypeIsAnnotatedWithDocument() {
|
||||
|
||||
R2dbcRepositoryConfigurationExtension extension = new R2dbcRepositoryConfigurationExtension();
|
||||
assertHasRepo(SampleRepository.class, extension.getRepositoryConfigurations(configurationSource, loader, true));
|
||||
}
|
||||
|
||||
@Test // gh-13
|
||||
public void isStrictMatchIfRepositoryExtendsStoreSpecificBase() {
|
||||
void isStrictMatchIfRepositoryExtendsStoreSpecificBase() {
|
||||
|
||||
R2dbcRepositoryConfigurationExtension extension = new R2dbcRepositoryConfigurationExtension();
|
||||
assertHasRepo(StoreRepository.class, extension.getRepositoryConfigurations(configurationSource, loader, true));
|
||||
}
|
||||
|
||||
@Test // gh-13
|
||||
public void isNotStrictMatchIfDomainTypeIsNotAnnotatedWithDocument() {
|
||||
void isNotStrictMatchIfDomainTypeIsNotAnnotatedWithDocument() {
|
||||
|
||||
R2dbcRepositoryConfigurationExtension extension = new R2dbcRepositoryConfigurationExtension();
|
||||
assertDoesNotHaveRepo(UnannotatedRepository.class,
|
||||
@@ -74,7 +75,7 @@ public class R2dbcRepositoryConfigurationExtensionUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-13
|
||||
public void doesNotHaveNonReactiveRepository() {
|
||||
void doesNotHaveNonReactiveRepository() {
|
||||
|
||||
R2dbcRepositoryConfigurationExtension extension = new R2dbcRepositoryConfigurationExtension();
|
||||
assertDoesNotHaveRepo(NonReactiveRepository.class,
|
||||
@@ -105,7 +106,7 @@ public class R2dbcRepositoryConfigurationExtensionUnitTests {
|
||||
}
|
||||
|
||||
@EnableR2dbcRepositories(considerNestedRepositories = true)
|
||||
static class Config {}
|
||||
private static class Config {}
|
||||
|
||||
@Table("sample")
|
||||
static class Sample {}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.r2dbc.repository.query;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ExpressionQuery}.
|
||||
@@ -26,10 +26,10 @@ import org.junit.Test;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public class ExpressionQueryUnitTests {
|
||||
class ExpressionQueryUnitTests {
|
||||
|
||||
@Test // gh-373
|
||||
public void bindsMultipleSpelParametersCorrectly() {
|
||||
void bindsMultipleSpelParametersCorrectly() {
|
||||
|
||||
ExpressionQuery query = ExpressionQuery
|
||||
.create("INSERT IGNORE INTO table (x, y) VALUES (:#{#point.x}, :#{#point.y})");
|
||||
|
||||
@@ -29,11 +29,13 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
@@ -58,8 +60,9 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
||||
* @author Mingyuan Wu
|
||||
* @author Myeonghyeon Lee
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PartTreeR2dbcQueryUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class PartTreeR2dbcQueryUnitTests {
|
||||
|
||||
private static final String TABLE = "users";
|
||||
private static final String ALL_FIELDS = TABLE + ".id, " + TABLE + ".first_name, " + TABLE + ".last_name, " + TABLE
|
||||
@@ -69,12 +72,12 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
@Mock ConnectionFactory connectionFactory;
|
||||
@Mock R2dbcConverter r2dbcConverter;
|
||||
|
||||
RelationalMappingContext mappingContext;
|
||||
ReactiveDataAccessStrategy dataAccessStrategy;
|
||||
DatabaseClient databaseClient;
|
||||
private RelationalMappingContext mappingContext;
|
||||
private ReactiveDataAccessStrategy dataAccessStrategy;
|
||||
private DatabaseClient databaseClient;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
ConnectionFactoryMetadata metadataMock = mock(ConnectionFactoryMetadata.class);
|
||||
when(metadataMock.getName()).thenReturn("PostgreSQL");
|
||||
@@ -92,7 +95,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttribute() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttribute() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -104,7 +107,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryWithIsNullCondition() throws Exception {
|
||||
void createsQueryWithIsNullCondition() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -116,7 +119,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryWithLimitForExistsProjection() throws Exception {
|
||||
void createsQueryWithLimitForExistsProjection() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("existsByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -128,7 +131,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameAndFirstName", String.class, String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -140,7 +143,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameOrFirstName", String.class, String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -152,7 +155,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282, gh-349
|
||||
public void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBetween", Date.class, Date.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -174,7 +177,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeLessThan() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeLessThan() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThan", Integer.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -187,7 +190,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThanEqual", Integer.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -200,7 +203,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThan", Integer.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -213,7 +216,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThanEqual", Integer.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -226,7 +229,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthAfter", Date.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -239,7 +242,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception {
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBefore", Date.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
dataAccessStrategy);
|
||||
@@ -251,7 +254,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNull");
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -264,7 +267,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeIsNotNull() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeIsNotNull() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNotNull");
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -277,7 +280,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameLike", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -290,7 +293,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotLike", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -303,7 +306,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -317,7 +320,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test // gh-282
|
||||
public void appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery() throws Exception {
|
||||
void appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -331,7 +334,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -345,7 +348,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test // gh-282
|
||||
public void prependsLikeOperatorParameterWithPercentSymbolForEndingWithQuery() throws Exception {
|
||||
void prependsLikeOperatorParameterWithPercentSymbolForEndingWithQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -359,7 +362,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeContaining() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeContaining() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -373,7 +376,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test // gh-282
|
||||
public void wrapsLikeOperatorParameterWithPercentSymbolsForContainingQuery() throws Exception {
|
||||
void wrapsLikeOperatorParameterWithPercentSymbolsForContainingQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -387,7 +390,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeNotContaining() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeNotContaining() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -401,7 +404,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test // gh-282
|
||||
public void wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery() throws Exception {
|
||||
void wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -415,7 +418,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute()
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute()
|
||||
throws Exception {
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameDesc", Integer.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -428,7 +431,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeWithAscendingOrderingByStringAttribute() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeWithAscendingOrderingByStringAttribute() throws Exception {
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameAsc", Integer.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
dataAccessStrategy);
|
||||
@@ -440,7 +443,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeNot() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeNot() throws Exception {
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameNot", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
dataAccessStrategy);
|
||||
@@ -452,7 +455,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeIn() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeIn() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIn", Collection.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -466,7 +469,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByIntegerAttributeNotIn() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByIntegerAttributeNotIn() throws Exception {
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeNotIn", Collection.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
dataAccessStrategy);
|
||||
@@ -479,7 +482,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByBooleanAttributeTrue() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByBooleanAttributeTrue() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveTrue");
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -492,7 +495,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByBooleanAttributeFalse() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByBooleanAttributeFalse() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveFalse");
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -505,7 +508,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeIgnoringCase() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeIgnoringCase() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameIgnoreCase", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -518,7 +521,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void throwsExceptionWhenIgnoringCaseIsImpossible() throws Exception {
|
||||
void throwsExceptionWhenIgnoringCaseIsImpossible() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findByIdIgnoringCase", Long.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -529,7 +532,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void throwsExceptionWhenInPredicateHasNonIterableParameter() throws Exception {
|
||||
void throwsExceptionWhenInPredicateHasNonIterableParameter() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIn", Long.class);
|
||||
|
||||
@@ -538,7 +541,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void throwsExceptionWhenSimplePropertyPredicateHasIterableParameter() throws Exception {
|
||||
void throwsExceptionWhenSimplePropertyPredicateHasIterableParameter() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllById", Collection.class);
|
||||
|
||||
@@ -547,7 +550,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void throwsExceptionWhenConditionKeywordIsUnsupported() throws Exception {
|
||||
void throwsExceptionWhenConditionKeywordIsUnsupported() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIsEmpty");
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -558,7 +561,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void throwsExceptionWhenInvalidNumberOfParameterIsGiven() throws Exception {
|
||||
void throwsExceptionWhenInvalidNumberOfParameterIsGiven() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -569,7 +572,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception {
|
||||
void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findTop3ByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -582,7 +585,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void createsQueryToFindFirstEntityByStringAttribute() throws Exception {
|
||||
void createsQueryToFindFirstEntityByStringAttribute() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findFirstByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -595,7 +598,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-341
|
||||
public void createsQueryToDeleteByFirstName() throws Exception {
|
||||
void createsQueryToDeleteByFirstName() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("deleteByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -607,7 +610,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-344
|
||||
public void createsQueryToFindAllEntitiesByStringAttributeWithDistinct() throws Exception {
|
||||
void createsQueryToFindAllEntitiesByStringAttributeWithDistinct() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("findDistinctByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
@@ -619,7 +622,7 @@ public class PartTreeR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-363
|
||||
public void createsQueryForCountProjection() throws Exception {
|
||||
void createsQueryForCountProjection() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = getQueryMethod("countByFirstName", String.class);
|
||||
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, databaseClient, r2dbcConverter,
|
||||
|
||||
@@ -19,10 +19,11 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.r2dbc.core.DatabaseClient;
|
||||
import org.springframework.r2dbc.core.PreparedOperation;
|
||||
|
||||
@@ -32,14 +33,14 @@ import org.springframework.r2dbc.core.PreparedOperation;
|
||||
* @author Roman Chigvintsev
|
||||
* @author Marl Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@Ignore
|
||||
public class PreparedOperationBindableQueryUnitTests {
|
||||
class PreparedOperationBindableQueryUnitTests {
|
||||
|
||||
@Mock PreparedOperation<?> preparedOperation;
|
||||
|
||||
@Test // gh-282
|
||||
public void bindsQueryParameterValues() {
|
||||
void bindsQueryParameterValues() {
|
||||
|
||||
DatabaseClient.GenericExecuteSpec bindSpecMock = mock(DatabaseClient.GenericExecuteSpec.class);
|
||||
|
||||
@@ -49,7 +50,7 @@ public class PreparedOperationBindableQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-282
|
||||
public void returnsSqlQuery() {
|
||||
void returnsSqlQuery() {
|
||||
|
||||
when(preparedOperation.get()).thenReturn("SELECT * FROM test");
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.r2dbc.repository.query;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -26,8 +25,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -49,17 +48,17 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat
|
||||
* @author Mark Paluch
|
||||
* @author Stephen Cohen
|
||||
*/
|
||||
public class R2dbcQueryMethodUnitTests {
|
||||
class R2dbcQueryMethodUnitTests {
|
||||
|
||||
RelationalMappingContext context;
|
||||
private RelationalMappingContext context;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.context = new R2dbcMappingContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void detectsCollectionFromReturnTypeIfReturnTypeAssignable() throws Exception {
|
||||
void detectsCollectionFromReturnTypeIfReturnTypeAssignable() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = queryMethod(SampleRepository.class, "method");
|
||||
RelationalEntityMetadata<?> metadata = queryMethod.getEntityInformation();
|
||||
@@ -69,7 +68,7 @@ public class R2dbcQueryMethodUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-235
|
||||
public void detectsModifyingQuery() throws Exception {
|
||||
void detectsModifyingQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = queryMethod(SampleRepository.class, "method");
|
||||
|
||||
@@ -77,7 +76,7 @@ public class R2dbcQueryMethodUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-235
|
||||
public void detectsNotModifyingQuery() throws Exception {
|
||||
void detectsNotModifyingQuery() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = queryMethod(SampleRepository.class, "differentTable");
|
||||
|
||||
@@ -85,7 +84,7 @@ public class R2dbcQueryMethodUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void detectsTableNameFromRepoTypeIfReturnTypeNotAssignable() throws Exception {
|
||||
void detectsTableNameFromRepoTypeIfReturnTypeNotAssignable() throws Exception {
|
||||
|
||||
R2dbcQueryMethod queryMethod = queryMethod(SampleRepository.class, "differentTable");
|
||||
RelationalEntityMetadata<?> metadata = queryMethod.getEntityInformation();
|
||||
@@ -94,37 +93,40 @@ public class R2dbcQueryMethodUnitTests {
|
||||
assertThat(metadata.getTableName()).isEqualTo(SqlIdentifier.unquoted("contact"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsNullMappingContext() throws Exception {
|
||||
@Test
|
||||
void rejectsNullMappingContext() throws Exception {
|
||||
|
||||
Method method = PersonRepository.class.getMethod("findMonoByLastname", String.class, Pageable.class);
|
||||
|
||||
new R2dbcQueryMethod(method, new DefaultRepositoryMetadata(PersonRepository.class),
|
||||
new SpelAwareProxyProjectionFactory(), null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void rejectsMonoPageableResult() throws Exception {
|
||||
queryMethod(PersonRepository.class, "findMonoByLastname", String.class, Pageable.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new R2dbcQueryMethod(method,
|
||||
new DefaultRepositoryMetadata(PersonRepository.class), new SpelAwareProxyProjectionFactory(), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsQueryMethodObjectForMethodReturningAnInterface() throws Exception {
|
||||
void rejectsMonoPageableResult() {
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> queryMethod(PersonRepository.class, "findMonoByLastname", String.class, Pageable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsQueryMethodObjectForMethodReturningAnInterface() throws Exception {
|
||||
queryMethod(SampleRepository.class, "methodReturningAnInterface");
|
||||
}
|
||||
|
||||
@Test(expected = InvalidDataAccessApiUsageException.class)
|
||||
public void throwsExceptionOnWrappedPage() throws Exception {
|
||||
queryMethod(PersonRepository.class, "findMonoPageByLastname", String.class, Pageable.class);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidDataAccessApiUsageException.class)
|
||||
public void throwsExceptionOnWrappedSlice() throws Exception {
|
||||
queryMethod(PersonRepository.class, "findMonoSliceByLastname", String.class, Pageable.class);
|
||||
@Test
|
||||
void throwsExceptionOnWrappedPage() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> queryMethod(PersonRepository.class, "findMonoPageByLastname", String.class, Pageable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fallsBackToRepositoryDomainTypeIfMethodDoesNotReturnADomainType() throws Exception {
|
||||
void throwsExceptionOnWrappedSlice() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> queryMethod(PersonRepository.class, "findMonoSliceByLastname", String.class, Pageable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fallsBackToRepositoryDomainTypeIfMethodDoesNotReturnADomainType() throws Exception {
|
||||
|
||||
R2dbcQueryMethod method = queryMethod(PersonRepository.class, "deleteByUserName", String.class);
|
||||
|
||||
@@ -132,7 +134,7 @@ public class R2dbcQueryMethodUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-421
|
||||
public void fallsBackToRepositoryDomainTypeIfMethodReturnsKotlinUnit() throws Exception {
|
||||
void fallsBackToRepositoryDomainTypeIfMethodReturnsKotlinUnit() throws Exception {
|
||||
|
||||
R2dbcQueryMethod method = queryMethod(PersonRepository.class, "deleteByFirstname", String.class);
|
||||
|
||||
@@ -173,11 +175,11 @@ public class R2dbcQueryMethodUnitTests {
|
||||
|
||||
static class Contact {}
|
||||
|
||||
static class Address {}
|
||||
private static class Address {}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Modifying
|
||||
public @interface MyModifyingAnnotation {
|
||||
@interface MyModifyingAnnotation {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,13 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.projection.ProjectionFactory;
|
||||
@@ -49,7 +51,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
public class StringBasedR2dbcQueryUnitTests {
|
||||
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
@@ -62,8 +65,8 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
private ProjectionFactory factory;
|
||||
private RepositoryMetadata metadata;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.mappingContext = new R2dbcMappingContext();
|
||||
this.converter = new MappingR2dbcConverter(this.mappingContext);
|
||||
@@ -75,7 +78,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindsSimplePropertyCorrectly() {
|
||||
void bindsSimplePropertyCorrectly() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("findByLastname", String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White");
|
||||
@@ -89,7 +92,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-164
|
||||
public void bindsPositionalPropertyCorrectly() {
|
||||
void bindsPositionalPropertyCorrectly() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("findByLastnamePositional", String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White");
|
||||
@@ -103,7 +106,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindsByNamedParameter() {
|
||||
void bindsByNamedParameter() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("findByNamedParameter", String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White");
|
||||
@@ -117,7 +120,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindsByBindmarker() {
|
||||
void bindsByBindmarker() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("findByNamedBindMarker", String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White");
|
||||
@@ -131,7 +134,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bindsByIndexWithNamedParameter() {
|
||||
void bindsByIndexWithNamedParameter() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("findNotByNamedBindMarker", String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White");
|
||||
@@ -145,7 +148,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-164
|
||||
public void bindsSimpleSpelQuery() {
|
||||
void bindsSimpleSpelQuery() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("simpleSpel");
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod());
|
||||
@@ -159,7 +162,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-164
|
||||
public void bindsIndexedSpelQuery() {
|
||||
void bindsIndexedSpelQuery() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("simpleIndexedSpel", String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White");
|
||||
@@ -174,7 +177,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-164
|
||||
public void bindsPositionalSpelQuery() {
|
||||
void bindsPositionalSpelQuery() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("simplePositionalSpel", String.class, String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White", "Walter");
|
||||
@@ -191,7 +194,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-164
|
||||
public void bindsPositionalNamedSpelQuery() {
|
||||
void bindsPositionalNamedSpelQuery() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("simpleNamedSpel", String.class, String.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "White", "Walter");
|
||||
@@ -208,7 +211,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-164
|
||||
public void bindsComplexSpelQuery() {
|
||||
void bindsComplexSpelQuery() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("queryWithSpelObject", Person.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), new Person("Walter"));
|
||||
@@ -223,7 +226,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-321
|
||||
public void skipsNonBindableParameters() {
|
||||
void skipsNonBindableParameters() {
|
||||
|
||||
StringBasedR2dbcQuery query = getQueryMethod("queryWithUnusedParameter", String.class, Sort.class);
|
||||
R2dbcParameterAccessor accessor = new R2dbcParameterAccessor(query.getQueryMethod(), "Walter", null);
|
||||
@@ -288,7 +291,7 @@ public class StringBasedR2dbcQueryUnitTests {
|
||||
|
||||
String name;
|
||||
|
||||
public Person(String name) {
|
||||
Person(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,15 +31,14 @@ import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.domain.Persistable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.r2dbc.convert.MappingR2dbcConverter;
|
||||
import org.springframework.data.r2dbc.core.ReactiveDataAccessStrategy;
|
||||
@@ -70,8 +69,8 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
SimpleR2dbcRepository<LegoSet, Integer> repository;
|
||||
JdbcTemplate jdbc;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
RelationalEntityInformation<LegoSet, Integer> entityInformation = new MappingRelationalEntityInformation<>(
|
||||
(RelationalPersistentEntity<LegoSet>) mappingContext.getRequiredPersistentEntity(LegoSet.class));
|
||||
@@ -107,7 +106,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
protected abstract String getCreateTableStatement();
|
||||
|
||||
@Test // gh-444
|
||||
public void shouldSaveNewObject() {
|
||||
void shouldSaveNewObject() {
|
||||
|
||||
repository.save(new LegoSet(0, "SCHAUFELRADBAGGER", 12)) //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -124,7 +123,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test // gh-93
|
||||
public void shouldSaveNewObjectAndSetVersionIfWrapperVersionPropertyExists() {
|
||||
void shouldSaveNewObjectAndSetVersionIfWrapperVersionPropertyExists() {
|
||||
|
||||
LegoSetVersionable legoSet = new LegoSetVersionable(0, "SCHAUFELRADBAGGER", 12, null);
|
||||
|
||||
@@ -142,7 +141,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test // gh-93
|
||||
public void shouldSaveNewObjectAndSetVersionIfPrimitiveVersionPropertyExists() {
|
||||
void shouldSaveNewObjectAndSetVersionIfPrimitiveVersionPropertyExists() {
|
||||
|
||||
LegoSetPrimitiveVersionable legoSet = new LegoSetPrimitiveVersionable(0, "SCHAUFELRADBAGGER", 12, 0);
|
||||
|
||||
@@ -160,7 +159,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldUpdateObject() {
|
||||
void shouldUpdateObject() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -178,7 +177,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test // gh-93
|
||||
public void shouldUpdateVersionableObjectAndIncreaseVersion() {
|
||||
void shouldUpdateVersionableObjectAndIncreaseVersion() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual, version) VALUES('SCHAUFELRADBAGGER', 12, 42)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -202,7 +201,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test // gh-93
|
||||
public void shouldFailWithOptimistickLockingWhenVersionDoesNotMatchOnUpdate() {
|
||||
void shouldFailWithOptimistickLockingWhenVersionDoesNotMatchOnUpdate() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual, version) VALUES('SCHAUFELRADBAGGER', 12, 42)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -216,7 +215,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSaveObjectsUsingIterable() {
|
||||
void shouldSaveObjectsUsingIterable() {
|
||||
|
||||
LegoSet legoSet1 = new LegoSet(0, "SCHAUFELRADBAGGER", 12);
|
||||
LegoSet legoSet2 = new LegoSet(0, "FORSCHUNGSSCHIFF", 13);
|
||||
@@ -237,7 +236,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSaveObjectsUsingPublisher() {
|
||||
void shouldSaveObjectsUsingPublisher() {
|
||||
|
||||
LegoSet legoSet1 = new LegoSet(0, "SCHAUFELRADBAGGER", 12);
|
||||
LegoSet legoSet2 = new LegoSet(0, "FORSCHUNGSSCHIFF", 13);
|
||||
@@ -252,7 +251,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindById() {
|
||||
void shouldFindById() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -268,7 +267,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExistsById() {
|
||||
void shouldExistsById() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -285,7 +284,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldExistsByIdPublisher() {
|
||||
void shouldExistsByIdPublisher() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -302,7 +301,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindByAll() {
|
||||
void shouldFindByAll() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('FORSCHUNGSSCHIFF', 13)");
|
||||
@@ -318,7 +317,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test // gh-407
|
||||
public void shouldFindAllWithSort() {
|
||||
void shouldFindAllWithSort() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('FORSCHUNGSSCHIFF', 13)");
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
@@ -338,7 +337,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindAllByIdUsingIterable() {
|
||||
void shouldFindAllByIdUsingIterable() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('FORSCHUNGSSCHIFF', 13)");
|
||||
@@ -356,7 +355,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindAllByIdUsingPublisher() {
|
||||
void shouldFindAllByIdUsingPublisher() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('FORSCHUNGSSCHIFF', 13)");
|
||||
@@ -374,7 +373,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCount() {
|
||||
void shouldCount() {
|
||||
|
||||
repository.count() //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -391,7 +390,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeleteById() {
|
||||
void shouldDeleteById() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -405,7 +404,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeleteByIdPublisher() {
|
||||
void shouldDeleteByIdPublisher() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -419,7 +418,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDelete() {
|
||||
void shouldDelete() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -435,7 +434,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeleteAllUsingIterable() {
|
||||
void shouldDeleteAllUsingIterable() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -451,7 +450,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeleteAllUsingPublisher() {
|
||||
void shouldDeleteAllUsingPublisher() {
|
||||
|
||||
jdbc.execute("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)");
|
||||
Integer id = jdbc.queryForObject("SELECT id FROM legoset", Integer.class);
|
||||
@@ -483,7 +482,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
static class LegoSetVersionable extends LegoSet {
|
||||
@Version Integer version;
|
||||
|
||||
public LegoSetVersionable(int id, String name, Integer manual, Integer version) {
|
||||
LegoSetVersionable(int id, String name, Integer manual, Integer version) {
|
||||
super(id, name, manual);
|
||||
this.version = version;
|
||||
}
|
||||
@@ -495,7 +494,7 @@ public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2db
|
||||
static class LegoSetPrimitiveVersionable extends LegoSet {
|
||||
@Version int version;
|
||||
|
||||
public LegoSetPrimitiveVersionable(int id, String name, Integer manual, int version) {
|
||||
LegoSetPrimitiveVersionable(int id, String name, Integer manual, int version) {
|
||||
super(id, name, manual);
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -43,14 +43,14 @@ import org.springframework.data.relational.core.mapping.RelationalPersistentEnti
|
||||
import org.springframework.data.relational.repository.query.RelationalEntityInformation;
|
||||
import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SimpleR2dbcRepository} against H2.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class H2SimpleR2dbcRepositoryIntegrationTests extends AbstractSimpleR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class H2SimpleR2dbcRepositoryIntegrationTests extends AbstractSimpleR2dbc
|
||||
}
|
||||
|
||||
@Test // gh-90
|
||||
public void shouldInsertNewObjectWithGivenId() {
|
||||
void shouldInsertNewObjectWithGivenId() {
|
||||
|
||||
try {
|
||||
this.jdbc.execute("DROP TABLE always_new");
|
||||
@@ -108,7 +108,7 @@ public class H2SimpleR2dbcRepositoryIntegrationTests extends AbstractSimpleR2dbc
|
||||
}
|
||||
|
||||
@Test // gh-232
|
||||
public void updateShouldFailIfRowDoesNotExist() {
|
||||
void updateShouldFailIfRowDoesNotExist() {
|
||||
|
||||
LegoSet legoSet = new LegoSet(9999, "SCHAUFELRADBAGGER", 12);
|
||||
|
||||
|
||||
@@ -19,26 +19,26 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.PostgresTestSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SimpleR2dbcRepository} against Postgres.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class PostgresSimpleR2dbcRepositoryIntegrationTests extends AbstractSimpleR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = PostgresTestSupport.database();
|
||||
|
||||
@Configuration
|
||||
static class IntegrationTestConfiguration extends AbstractR2dbcConfiguration {
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.data.r2dbc.repository.support;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.r2dbc.convert.MappingR2dbcConverter;
|
||||
@@ -39,7 +39,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class R2dbcRepositoryFactoryUnitTests {
|
||||
|
||||
R2dbcConverter r2dbcConverter = new MappingR2dbcConverter(new R2dbcMappingContext());
|
||||
@@ -47,7 +47,7 @@ public class R2dbcRepositoryFactoryUnitTests {
|
||||
@Mock DatabaseClient databaseClient;
|
||||
@Mock ReactiveDataAccessStrategy dataAccessStrategy;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
@SuppressWarnings("unchecked")
|
||||
public void before() {
|
||||
when(dataAccessStrategy.getConverter()).thenReturn(r2dbcConverter);
|
||||
|
||||
@@ -19,25 +19,26 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
|
||||
import org.springframework.data.r2dbc.testing.ExternalDatabase;
|
||||
import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SimpleR2dbcRepository} against Microsoft SQL Server.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class SqlServerSimpleR2dbcRepositoryIntegrationTests extends AbstractSimpleR2dbcRepositoryIntegrationTests {
|
||||
|
||||
@ClassRule public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
@RegisterExtension public static final ExternalDatabase database = SqlServerTestSupport.database();
|
||||
|
||||
@Configuration
|
||||
static class IntegrationTestConfiguration extends AbstractR2dbcConfiguration {
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.r2dbc.spi.R2dbcRollbackException;
|
||||
import io.r2dbc.spi.R2dbcTimeoutException;
|
||||
import io.r2dbc.spi.R2dbcTransientResourceException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
@@ -41,12 +41,12 @@ import org.springframework.data.r2dbc.UncategorizedR2dbcException;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
|
||||
R2dbcExceptionSubclassTranslator translator = new R2dbcExceptionSubclassTranslator();
|
||||
private final R2dbcExceptionSubclassTranslator translator = new R2dbcExceptionSubclassTranslator();
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslateTransientResourceException() {
|
||||
void shouldTranslateTransientResourceException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcTransientResourceException(""));
|
||||
|
||||
@@ -55,7 +55,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslateRollbackException() {
|
||||
void shouldTranslateRollbackException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcRollbackException());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslateTimeoutException() {
|
||||
void shouldTranslateTimeoutException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcTimeoutException());
|
||||
|
||||
@@ -71,7 +71,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldNotTranslateUnknownExceptions() {
|
||||
void shouldNotTranslateUnknownExceptions() {
|
||||
|
||||
Exception exception = translator.translate("", "", new MyTransientExceptions());
|
||||
|
||||
@@ -79,7 +79,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslateNonTransientResourceException() {
|
||||
void shouldTranslateNonTransientResourceException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcNonTransientResourceException());
|
||||
|
||||
@@ -87,7 +87,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslateIntegrityViolationException() {
|
||||
void shouldTranslateIntegrityViolationException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcDataIntegrityViolationException());
|
||||
|
||||
@@ -95,7 +95,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslatePermissionDeniedException() {
|
||||
void shouldTranslatePermissionDeniedException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcPermissionDeniedException());
|
||||
|
||||
@@ -103,7 +103,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void shouldTranslateBadSqlGrammarException() {
|
||||
void shouldTranslateBadSqlGrammarException() {
|
||||
|
||||
Exception exception = translator.translate("", "", new R2dbcBadGrammarException());
|
||||
|
||||
@@ -111,7 +111,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void messageGeneration() {
|
||||
void messageGeneration() {
|
||||
|
||||
Exception exception = translator.translate("TASK", "SOME-SQL", new R2dbcTransientResourceException("MESSAGE"));
|
||||
|
||||
@@ -121,7 +121,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void messageGenerationNullSQL() {
|
||||
void messageGenerationNullSQL() {
|
||||
|
||||
Exception exception = translator.translate("TASK", null, new R2dbcTransientResourceException("MESSAGE"));
|
||||
|
||||
@@ -131,7 +131,7 @@ public class R2dbcExceptionSubclassTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // gh-57
|
||||
public void messageGenerationNullMessage() {
|
||||
void messageGenerationNullMessage() {
|
||||
|
||||
Exception exception = translator.translate("TASK", "SOME-SQL", new R2dbcTransientResourceException());
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import io.r2dbc.spi.R2dbcException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.dao.CannotAcquireLockException;
|
||||
import org.springframework.dao.CannotSerializeTransactionException;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -37,9 +37,9 @@ import org.springframework.jdbc.support.SQLErrorCodes;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
|
||||
private static SQLErrorCodes ERROR_CODES = new SQLErrorCodes();
|
||||
private static final SQLErrorCodes ERROR_CODES = new SQLErrorCodes();
|
||||
static {
|
||||
ERROR_CODES.setBadSqlGrammarCodes("1", "2");
|
||||
ERROR_CODES.setInvalidResultSetAccessCodes("3", "4");
|
||||
@@ -52,7 +52,7 @@ public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTranslateToBadGrammarException() {
|
||||
void shouldTranslateToBadGrammarException() {
|
||||
|
||||
R2dbcExceptionTranslator sut = new SqlErrorCodeR2dbcExceptionTranslator(ERROR_CODES);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTranslateToResultException() {
|
||||
void shouldTranslateToResultException() {
|
||||
|
||||
R2dbcExceptionTranslator sut = new SqlErrorCodeR2dbcExceptionTranslator(ERROR_CODES);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFallbackToUncategorized() {
|
||||
void shouldFallbackToUncategorized() {
|
||||
|
||||
R2dbcExceptionTranslator sut = new SqlErrorCodeR2dbcExceptionTranslator(ERROR_CODES);
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldTranslateDataIntegrityViolationException() {
|
||||
void shouldTranslateDataIntegrityViolationException() {
|
||||
|
||||
R2dbcExceptionTranslator sut = new SqlErrorCodeR2dbcExceptionTranslator(ERROR_CODES);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void errorCodeTranslation() {
|
||||
void errorCodeTranslation() {
|
||||
|
||||
R2dbcExceptionTranslator sut = new SqlErrorCodeR2dbcExceptionTranslator(ERROR_CODES);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class SqlErrorCodeR2dbcExceptionTranslatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldApplyCustomTranslation() {
|
||||
void shouldApplyCustomTranslation() {
|
||||
|
||||
String TASK = "TASK";
|
||||
String SQL = "SQL SELECT *";
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import io.r2dbc.spi.R2dbcException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
@@ -33,44 +33,45 @@ import org.springframework.data.r2dbc.UncategorizedR2dbcException;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SqlStateR2dbcExceptionTranslatorUnitTests {
|
||||
class SqlStateR2dbcExceptionTranslatorUnitTests {
|
||||
|
||||
private static final String REASON = "The game is afoot!";
|
||||
private static final String TASK = "Counting sheep... yawn.";
|
||||
private static final String SQL = "select count(0) from t_sheep where over_fence = ... yawn... 1";
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testTranslateNullException() {
|
||||
new SqlStateR2dbcExceptionTranslator().translate("", "", null);
|
||||
@Test
|
||||
void testTranslateNullException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new SqlStateR2dbcExceptionTranslator().translate("", "", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateBadSqlGrammar() {
|
||||
void testTranslateBadSqlGrammar() {
|
||||
doTest("07", BadSqlGrammarException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateDataIntegrityViolation() {
|
||||
void testTranslateDataIntegrityViolation() {
|
||||
doTest("23", DataIntegrityViolationException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateDataAccessResourceFailure() {
|
||||
void testTranslateDataAccessResourceFailure() {
|
||||
doTest("53", DataAccessResourceFailureException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateTransientDataAccessResourceFailure() {
|
||||
void testTranslateTransientDataAccessResourceFailure() {
|
||||
doTest("S1", TransientDataAccessResourceException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateConcurrencyFailure() {
|
||||
void testTranslateConcurrencyFailure() {
|
||||
doTest("40", ConcurrencyFailureException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateUncategorized() {
|
||||
void testTranslateUncategorized() {
|
||||
doTest("00000000", UncategorizedR2dbcException.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,22 +22,22 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.AssumptionViolatedException;
|
||||
import org.junit.rules.ExternalResource;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.opentest4j.TestAbortedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testcontainers.containers.JdbcDatabaseContainer;
|
||||
|
||||
/**
|
||||
* {@link ExternalResource} wrapper to encapsulate {@link ProvidedDatabase} and
|
||||
* {@link org.testcontainers.containers.PostgreSQLContainer}.
|
||||
* {@link BeforeAllCallback} wrapper to encapsulate {@link ProvidedDatabase} and {@link JdbcDatabaseContainer}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public abstract class ExternalDatabase extends ExternalResource {
|
||||
public abstract class ExternalDatabase implements BeforeAllCallback {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(ExternalDatabase.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExternalDatabase.class);
|
||||
|
||||
/**
|
||||
* Construct an absent database that is used as {@literal null} object if no database is available.
|
||||
@@ -79,13 +79,13 @@ public abstract class ExternalDatabase extends ExternalResource {
|
||||
public abstract String getJdbcUrl();
|
||||
|
||||
/**
|
||||
* Throws an {@link AssumptionViolatedException} if the database cannot be reached.
|
||||
* Throws an {@link TestAbortedException} if the database cannot be reached.
|
||||
*/
|
||||
@Override
|
||||
protected void before() {
|
||||
public void beforeAll(ExtensionContext context) {
|
||||
|
||||
if (!checkValidity()) {
|
||||
throw new AssumptionViolatedException(
|
||||
throw new TestAbortedException(
|
||||
String.format("Cannot connect to %s:%d. Skipping tests.", getHostname(), getPort()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user