diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/AbstractAuditingTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/AbstractAuditingTests.java index 9d45d711f..ebed8d78e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/AbstractAuditingTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/AbstractAuditingTests.java @@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*; import java.time.LocalDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.data.annotation.CreatedDate; @@ -38,10 +38,10 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public abstract class AbstractAuditingTests { +abstract class AbstractAuditingTests { @Test // DATACASS-4 - public void enablesAuditingAndSetsPropertiesAccordingly() throws Exception { + void enablesAuditingAndSetsPropertiesAccordingly() throws Exception { ApplicationContext context = getApplicationContext(); @@ -66,7 +66,7 @@ public abstract class AbstractAuditingTests { } @Test // DATACASS-4 - public void enablesReactiveAuditingAndSetsPropertiesAccordingly() throws Exception { + void enablesReactiveAuditingAndSetsPropertiesAccordingly() throws Exception { ApplicationContext context = getApplicationContext(); @@ -93,11 +93,12 @@ public abstract class AbstractAuditingTests { protected abstract ApplicationContext getApplicationContext(); @Table + private class Entity { - @Id Long id; - @CreatedDate LocalDateTime created; - LocalDateTime modified; + @Id private Long id; + @CreatedDate private LocalDateTime created; + private LocalDateTime modified; @LastModifiedDate public LocalDateTime getModified() { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraAuditingRegistrarUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraAuditingRegistrarUnitTests.java index a89e26699..3d168a875 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraAuditingRegistrarUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraAuditingRegistrarUnitTests.java @@ -17,10 +17,10 @@ package org.springframework.data.cassandra.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.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.core.type.AnnotationMetadata; @@ -30,21 +30,21 @@ import org.springframework.core.type.AnnotationMetadata; * * @author Mark Paluch */ -@RunWith(MockitoJUnitRunner.class) -public class CassandraAuditingRegistrarUnitTests { +@ExtendWith(MockitoExtension.class) +class CassandraAuditingRegistrarUnitTests { - CassandraAuditingRegistrar registrar = new CassandraAuditingRegistrar(); + private CassandraAuditingRegistrar registrar = new CassandraAuditingRegistrar(); @Mock AnnotationMetadata metadata; @Mock BeanDefinitionRegistry registry; @Test // DATACASS-4 - public void rejectsNullAnnotationMetadata() { + void rejectsNullAnnotationMetadata() { assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(null, registry)); } @Test // DATACASS-4 - public void rejectsNullBeanDefinitionRegistry() { + void rejectsNullBeanDefinitionRegistry() { assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(metadata, null)); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraNamespaceIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraNamespaceIntegrationTests.java index cba0d9154..7b8471a10 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraNamespaceIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CassandraNamespaceIntegrationTests.java @@ -20,8 +20,7 @@ import static org.assertj.core.api.Assertions.*; import java.util.List; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -30,8 +29,7 @@ import org.springframework.data.cassandra.core.cql.CqlTemplate; import org.springframework.data.cassandra.core.mapping.CassandraMappingContext; import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver; import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.util.ReflectionTestUtils; /** @@ -40,15 +38,14 @@ import org.springframework.test.util.ReflectionTestUtils; * * @author Mark Paluch */ -@RunWith(SpringRunner.class) -@ContextConfiguration +@SpringJUnitConfig @SuppressWarnings("unused") -public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { +class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Autowired private ApplicationContext applicationContext; @Test // DATACASS-705 - public void keyspaceShouldBeInitialized() { + void keyspaceShouldBeInitialized() { CqlTemplate cqlTemplate = this.applicationContext.getBean(CqlTemplate.class); @@ -58,7 +55,7 @@ public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbedd } @Test // DATACASS-172 - public void mappingContextShouldHaveUserTypeResolverConfigured() { + void mappingContextShouldHaveUserTypeResolverConfigured() { CassandraMappingContext mappingContext = this.applicationContext.getBean(CassandraMappingContext.class); @@ -69,7 +66,7 @@ public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbedd } @Test // DATACASS-417 - public void mappingContextShouldCassandraTemplateConfigured() { + void mappingContextShouldCassandraTemplateConfigured() { CassandraTemplate cassandraTemplate = this.applicationContext.getBean(CassandraTemplate.class); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ConfigIntegrationTests.java index 38198d910..41858f1d6 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ConfigIntegrationTests.java @@ -15,15 +15,13 @@ */ package org.springframework.data.cassandra.config; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.support.AbstractTestJavaConfig; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.datastax.oss.driver.api.core.CqlSession; @@ -31,9 +29,8 @@ import com.datastax.oss.driver.api.core.CqlSession; * @author Matthew T. Adams * @author Mark Paluch */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = ConfigIntegrationTests.Config.class) -public class ConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +@SpringJUnitConfig(classes = ConfigIntegrationTests.Config.class) +class ConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { @Configuration static class Config extends AbstractTestJavaConfig { @@ -47,7 +44,7 @@ public class ConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationT @Autowired CqlSession session; @Test - public void test() { + void test() { session.execute("DROP KEYSPACE IF EXISTS ConfigTest"); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CqlTemplateConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CqlTemplateConfigIntegrationTests.java index 431455ab9..0b6ce38be 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CqlTemplateConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/CqlTemplateConfigIntegrationTests.java @@ -18,14 +18,15 @@ package org.springframework.data.cassandra.config; import static org.assertj.core.api.Assertions.*; 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.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.core.cql.CqlTemplate; -import org.springframework.data.cassandra.test.util.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.test.util.IntegrationTestsSupport; +import org.springframework.data.cassandra.test.util.CassandraExtension; import com.datastax.oss.driver.api.core.CqlSession; @@ -36,7 +37,7 @@ import com.datastax.oss.driver.api.core.CqlSession; * @author Oliver Gierke * @author Mark Paluch */ -public class CqlTemplateConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest { +class CqlTemplateConfigIntegrationTests extends IntegrationTestsSupport { @Configuration static class Config extends AbstractCqlTemplateConfiguration { @@ -53,28 +54,28 @@ public class CqlTemplateConfigIntegrationTests extends AbstractEmbeddedCassandra @Override protected int getPort() { - return cassandraEnvironment.getPort(); + return CassandraExtension.getResources().getPort(); } } - CqlSession session; - ConfigurableApplicationContext context; + private CqlSession session; + private ConfigurableApplicationContext context; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.context = new AnnotationConfigApplicationContext(Config.class); this.session = context.getBean(CqlSession.class); } @After - public void tearDown() { + void tearDown() { context.close(); } @Test - public void test() { + void test() { CqlTemplate cqlTemplate = context.getBean(CqlTemplate.class); assertThat(cqlTemplate.describeRing()).isNotEmpty(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java index 727bc39e3..ad7d02384 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests.java @@ -15,28 +15,25 @@ */ package org.springframework.data.cassandra.config; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.support.KeyspaceTestUtils; -import org.springframework.data.cassandra.test.util.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.data.cassandra.test.util.IntegrationTestsSupport; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.datastax.oss.driver.api.core.CqlSession; /** * @author Matthew T. Adams */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -public class FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest { +@SpringJUnitConfig +class FullySpecifiedKeyspaceCreatingXmlConfigIntegrationTests extends IntegrationTestsSupport { @Autowired CqlSession session; @Test - public void test() { + void test() { KeyspaceTestUtils.assertKeyspaceExists("full1", session); KeyspaceTestUtils.assertKeyspaceExists("full2", session); KeyspaceTestUtils.assertKeyspaceExists("script1", session); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/JavaConfigAuditingTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/JavaConfigAuditingTests.java index c447be30c..d29b6b750 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/JavaConfigAuditingTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/JavaConfigAuditingTests.java @@ -17,14 +17,12 @@ package org.springframework.data.cassandra.config; import static org.mockito.Mockito.*; -import org.junit.runner.RunWith; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.datastax.oss.driver.api.core.CqlSession; @@ -33,14 +31,13 @@ import com.datastax.oss.driver.api.core.CqlSession; * * @author Mark Paluch */ -@RunWith(SpringRunner.class) -@ContextConfiguration -public class JavaConfigAuditingTests extends AbstractAuditingTests { +@SpringJUnitConfig +class JavaConfigAuditingTests extends AbstractAuditingTests { @Autowired ApplicationContext context; @Override - protected ApplicationContext getApplicationContext() { + public ApplicationContext getApplicationContext() { return context; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceActionSpecificationFactoryBeanUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceActionSpecificationFactoryBeanUnitTests.java index b2c80d52e..e7b2428be 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceActionSpecificationFactoryBeanUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceActionSpecificationFactoryBeanUnitTests.java @@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.cql.keyspace.AlterKeyspaceSpecification; import org.springframework.data.cassandra.core.cql.keyspace.CreateKeyspaceSpecification; @@ -35,12 +35,12 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class KeyspaceActionSpecificationFactoryBeanUnitTests { +class KeyspaceActionSpecificationFactoryBeanUnitTests { - KeyspaceActionSpecificationFactoryBean bean = new KeyspaceActionSpecificationFactoryBean(); + private KeyspaceActionSpecificationFactoryBean bean = new KeyspaceActionSpecificationFactoryBean(); @Test // DATACASS-502 - public void shouldCreateKeyspace() { + void shouldCreateKeyspace() { bean.setAction(KeyspaceAction.CREATE); bean.setName("my_keyspace"); @@ -60,7 +60,7 @@ public class KeyspaceActionSpecificationFactoryBeanUnitTests { } @Test // DATACASS-502 - public void shouldCreateAndDropKeyspace() { + void shouldCreateAndDropKeyspace() { bean.setAction(KeyspaceAction.CREATE_DROP); bean.setName("my_keyspace"); @@ -78,7 +78,7 @@ public class KeyspaceActionSpecificationFactoryBeanUnitTests { } @Test // DATACASS-502 - public void shouldAlterKeyspace() { + void shouldAlterKeyspace() { bean.setAction(KeyspaceAction.ALTER); bean.setDurableWrites(true); @@ -100,7 +100,7 @@ public class KeyspaceActionSpecificationFactoryBeanUnitTests { } @Test // DATACASS-502 - public void shouldAlterKeyspaceWithSimpleReplication() { + void shouldAlterKeyspaceWithSimpleReplication() { bean.setAction(KeyspaceAction.ALTER); bean.setDurableWrites(true); @@ -120,7 +120,7 @@ public class KeyspaceActionSpecificationFactoryBeanUnitTests { } @Test // DATACASS-502 - public void shouldAlterKeyspaceWithoutReplication() { + void shouldAlterKeyspaceWithoutReplication() { bean.setAction(KeyspaceAction.ALTER); bean.setDurableWrites(true); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceCreatingJavaConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceCreatingJavaConfigIntegrationTests.java index 494969615..456bda85b 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceCreatingJavaConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/KeyspaceCreatingJavaConfigIntegrationTests.java @@ -20,8 +20,7 @@ import static org.assertj.core.api.Assertions.*; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; @@ -30,9 +29,8 @@ import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceAttributes; import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceOption; import org.springframework.data.cassandra.support.AbstractTestJavaConfig; import org.springframework.data.cassandra.support.KeyspaceTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.datastax.oss.driver.api.core.CqlSession; @@ -40,14 +38,13 @@ import com.datastax.oss.driver.api.core.CqlSession; * @author Matthew T. Adams * @author Mark Paluch */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = KeyspaceCreatingJavaConfigIntegrationTests.KeyspaceCreatingJavaConfig.class) -public class KeyspaceCreatingJavaConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +@SpringJUnitConfig(classes = KeyspaceCreatingJavaConfigIntegrationTests.KeyspaceCreatingJavaConfig.class) +class KeyspaceCreatingJavaConfigIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { @Autowired CqlSession session; @Test - public void test() { + void test() { assertThat(session).isNotNull(); KeyspaceTestUtils.assertKeyspaceExists(KeyspaceCreatingJavaConfig.KEYSPACE_NAME, session); @@ -62,7 +59,7 @@ public class KeyspaceCreatingJavaConfigIntegrationTests extends AbstractKeyspace @Configuration static class KeyspaceCreatingJavaConfig extends AbstractTestJavaConfig { - public static final String KEYSPACE_NAME = "foo"; + private static final String KEYSPACE_NAME = "foo"; @Override protected String getKeyspaceName() { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java index a21f8e8af..23bccf5f6 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalKeyspaceCreatingXmlConfigIntegrationTests.java @@ -15,28 +15,25 @@ */ package org.springframework.data.cassandra.config; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.support.KeyspaceTestUtils; -import org.springframework.data.cassandra.test.util.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.data.cassandra.test.util.IntegrationTestsSupport; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.datastax.oss.driver.api.core.CqlSession; /** * @author Matthew T. Adams */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -public class MinimalKeyspaceCreatingXmlConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest { +@SpringJUnitConfig +class MinimalKeyspaceCreatingXmlConfigIntegrationTests extends IntegrationTestsSupport { @Autowired CqlSession session; @Test - public void test() { + void test() { KeyspaceTestUtils.assertKeyspaceExists("minimal", session); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalXmlConfigIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalXmlConfigIntegrationTests.java index 1dcf17994..1537e5ae5 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalXmlConfigIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/MinimalXmlConfigIntegrationTests.java @@ -18,16 +18,15 @@ package org.springframework.data.cassandra.config; import static org.assertj.core.api.Assertions.*; import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.support.KeyspaceTestUtils; -import org.springframework.data.cassandra.test.util.AbstractEmbeddedCassandraIntegrationTest; -import org.springframework.data.cassandra.test.util.KeyspaceRule; +import org.springframework.data.cassandra.test.util.IntegrationTestsSupport; +import org.springframework.data.cassandra.test.util.TestKeyspaceName; import com.datastax.oss.driver.api.core.CqlSession; @@ -36,29 +35,28 @@ import com.datastax.oss.driver.api.core.CqlSession; * @author Oliver Gierke * @author Mark Paluch */ -public class MinimalXmlConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest { +@TestKeyspaceName(MinimalXmlConfigIntegrationTests.KEYSPACE) +class MinimalXmlConfigIntegrationTests extends IntegrationTestsSupport { - public static final String KEYSPACE = "minimalxmlconfigtest"; + static final String KEYSPACE = "minimalxmlconfigtest"; private CqlSession session; private ConfigurableApplicationContext context; - @Rule public final KeyspaceRule keyspaceRule = new KeyspaceRule(cassandraEnvironment, KEYSPACE); - - @Before - public void setUp() { + @BeforeEach + void setUp() { this.context = new ClassPathXmlApplicationContext("MinimalXmlConfigIntegrationTests-context.xml", getClass()); this.session = context.getBean(CqlSession.class); } @After - public void tearDown() { + void tearDown() { context.close(); } @Test - public void test() { + void test() { KeyspaceTestUtils.assertKeyspaceExists(KEYSPACE, session); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/NamespaceAuditingTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/NamespaceAuditingTests.java index b6d84a5ac..86d985e8f 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/NamespaceAuditingTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/NamespaceAuditingTests.java @@ -15,33 +15,26 @@ */ package org.springframework.data.cassandra.config; -import org.junit.ClassRule; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.data.cassandra.test.util.CassandraRule; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.data.cassandra.test.util.CassandraExtension; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Unit tests for auditing enabled using XML config. * * @author Mark Paluch */ -@RunWith(SpringRunner.class) -@ContextConfiguration -public class NamespaceAuditingTests extends AbstractAuditingTests { - - /** - * Initiate a Cassandra environment in this test scope. - */ - @ClassRule public static final CassandraRule cassandraEnvironment = new CassandraRule("embedded-cassandra.yaml"); +@SpringJUnitConfig +@ExtendWith(CassandraExtension.class) +class NamespaceAuditingTests extends AbstractAuditingTests { @Autowired ApplicationContext context; @Override - protected ApplicationContext getApplicationContext() { + public ApplicationContext getApplicationContext() { return context; } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ParsingUtilsUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ParsingUtilsUnitTests.java index 054589a0a..30db3145c 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ParsingUtilsUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ParsingUtilsUnitTests.java @@ -19,7 +19,7 @@ package org.springframework.data.cassandra.config; import static org.assertj.core.api.Assertions.*; import static org.springframework.data.cassandra.support.BeanDefinitionTestUtils.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -30,10 +30,10 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; * * @author John Blum */ -public class ParsingUtilsUnitTests { +class ParsingUtilsUnitTests { @Test // DATACASS-298 - public void addOptionalReferencePropertyUsesDefault() { + void addOptionalReferencePropertyUsesDefault() { BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty", null, "defaultBeanReference", false, true); @@ -45,7 +45,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addOptionalReferencePropertyWithNoValueDoesReturnsWithoutAdding() { + void addOptionalReferencePropertyWithNoValueDoesReturnsWithoutAdding() { BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty", null, null, false, false); @@ -57,7 +57,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addOptionalValuePropertyUsesDefault() { + void addOptionalValuePropertyUsesDefault() { BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", null, "defaultValue", false, false); @@ -68,7 +68,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addOptionalValuePropertyWithNoValueDoesReturnsWithoutAdding() { + void addOptionalValuePropertyWithNoValueDoesReturnsWithoutAdding() { BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", null, null, false, false); @@ -80,7 +80,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addRequiredReferencePropertyIsSuccessful() { + void addRequiredReferencePropertyIsSuccessful() { BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty", "reference", null, true, true); @@ -92,7 +92,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addRequiredReferencePropertyWithNoReferenceFails() { + void addRequiredReferencePropertyWithNoReferenceFails() { assertThatIllegalArgumentException() .isThrownBy(() -> ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty", @@ -101,7 +101,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addRequiredValuePropertyIsSuccessful() { + void addRequiredValuePropertyIsSuccessful() { BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", "value", null, true, false); @@ -112,7 +112,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addRequiredValuePropertyWithNoValueFails() { + void addRequiredValuePropertyWithNoValueFails() { assertThatIllegalArgumentException() .isThrownBy(() -> ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", null, @@ -121,7 +121,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addPropertyThrowsIllegalArgumentExceptionForNullBuilder() { + void addPropertyThrowsIllegalArgumentExceptionForNullBuilder() { assertThatIllegalArgumentException() .isThrownBy(() -> ParsingUtils.addProperty(null, "propertyName", "value", "defaultValue", false, false)) @@ -129,7 +129,7 @@ public class ParsingUtilsUnitTests { } @Test // DATACASS-298 - public void addPropertyThrowsIllegalArgumentExceptionForNullPropertyName() { + void addPropertyThrowsIllegalArgumentExceptionForNullPropertyName() { assertThatIllegalArgumentException().isThrownBy(() -> ParsingUtils .addProperty(BeanDefinitionBuilder.genericBeanDefinition(), null, "value", "defaultValue", false, true)) diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveAuditingTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveAuditingTests.java index e40db522e..354cebc13 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveAuditingTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveAuditingTests.java @@ -22,8 +22,7 @@ import reactor.test.StepVerifier; import java.time.LocalDateTime; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -41,7 +40,6 @@ import org.springframework.data.cassandra.core.mapping.event.ReactiveBeforeConve import org.springframework.data.domain.ReactiveAuditorAware; import org.springframework.data.mapping.callback.ReactiveEntityCallbacks; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -50,9 +48,8 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -@RunWith(SpringRunner.class) @ContextConfiguration -public class ReactiveAuditingTests { +class ReactiveAuditingTests { @Autowired ApplicationContext context; @@ -77,7 +74,7 @@ public class ReactiveAuditingTests { } @Test // DATACASS-784 - public void enablesAuditingAndSetsPropertiesAccordingly() { + void enablesAuditingAndSetsPropertiesAccordingly() { CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class); mappingContext.getPersistentEntity(Entity.class); @@ -94,12 +91,13 @@ public class ReactiveAuditingTests { } @Table + private class Entity { @Id Long id; - @CreatedDate LocalDateTime created; - @CreatedBy String createdBy; - LocalDateTime modified; + @CreatedDate private LocalDateTime created; + @CreatedBy private String createdBy; + private LocalDateTime modified; @LastModifiedDate public LocalDateTime getModified() { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveCassandraConfigurationIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveCassandraConfigurationIntegrationTests.java index ab12fd008..03d7893e9 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveCassandraConfigurationIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/ReactiveCassandraConfigurationIntegrationTests.java @@ -17,44 +17,41 @@ package org.springframework.data.cassandra.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.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest; import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * Integration tests for {@link AbstractReactiveCassandraConfiguration}. * * @author Mark Paluch */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = IntegrationTestConfig.class) -public class ReactiveCassandraConfigurationIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { +@SpringJUnitConfig(classes = IntegrationTestConfig.class) +class ReactiveCassandraConfigurationIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest { @Autowired BeanFactory beanFactory; @Test // DATACASS-713 - public void shouldContainCassandraSessionBean() { + void shouldContainCassandraSessionBean() { assertThat(beanFactory.containsBean(DefaultCqlBeanNames.SESSION)).isTrue(); } @Test // DATACASS-713 - public void shouldContainCassandraSessionFactoryBean() { + void shouldContainCassandraSessionFactoryBean() { assertThat(beanFactory.containsBean(DefaultCqlBeanNames.SESSION_FACTORY)).isTrue(); } @Test // DATACASS-713 - public void shouldContainReactiveCassandraSessionBean() { + void shouldContainReactiveCassandraSessionBean() { assertThat(beanFactory.containsBean("reactiveCassandraSession")).isTrue(); } @Test // DATACASS-713 - public void shouldContainReactiveCassandraSessionFactoryBean() { + void shouldContainReactiveCassandraSessionFactoryBean() { assertThat(beanFactory.containsBean("reactiveCassandraSessionFactory")).isTrue(); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java index 316c51781..e59061043 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java @@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.*; import java.util.Collections; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.ConfigurableApplicationContext; @@ -33,7 +33,8 @@ import org.springframework.data.cassandra.core.cql.session.init.KeyspacePopulato import org.springframework.data.cassandra.core.cql.session.init.ResourceKeyspacePopulator; import org.springframework.data.cassandra.domain.Person; import org.springframework.data.cassandra.repository.support.IntegrationTestConfig; -import org.springframework.data.cassandra.test.util.AbstractEmbeddedCassandraIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; +import org.springframework.data.cassandra.test.util.IntegrationTestsSupport; import org.springframework.lang.Nullable; import com.datastax.oss.driver.api.core.CqlSession; @@ -46,13 +47,13 @@ import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata; * * @author John Blum * @author Mark Paluch - * @see org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest + * @see AbstractKeyspaceCreatingIntegrationTests */ -public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest { +class SchemaActionIntegrationTests extends IntegrationTestsSupport { - protected static final String CREATE_PERSON_TABLE_CQL = "CREATE TABLE IF NOT EXISTS person (id int, firstName text, lastName text, PRIMARY KEY(id));"; + private static final String CREATE_PERSON_TABLE_CQL = "CREATE TABLE IF NOT EXISTS person (id int, firstName text, lastName text, PRIMARY KEY(id));"; - protected ConfigurableApplicationContext newApplicationContext(Class... annotatedClasses) { + ConfigurableApplicationContext newApplicationContext(Class... annotatedClasses) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(annotatedClasses); @@ -89,7 +90,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg } @Test - public void createWithNoExistingTableCreatesTableFromEntity() { + void createWithNoExistingTableCreatesTableFromEntity() { doInSessionWithConfiguration(CreateWithNoExistingTableConfiguration.class, session -> { @@ -101,7 +102,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg } @Test - public void createWithExistingTableThrowsErrorWhenCreatingTableFromEntity() { + void createWithExistingTableThrowsErrorWhenCreatingTableFromEntity() { try { @@ -119,7 +120,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg } @Test - public void createIfNotExistsWithNoExistingTableCreatesTableFromEntity() { + void createIfNotExistsWithNoExistingTableCreatesTableFromEntity() { doInSessionWithConfiguration(CreateIfNotExistsWithNoExistingTableConfiguration.class, session -> { @@ -131,7 +132,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg } @Test - public void createIfNotExistsWithExistingTableUsesExistingTable() { + void createIfNotExistsWithExistingTableUsesExistingTable() { doInSessionWithConfiguration(CreateIfNotExistsWithExistingTableConfiguration.class, session -> { @@ -142,7 +143,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg } @Test - public void recreateTableFromEntityDropsExistingTable() { + void recreateTableFromEntityDropsExistingTable() { doInSessionWithConfiguration(RecreateSchemaActionWithExistingTableConfiguration.class, session -> { diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java index 6e748feb8..8370548a9 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateIntegrationTests.java @@ -23,8 +23,8 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.concurrent.Future; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.cql.AsyncCqlTemplate; @@ -35,7 +35,7 @@ import org.springframework.data.cassandra.core.query.Update; import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; import org.springframework.util.concurrent.ListenableFuture; @@ -47,12 +47,12 @@ import com.datastax.oss.driver.api.core.uuid.Uuids; * * @author Mark Paluch */ -public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { private AsyncCassandraTemplate template; - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); CassandraTemplate cassandraTemplate = new CassandraTemplate(session, converter); @@ -65,7 +65,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-343 - public void shouldSelectByQueryWithSorting() { + void shouldSelectByQueryWithSorting() { UserToken token1 = new UserToken(); token1.setUserId(Uuids.endOf(System.currentTimeMillis())); @@ -86,7 +86,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-343 - public void shouldSelectOneByQuery() { + void shouldSelectOneByQuery() { UserToken token1 = new UserToken(); token1.setUserId(Uuids.endOf(System.currentTimeMillis())); @@ -101,7 +101,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void insertShouldInsertEntity() { + void insertShouldInsertEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -114,7 +114,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-250 - public void insertShouldCreateEntityWithLwt() { + void insertShouldCreateEntityWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -126,7 +126,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-250 - public void insertShouldNotUpdateEntityWithLwt() { + void insertShouldNotUpdateEntityWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -143,7 +143,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void shouldInsertAndCountEntities() { + void shouldInsertAndCountEntities() { User user = new User("heisenberg", "Walter", "White"); @@ -155,7 +155,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-512 - public void shouldInsertEntityAndCountByQuery() { + void shouldInsertEntityAndCountByQuery() { User user = new User("heisenberg", "Walter", "White"); @@ -166,7 +166,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-512 - public void shouldInsertEntityAndExistsByQuery() { + void shouldInsertEntityAndExistsByQuery() { User user = new User("heisenberg", "Walter", "White"); @@ -177,7 +177,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void updateShouldUpdateEntity() { + void updateShouldUpdateEntity() { User user = new User("heisenberg", "Walter", "White"); getUninterruptibly(template.insert(user)); @@ -191,7 +191,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void updateShouldNotCreateEntityWithLwt() { + void updateShouldNotCreateEntityWithLwt() { UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build(); @@ -204,7 +204,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void updateShouldUpdateEntityWithLwt() throws InterruptedException { + void updateShouldUpdateEntityWithLwt() throws InterruptedException { UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build(); @@ -220,7 +220,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-343 - public void updateShouldUpdateEntityByQuery() { + void updateShouldUpdateEntityByQuery() { User user = new User("heisenberg", "Walter", "White"); getUninterruptibly(template.insert(user)); @@ -234,7 +234,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-343 - public void deleteByQueryShouldRemoveEntity() { + void deleteByQueryShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); getUninterruptibly(template.insert(user)); @@ -246,7 +246,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-343 - public void deleteColumnsByQueryShouldRemoveColumn() { + void deleteColumnsByQueryShouldRemoveColumn() { User user = new User("heisenberg", "Walter", "White"); getUninterruptibly(template.insert(user)); @@ -261,7 +261,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void deleteShouldRemoveEntity() { + void deleteShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); getUninterruptibly(template.insert(user)); @@ -273,7 +273,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-292 - public void deleteByIdShouldRemoveEntity() { + void deleteByIdShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); getUninterruptibly(template.insert(user)); @@ -285,7 +285,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-606 - public void deleteShouldRemoveEntityWithLwt() { + void deleteShouldRemoveEntityWithLwt() { DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build(); @@ -296,7 +296,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-606 - public void deleteByQueryShouldRemoveEntityWithLwt() { + void deleteByQueryShouldRemoveEntityWithLwt() { DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build(); @@ -309,7 +309,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-56 - public void shouldPageRequests() { + void shouldPageRequests() { Set expectedIds = new LinkedHashSet<>(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java index 5a1c5f2f7..af35db38a 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncCassandraTemplateUnitTests.java @@ -27,13 +27,15 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -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.ArgumentCaptor; import org.mockito.Captor; 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.cassandra.CassandraConnectionFailureException; import org.springframework.data.cassandra.core.mapping.event.BeforeConvertCallback; @@ -62,7 +64,8 @@ import com.datastax.oss.driver.api.core.type.DataTypes; * * @author Mark Paluch */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class AsyncCassandraTemplateUnitTests { @Mock CqlSession session; @@ -73,14 +76,14 @@ public class AsyncCassandraTemplateUnitTests { @Captor ArgumentCaptor statementCaptor; - AsyncCassandraTemplate template; + private AsyncCassandraTemplate template; - Object beforeSave; + private Object beforeSave; - Object beforeConvert; + private Object beforeConvert; - @Before - public void setUp() { + @BeforeEach + void setUp() { template = new AsyncCassandraTemplate(session); @@ -107,7 +110,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectUsingCqlShouldReturnMappedResults() { + void selectUsingCqlShouldReturnMappedResults() { when(resultSet.currentPage()).thenReturn(Collections.singleton(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -131,7 +134,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectUsingCqlShouldInvokeCallbackWithMappedResults() { + void selectUsingCqlShouldInvokeCallbackWithMappedResults() { when(resultSet.currentPage()).thenReturn(Collections.singletonList(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -157,7 +160,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectShouldTranslateException() throws Exception { + void selectShouldTranslateException() throws Exception { when(resultSet.currentPage()).thenThrow(new NoNodeAvailableException()); @@ -174,7 +177,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectOneShouldReturnMappedResults() { + void selectOneShouldReturnMappedResults() { when(resultSet.currentPage()).thenReturn(Collections.singleton(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -198,7 +201,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectOneByIdShouldReturnMappedResults() { + void selectOneByIdShouldReturnMappedResults() { when(resultSet.currentPage()).thenReturn(Collections.singleton(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -221,7 +224,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-696 - public void selectOneShouldNull() { + void selectOneShouldNull() { when(resultSet.currentPage()).thenReturn(Collections.singleton(row)); @@ -231,7 +234,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void existsShouldReturnExistingElement() { + void existsShouldReturnExistingElement() { when(resultSet.one()).thenReturn(row); @@ -243,7 +246,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void existsShouldReturnNonExistingElement() { + void existsShouldReturnNonExistingElement() { ListenableFuture future = template.exists("myid", User.class); @@ -253,7 +256,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-512 - public void existsByQueryShouldReturnExistingElement() { + void existsByQueryShouldReturnExistingElement() { when(resultSet.one()).thenReturn(row); @@ -265,7 +268,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void countShouldExecuteCountQueryElement() { + void countShouldExecuteCountQueryElement() { when(resultSet.currentPage()).thenReturn(Collections.singleton(row)); when(row.getLong(0)).thenReturn(42L); @@ -279,7 +282,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void countByQueryShouldExecuteCountQueryElement() { + void countByQueryShouldExecuteCountQueryElement() { when(resultSet.currentPage()).thenReturn(Collections.singleton(row)); when(row.getLong(0)).thenReturn(42L); @@ -293,7 +296,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292, DATACASS-618 - public void insertShouldInsertEntity() { + void insertShouldInsertEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -310,7 +313,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-618 - public void insertShouldInsertVersionedEntity() { + void insertShouldInsertVersionedEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -327,7 +330,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void insertShouldTranslateException() throws Exception { + void insertShouldTranslateException() throws Exception { reset(session); when(session.executeAsync(any(Statement.class))) @@ -346,7 +349,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292, DATACASS-618 - public void updateShouldUpdateEntity() { + void updateShouldUpdateEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -363,7 +366,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-618 - public void updateShouldUpdateVersionedEntity() { + void updateShouldUpdateVersionedEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -381,7 +384,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldUpdateEntityWithOptions() { + void updateShouldUpdateEntityWithOptions() { UpdateOptions updateOptions = UpdateOptions.builder().withIfExists().build(); User user = new User("heisenberg", "Walter", "White"); @@ -394,7 +397,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldUpdateEntityWithLwt() { + void updateShouldUpdateEntityWithLwt() { UpdateOptions options = UpdateOptions.builder().ifCondition(where("firstname").is("Walter")).build(); User user = new User("heisenberg", "Walter", "White"); @@ -407,7 +410,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldApplyUpdateQuery() { + void updateShouldApplyUpdateQuery() { Query query = Query.query(where("id").is("heisenberg")); Update update = Update.update("firstname", "Walter"); @@ -420,7 +423,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldApplyUpdateQueryWitLwt() { + void updateShouldApplyUpdateQueryWitLwt() { Filter ifCondition = Filter.from(where("firstname").is("Walter"), where("lastname").is("White")); @@ -437,7 +440,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void updateShouldTranslateException() throws Exception { + void updateShouldTranslateException() throws Exception { reset(session); when(session.executeAsync(any(Statement.class))) @@ -456,7 +459,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void deleteByIdShouldRemoveEntity() { + void deleteByIdShouldRemoveEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -470,7 +473,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void deleteShouldRemoveEntity() { + void deleteShouldRemoveEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -484,7 +487,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void deleteShouldRemoveEntityWithLwt() { + void deleteShouldRemoveEntityWithLwt() { User user = new User("heisenberg", "Walter", "White"); DeleteOptions options = DeleteOptions.builder().ifCondition(where("firstname").is("Walter")).build(); @@ -497,7 +500,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void deleteShouldRemoveByQueryWithLwt() { + void deleteShouldRemoveByQueryWithLwt() { DeleteOptions options = DeleteOptions.builder().ifCondition(where("firstname").is("Walter")).build(); Query query = Query.query(where("id").is("heisenberg")).queryOptions(options); @@ -510,7 +513,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void deleteShouldTranslateException() throws Exception { + void deleteShouldTranslateException() throws Exception { reset(session); when(session.executeAsync(any(Statement.class))) @@ -529,7 +532,7 @@ public class AsyncCassandraTemplateUnitTests { } @Test // DATACASS-292 - public void truncateShouldRemoveEntities() { + void truncateShouldRemoveEntities() { template.truncate(User.class); @@ -548,9 +551,9 @@ public class AsyncCassandraTemplateUnitTests { private static class TestResultSetFuture extends CompletableFuture { - public TestResultSetFuture() {} + private TestResultSetFuture() {} - public TestResultSetFuture(AsyncResultSet resultSet) { + private TestResultSetFuture(AsyncResultSet resultSet) { complete(resultSet); } @@ -560,7 +563,7 @@ public class AsyncCassandraTemplateUnitTests { * @param throwable must not be {@literal null}. * @return the completed/failed {@link TestResultSetFuture}. */ - public static TestResultSetFuture failed(Throwable throwable) { + private static TestResultSetFuture failed(Throwable throwable) { TestResultSetFuture future = new TestResultSetFuture(); future.completeExceptionally(throwable); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java index 5159a5ef7..29f125384 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/AsyncOptimisticLockingIntegrationTests.java @@ -15,16 +15,15 @@ */ package org.springframework.data.cassandra.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.util.concurrent.Future; +import static org.assertj.core.api.Assertions.*; import lombok.Data; import lombok.experimental.Wither; -import org.junit.Before; -import org.junit.Test; +import java.util.concurrent.Future; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.data.annotation.Id; @@ -34,19 +33,19 @@ import org.springframework.data.cassandra.core.convert.MappingCassandraConverter import org.springframework.data.cassandra.core.cql.CqlTemplate; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for optimistic locking through {@link AsyncCassandraTemplate}. * * @author Mark Paluch */ -public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - AsyncCassandraTemplate template; + private AsyncCassandraTemplate template; - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); @@ -61,7 +60,7 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-576 - public void shouldInsertVersioned() { + void shouldInsertVersioned() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -74,7 +73,7 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-576 - public void duplicateInsertShouldFail() { + void duplicateInsertShouldFail() { getUninterruptibly(template.insert(new VersionedEntity(42))); @@ -83,7 +82,7 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-576 - public void shouldUpdateVersioned() { + void shouldUpdateVersioned() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -98,7 +97,7 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-576 - public void updateForOutdatedEntityShouldFail() { + void updateForOutdatedEntityShouldFail() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -108,7 +107,7 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-576 - public void shouldDeleteVersionedEntity() { + void shouldDeleteVersionedEntity() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -122,7 +121,7 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-576 - public void deleteForOutdatedEntityShouldFail() { + void deleteForOutdatedEntityShouldFail() { getUninterruptibly(template.insert(new VersionedEntity(42))); @@ -153,12 +152,12 @@ public class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCrea final String name; - public VersionedEntity(long id) { + private VersionedEntity(long id) { this(id, 0, null); } @PersistenceConstructor - public VersionedEntity(long id, long version, String name) { + private VersionedEntity(long id, long version, String name) { this.id = id; this.version = version; this.name = name; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java index 4dd4767dc..9fece4949 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraAdminTemplateIntegrationTests.java @@ -19,14 +19,14 @@ import static org.assertj.core.api.Assertions.*; import java.util.Collection; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.cql.generator.DropTableCqlGenerator; import org.springframework.data.cassandra.core.cql.keyspace.DropTableSpecification; import org.springframework.data.cassandra.domain.User; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.metadata.Metadata; @@ -38,12 +38,12 @@ import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata; * * @author Mark Paluch */ -public class CassandraAdminTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class CassandraAdminTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { private CassandraAdminTemplate cassandraAdminTemplate; - @Before - public void before() { + @BeforeEach + void before() { cassandraAdminTemplate = new CassandraAdminTemplate(session, new MappingCassandraConverter()); @@ -61,7 +61,7 @@ public class CassandraAdminTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-173 - public void testCreateTables() { + void testCreateTables() { assertThat(getKeyspaceMetadata().getTables()).hasSize(0); @@ -73,7 +73,7 @@ public class CassandraAdminTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test - public void testDropTable() { + void testDropTable() { cassandraAdminTemplate.createTable(true, CqlIdentifier.fromCql("users"), User.class, null); assertThat(getKeyspaceMetadata().getTables()).hasSize(1); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java index 03e2be365..7b5ee4ded 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraBatchTemplateIntegrationTests.java @@ -15,22 +15,21 @@ */ package org.springframework.data.cassandra.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.*; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.cql.WriteOptions; import org.springframework.data.cassandra.domain.FlatGroup; import org.springframework.data.cassandra.domain.Group; import org.springframework.data.cassandra.domain.GroupKey; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.cql.ResultSet; import com.datastax.oss.driver.api.core.cql.Row; @@ -41,15 +40,15 @@ import com.datastax.oss.driver.api.core.cql.Row; * @author Mark Paluch * @author Anup Sabbi */ -public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraTemplate template; + private CassandraTemplate template; - Group walter = new Group(new GroupKey("users", "0x1", "walter")); - Group mike = new Group(new GroupKey("users", "0x1", "mike")); + private Group walter = new Group(new GroupKey("users", "0x1", "walter")); + private Group mike = new Group(new GroupKey("users", "0x1", "mike")); - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { template = new CassandraTemplate(session); @@ -64,7 +63,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldInsertEntities() { + void shouldInsertEntities() { CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template); batchOperations.insert(walter).insert(mike).execute(); @@ -75,7 +74,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldInsertEntitiesWithLwt() { + void shouldInsertEntitiesWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -101,7 +100,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldInsertCollectionOfEntities() { + void shouldInsertCollectionOfEntities() { CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template); batchOperations.insert(Arrays.asList(walter, mike)).execute(); @@ -112,7 +111,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-443 - public void shouldInsertCollectionOfEntitiesWithTtl() { + void shouldInsertCollectionOfEntitiesWithTtl() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -133,7 +132,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldUpdateEntities() { + void shouldUpdateEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -147,7 +146,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldUpdateCollectionOfEntities() { + void shouldUpdateCollectionOfEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -161,7 +160,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-443 - public void shouldUpdateCollectionOfEntitiesWithTtl() { + void shouldUpdateCollectionOfEntitiesWithTtl() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -182,7 +181,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldUpdatesCollectionOfEntities() { + void shouldUpdatesCollectionOfEntities() { FlatGroup walter = new FlatGroup("users", "0x1", "walter"); FlatGroup mike = new FlatGroup("users", "0x1", "mike"); @@ -202,7 +201,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldDeleteEntities() { + void shouldDeleteEntities() { CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template); @@ -214,7 +213,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldDeleteCollectionOfEntities() { + void shouldDeleteCollectionOfEntities() { CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template); @@ -226,7 +225,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } @Test // DATACASS-288 - public void shouldApplyTimestampToAllEntities() { + void shouldApplyTimestampToAllEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -245,25 +244,21 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea } } - @Test(expected = IllegalStateException.class) // DATACASS-288 - public void shouldNotExecuteTwice() { + @Test // DATACASS-288 + void shouldNotExecuteTwice() { CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template); batchOperations.insert(walter).execute(); - batchOperations.execute(); - - fail("Missing IllegalStateException"); + assertThatIllegalStateException().isThrownBy(() -> batchOperations.execute()); } - @Test(expected = IllegalStateException.class) // DATACASS-288 - public void shouldNotAllowModificationAfterExecution() { + @Test // DATACASS-288 + void shouldNotAllowModificationAfterExecution() { CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template); batchOperations.insert(walter).execute(); - batchOperations.update(new Group()); - - fail("Missing IllegalStateException"); + assertThatIllegalStateException().isThrownBy(() -> batchOperations.update(new Group())); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java index d4a712a1e..8bc1fb836 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java @@ -26,12 +26,14 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -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.ArgumentCaptor; 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.cassandra.core.convert.SchemaFactory; import org.springframework.data.cassandra.core.cql.CqlOperations; @@ -51,22 +53,17 @@ import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry; * @author Mark Paluch * @author Jens Schauder */ -@RunWith(MockitoJUnitRunner.class) -public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPersistentEntitySchemaTestSupport { +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPersistentEntitySchemaTestSupport { @Mock CassandraAdminOperations adminOperations; @Mock CqlOperations operations; - CassandraMappingContext context = new CassandraMappingContext(); + private CassandraMappingContext context = new CassandraMappingContext(); - @Before - public void setUp() { - - context.setUserTypeResolver(typeName -> { - // make sure that calls to this method pop up. Calling UserTypeResolver while resolving - // to be created user types isn't a good idea because they do not exist at resolution time. - throw new IllegalArgumentException(String.format("Type %s not found", typeName)); - }); + @BeforeEach + void setUp() { when(adminOperations.getCqlOperations()).thenReturn(operations); when(adminOperations.getSchemaFactory()).thenReturn(new SchemaFactory(context, @@ -75,7 +72,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @Test // DATACASS-687 - public void shouldConsiderProperUdtOrdering() { + void shouldConsiderProperUdtOrdering() { List> ordered = new ArrayList<>(Arrays.asList(Udt2.class, Udt1.class, RequiredByAll.class)); @@ -104,7 +101,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @Test // DATACASS-172, DATACASS-406 - public void createsCorrectTypeForSimpleTypes() { + void createsCorrectTypeForSimpleTypes() { context.getPersistentEntity(MoonType.class); context.getPersistentEntity(PlanetType.class); @@ -118,7 +115,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @Test // DATACASS-406 - public void createsCorrectTypeForSets() { + void createsCorrectTypeForSets() { List> ordered = new ArrayList<>(Arrays.asList(UniverseType.class, PlanetType.class, MoonType.class)); @@ -146,7 +143,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @Test // DATACASS-406 - public void createsCorrectTypeForLists() { + void createsCorrectTypeForLists() { context.getPersistentEntity(SpaceAgencyType.class); @@ -161,7 +158,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @Test // DATACASS-406 - public void createsCorrectTypesForNestedTypes() { + void createsCorrectTypesForNestedTypes() { context.getPersistentEntity(PlanetType.class); @@ -174,7 +171,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @Test // DATACASS-213 - public void createsIndexes() { + void createsIndexes() { context.getPersistentEntity(IndexedEntity.class); @@ -205,18 +202,18 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests extends CassandraPe } @UserDefinedType - static class RequiredByAll { + private static class RequiredByAll { private String name; } @UserDefinedType - static class Udt1 { + private static class Udt1 { private RequiredByAll attachment; } @UserDefinedType - static class Udt2 extends AbstractModel { + private static class Udt2 extends AbstractModel { private Udt1 u1; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaDropperUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaDropperUnitTests.java index d9feb80ca..bcf421518 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaDropperUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaDropperUnitTests.java @@ -23,13 +23,13 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; -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.springframework.data.cassandra.core.mapping.CassandraMappingContext; import org.springframework.data.cassandra.support.UserDefinedTypeBuilder; @@ -39,6 +39,8 @@ import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata; import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata; import com.datastax.oss.driver.api.core.type.DataTypes; import com.datastax.oss.driver.api.core.type.UserDefinedType; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; /** * Unit tests for {@link CassandraPersistentEntitySchemaDropper}. @@ -46,24 +48,27 @@ import com.datastax.oss.driver.api.core.type.UserDefinedType; * @author Mark Paluch. */ @SuppressWarnings("unchecked") -@RunWith(MockitoJUnitRunner.class) -public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPersistentEntitySchemaTestSupport { +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPersistentEntitySchemaTestSupport { @Mock CassandraAdminOperations operations; @Mock KeyspaceMetadata metadata; - UserDefinedType universetype = UserDefinedTypeBuilder.forName("universetype").withField("name", DataTypes.TEXT) + private UserDefinedType universetype = UserDefinedTypeBuilder.forName("universetype") + .withField("name", DataTypes.TEXT) .build(); - UserDefinedType moontype = UserDefinedTypeBuilder.forName("moontype").withField("universeType", universetype).build(); - UserDefinedType planettype = UserDefinedTypeBuilder.forName("planettype") + private UserDefinedType moontype = UserDefinedTypeBuilder.forName("moontype").withField("universeType", universetype) + .build(); + private UserDefinedType planettype = UserDefinedTypeBuilder.forName("planettype") .withField("moonType", DataTypes.setOf(moontype)).withField("universeType", universetype).build(); @Mock TableMetadata person; @Mock TableMetadata contact; - CassandraMappingContext context = new CassandraMappingContext(); + private CassandraMappingContext context = new CassandraMappingContext(); // DATACASS-355 - @Before - public void setUp() { + @BeforeEach + void setUp() { context.setUserTypeResolver(typeName -> metadata.getUserDefinedType(typeName).get()); @@ -73,7 +78,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe } @Test // DATACASS-355, DATACASS-546 - public void shouldDropTypesInOrderOfDependencies() { + void shouldDropTypesInOrderOfDependencies() { when(metadata.getUserDefinedTypes()).thenReturn(createTypes(universetype, moontype, planettype)); @@ -86,7 +91,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe } @Test // DATACASS-355 - public void dropUserTypesShouldRetainUnusedTypes() { + void dropUserTypesShouldRetainUnusedTypes() { context.setInitialEntitySet(new HashSet<>(Arrays.asList(MoonType.class, UniverseType.class))); context.afterPropertiesSet(); @@ -105,7 +110,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe } @Test // DATACASS-355 - public void shouldDropTables() { + void shouldDropTables() { context.setInitialEntitySet(Collections.singleton(Person.class)); context.afterPropertiesSet(); @@ -125,7 +130,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests extends CassandraPe } @Test - public void dropTablesShouldRetainUnusedTables() { + void dropTablesShouldRetainUnusedTables() { context.setInitialEntitySet(Collections.singleton(Person.class)); context.afterPropertiesSet(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaTestSupport.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaTestSupport.java index 04f1ff229..1404c428b 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaTestSupport.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaTestSupport.java @@ -28,7 +28,7 @@ import org.springframework.data.cassandra.core.mapping.UserDefinedType; * * @author Mark Paluch */ -public abstract class CassandraPersistentEntitySchemaTestSupport { +abstract class CassandraPersistentEntitySchemaTestSupport { @UserDefinedType static class UniverseType { @@ -48,7 +48,7 @@ public abstract class CassandraPersistentEntitySchemaTestSupport { } @UserDefinedType - static class AstronautType { + private static class AstronautType { String name; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java index 1b67c611a..670913eeb 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateIntegrationTests.java @@ -35,8 +35,8 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -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.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.cql.CqlTemplate; @@ -57,7 +57,7 @@ import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; import org.springframework.data.cassandra.support.CassandraVersion; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; import org.springframework.data.util.Version; @@ -71,16 +71,16 @@ import com.datastax.oss.driver.api.core.uuid.Uuids; * @author Mark Paluch * @author Christoph Strobl */ -public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - static final Version CASSANDRA_3 = Version.parse("3.0"); + private static final Version CASSANDRA_3 = Version.parse("3.0"); - Version cassandraVersion; + private Version cassandraVersion; - CassandraTemplate template; + private CassandraTemplate template; - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); converter.setUserTypeResolver(new SimpleUserTypeResolver(session, CqlIdentifier.fromCql(keyspace))); @@ -112,7 +112,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void shouldSelectByQueryWithAllowFiltering() { + void shouldSelectByQueryWithAllowFiltering() { assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(CASSANDRA_3)); @@ -132,7 +132,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void shouldSelectByQueryWithSorting() { + void shouldSelectByQueryWithSorting() { UserToken token1 = new UserToken(); token1.setUserId(Uuids.endOf(System.currentTimeMillis())); @@ -154,7 +154,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-638 - public void shouldSelectProjection() { + void shouldSelectProjection() { User user = new User("heisenberg", "Walter", "White"); @@ -172,7 +172,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-638 - public void shouldSelectProjectionWithCompositeKey() { + void shouldSelectProjectionWithCompositeKey() { CompositeKey key = new CompositeKey("Walter", "White"); TypeWithCompositeKey user = new TypeWithCompositeKey(key, "comment"); @@ -193,7 +193,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void shouldSelectOneByQuery() { + void shouldSelectOneByQuery() { UserToken token1 = new UserToken(); token1.setUserId(Uuids.endOf(System.currentTimeMillis())); @@ -209,7 +209,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292, DATACASS-573 - public void insertShouldInsertEntity() { + void insertShouldInsertEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -222,7 +222,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-250, DATACASS-573 - public void insertShouldCreateEntityWithLwt() { + void insertShouldCreateEntityWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -235,7 +235,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-250, DATACASS-573 - public void insertShouldNotUpdateEntityWithLwt() { + void insertShouldNotUpdateEntityWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -252,7 +252,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292 - public void shouldInsertAndCountEntities() { + void shouldInsertAndCountEntities() { User user = new User("heisenberg", "Walter", "White"); @@ -263,7 +263,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-155 - public void shouldNotOverrideLaterMutation() { + void shouldNotOverrideLaterMutation() { Instant now = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant(); User user = new User("heisenberg", "Walter", "White"); @@ -282,7 +282,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-512 - public void shouldInsertEntityAndCountByQuery() { + void shouldInsertEntityAndCountByQuery() { User user = new User("heisenberg", "Walter", "White"); @@ -293,7 +293,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-512 - public void shouldInsertEntityAndExistsByQuery() { + void shouldInsertEntityAndExistsByQuery() { User user = new User("heisenberg", "Walter", "White"); @@ -304,7 +304,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292, DATACASS-573 - public void updateShouldUpdateEntity() { + void updateShouldUpdateEntity() { User user = new User("heisenberg", "Walter", "White"); template.insert(user); @@ -318,7 +318,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292 - public void updateShouldNotCreateEntityWithLwt() { + void updateShouldNotCreateEntityWithLwt() { UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build(); @@ -331,7 +331,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292 - public void updateShouldUpdateEntityWithLwt() { + void updateShouldUpdateEntityWithLwt() { UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build(); @@ -347,7 +347,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void updateShouldUpdateEntityByQuery() { + void updateShouldUpdateEntityByQuery() { User person = new User("heisenberg", "Walter", "White"); template.insert(person); @@ -360,7 +360,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void deleteByQueryShouldRemoveEntity() { + void deleteByQueryShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); template.insert(user); @@ -372,7 +372,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void deleteColumnsByQueryShouldRemoveColumn() { + void deleteColumnsByQueryShouldRemoveColumn() { User user = new User("heisenberg", "Walter", "White"); template.insert(user); @@ -387,7 +387,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292 - public void deleteShouldRemoveEntity() { + void deleteShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); template.insert(user); @@ -398,7 +398,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-292 - public void deleteByIdShouldRemoveEntity() { + void deleteByIdShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); template.insert(user); @@ -410,7 +410,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-606 - public void deleteShouldRemoveEntityWithLwt() { + void deleteShouldRemoveEntityWithLwt() { DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build(); @@ -421,7 +421,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-606 - public void deleteByQueryShouldRemoveEntityWithLwt() { + void deleteByQueryShouldRemoveEntityWithLwt() { DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build(); @@ -433,7 +433,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-182 - public void stream() { + void stream() { User user = new User("heisenberg", "Walter", "White"); template.insert(user); @@ -444,7 +444,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-343 - public void streamByQuery() { + void streamByQuery() { User person = new User("heisenberg", "Walter", "White"); template.insert(person); @@ -457,7 +457,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-182 - public void updateShouldRemoveFields() { + void updateShouldRemoveFields() { User user = new User("heisenberg", "Walter", "White"); @@ -473,7 +473,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-182, DATACASS-420 - public void insertShouldNotRemoveFields() { + void insertShouldNotRemoveFields() { User user = new User("heisenberg", "Walter", "White"); @@ -489,7 +489,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-182 - public void insertAndUpdateToEmptyCollection() { + void insertAndUpdateToEmptyCollection() { BookReference bookReference = new BookReference(); @@ -509,7 +509,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-206 - public void shouldUseSpecifiedColumnNamesForSingleEntityModifyingOperations() { + void shouldUseSpecifiedColumnNamesForSingleEntityModifyingOperations() { UserToken userToken = new UserToken(); userToken.setToken(Uuids.startOf(System.currentTimeMillis())); @@ -534,7 +534,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-56 - public void shouldPageRequests() { + void shouldPageRequests() { Set expectedIds = new LinkedHashSet<>(); @@ -572,7 +572,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadPrefixedEmbeddedCorrectly() { + void shouldSaveAndReadPrefixedEmbeddedCorrectly() { WithPrefixedNullableEmbeddedType entity = new WithPrefixedNullableEmbeddedType(); entity.id = "id-1"; @@ -588,7 +588,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadEmbeddedCorrectly() { + void shouldSaveAndReadEmbeddedCorrectly() { WithNullableEmbeddedType entity = new WithNullableEmbeddedType(); entity.id = "id-1"; @@ -604,7 +604,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadNullableEmbeddedCorrectly() { + void shouldSaveAndReadNullableEmbeddedCorrectly() { WithNullableEmbeddedType entity = new WithNullableEmbeddedType(); entity.id = "id-1"; @@ -619,7 +619,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadEmptyEmbeddedCorrectly() { + void shouldSaveAndReadEmptyEmbeddedCorrectly() { WithEmptyEmbeddedType entity = new WithEmptyEmbeddedType(); entity.id = "id-1"; @@ -633,7 +633,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadEmbeddedUDTCorrectly() { + void shouldSaveAndReadEmbeddedUDTCorrectly() { OuterWithNullableEmbeddedType entity = new OuterWithNullableEmbeddedType(); entity.id = "id-1"; @@ -651,7 +651,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadPrefixedUdtEmbeddedCorrectly() { + void shouldSaveAndReadPrefixedUdtEmbeddedCorrectly() { OuterWithPrefixedNullableEmbeddedType entity = new OuterWithPrefixedNullableEmbeddedType(); entity.id = "id-1"; @@ -669,7 +669,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-167 - public void shouldSaveAndReadNullEmbeddedUDTCorrectly() { + void shouldSaveAndReadNullEmbeddedUDTCorrectly() { OuterWithNullableEmbeddedType entity = new OuterWithNullableEmbeddedType(); entity.id = "id-1"; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdIntegrationTest.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdIntegrationTest.java index adfb20b42..dacbe1fdd 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdIntegrationTest.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdIntegrationTest.java @@ -18,27 +18,27 @@ package org.springframework.data.cassandra.core; import static org.assertj.core.api.Assertions.*; import static org.springframework.data.cassandra.core.mapping.BasicMapId.*; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.MapId; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for {@link org.springframework.data.cassandra.core.CassandraTemplate} with {@link MapId}. * * @author Matthew T. Adams */ -public class CassandraTemplateMapIdIntegrationTest extends AbstractKeyspaceCreatingIntegrationTest { +class CassandraTemplateMapIdIntegrationTest extends AbstractKeyspaceCreatingIntegrationTests { - CassandraOperations operations; + private CassandraOperations operations; - @Before - public void before() { + @BeforeEach + void before() { operations = new CassandraTemplate(session); @@ -50,7 +50,7 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractKeyspaceCreat } @Test - public void testSinglePkc() { + void testSinglePkc() { // insert SinglePkc inserted = new SinglePkc(uuid()); @@ -77,43 +77,43 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractKeyspaceCreat } @Table - public static class SinglePkc { + private static class SinglePkc { - @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key; + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String key; - @Column String value; + @Column private String value; - public SinglePkc(String key) { + private SinglePkc(String key) { setKey(key); } - public String getKey() { + private String getKey() { return key; } - public void setKey(String key) { + private void setKey(String key) { this.key = key; } - public String getValue() { + private String getValue() { return value; } - public void setValue(String value) { + private void setValue(String value) { this.value = value; } } @Table - public static class MultiPkc { + private static class MultiPkc { - @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key0; + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String key0; - @PrimaryKeyColumn(ordinal = 1) String key1; + @PrimaryKeyColumn(ordinal = 1) private String key1; - @Column String value; + @Column private String value; - public MultiPkc(String key0, String key1) { + private MultiPkc(String key0, String key1) { setKey0(key0); setKey1(key1); } @@ -122,7 +122,7 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractKeyspaceCreat return key0; } - public void setKey0(String key0) { + private void setKey0(String key0) { this.key0 = key0; } @@ -130,7 +130,7 @@ public class CassandraTemplateMapIdIntegrationTest extends AbstractKeyspaceCreat return key1; } - public void setKey1(String key1) { + private void setKey1(String key1) { this.key1 = key1; } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdProxyDelegateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdProxyDelegateIntegrationTests.java index f55407888..04c009f23 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdProxyDelegateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateMapIdProxyDelegateIntegrationTests.java @@ -18,15 +18,15 @@ package org.springframework.data.cassandra.core; import static org.assertj.core.api.Assertions.*; import static org.springframework.data.cassandra.core.mapping.MapIdFactory.*; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.cql.PrimaryKeyType; import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.MapId; import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for {@link org.springframework.data.cassandra.core.CassandraTemplate} using {@link MapId}. @@ -34,12 +34,12 @@ import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingInte * @author Matthew T. Adams * @author Mark Paluch */ -public class CassandraTemplateMapIdProxyDelegateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +public class CassandraTemplateMapIdProxyDelegateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraOperations operations; + private CassandraOperations operations; - @Before - public void before() { + @BeforeEach + void before() { operations = new CassandraTemplate(session); @@ -51,7 +51,7 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTests extends Abstrac } @Test - public void testSinglePkc() { + void testSinglePkc() { // insert SinglePkc inserted = new SinglePkc(uuid()); @@ -84,35 +84,35 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTests extends Abstrac } @Table - public static class SinglePkc { + private static class SinglePkc { - @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key; + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String key; - @Column String value; + @Column private String value; - public SinglePkc(String key) { + private SinglePkc(String key) { setKey(key); } - public String getKey() { + private String getKey() { return key; } - public void setKey(String key) { + private void setKey(String key) { this.key = key; } - public String getValue() { + private String getValue() { return value; } - public void setValue(String value) { + private void setValue(String value) { this.value = value; } } @Test - public void testMultiPkc() { + void testMultiPkc() { // insert MultiPkc inserted = new MultiPkc(uuid(), uuid()); @@ -150,40 +150,40 @@ public class CassandraTemplateMapIdProxyDelegateIntegrationTests extends Abstrac } @Table - public static class MultiPkc { + private static class MultiPkc { - @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key0; + @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String key0; - @PrimaryKeyColumn(ordinal = 1) String key1; + @PrimaryKeyColumn(ordinal = 1) private String key1; - @Column String value; + @Column private String value; - public MultiPkc(String key0, String key1) { + private MultiPkc(String key0, String key1) { setKey0(key0); setKey1(key1); } - public String getKey0() { + private String getKey0() { return key0; } - public void setKey0(String key0) { + private void setKey0(String key0) { this.key0 = key0; } - public String getKey1() { + private String getKey1() { return key1; } - public void setKey1(String key1) { + private void setKey1(String key1) { this.key1 = key1; } - public String getValue() { + private String getValue() { return value; } - public void setValue(String value) { + private void setValue(String value) { this.value = value; } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java index b952fbefc..964930417 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraTemplateUnitTests.java @@ -23,13 +23,15 @@ import static org.springframework.data.cassandra.core.query.Criteria.*; import java.util.Collections; import java.util.List; -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.ArgumentCaptor; import org.mockito.Captor; 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.cassandra.CassandraConnectionFailureException; import org.springframework.data.cassandra.core.mapping.event.BeforeConvertCallback; @@ -57,8 +59,9 @@ import com.datastax.oss.driver.api.core.type.DataTypes; * * @author Mark Paluch */ -@RunWith(MockitoJUnitRunner.class) -public class CassandraTemplateUnitTests { +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class CassandraTemplateUnitTests { @Mock CqlSession session; @Mock ResultSet resultSet; @@ -68,14 +71,14 @@ public class CassandraTemplateUnitTests { @Captor ArgumentCaptor statementCaptor; - CassandraTemplate template; + private CassandraTemplate template; - Object beforeSave; + private Object beforeSave; - Object beforeConvert; + private Object beforeConvert; - @Before - public void setUp() { + @BeforeEach + void setUp() { template = new CassandraTemplate(session); @@ -102,7 +105,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectUsingCqlShouldReturnMappedResults() { + void selectUsingCqlShouldReturnMappedResults() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -126,7 +129,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectShouldTranslateException() { + void selectShouldTranslateException() { when(resultSet.iterator()).thenThrow(new NoNodeAvailableException()); @@ -140,7 +143,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectOneShouldReturnMappedResults() { + void selectOneShouldReturnMappedResults() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -163,7 +166,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-696 - public void selectOneShouldNull() { + void selectOneShouldNull() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); @@ -173,7 +176,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void selectOneByIdShouldReturnMappedResults() { + void selectOneByIdShouldReturnMappedResults() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -196,7 +199,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-313 - public void selectProjectedOneShouldReturnMappedResults() { + void selectProjectedOneShouldReturnMappedResults() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -215,7 +218,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void existsShouldReturnExistingElement() { + void existsShouldReturnExistingElement() { when(resultSet.one()).thenReturn(row); @@ -227,7 +230,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void existsShouldReturnNonExistingElement() { + void existsShouldReturnNonExistingElement() { boolean exists = template.exists("myid", User.class); @@ -237,7 +240,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-512 - public void existsByQueryShouldReturnExistingElement() { + void existsByQueryShouldReturnExistingElement() { when(resultSet.one()).thenReturn(row); @@ -249,7 +252,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void countShouldExecuteCountQueryElement() { + void countShouldExecuteCountQueryElement() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); when(row.getLong(0)).thenReturn(42L); @@ -263,7 +266,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-512 - public void countByQueryShouldExecuteCountQueryElement() { + void countByQueryShouldExecuteCountQueryElement() { when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator()); when(row.getLong(0)).thenReturn(42L); @@ -277,7 +280,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292, DATACASS-618 - public void insertShouldInsertEntity() { + void insertShouldInsertEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -293,7 +296,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-618 - public void insertShouldInsertVersionedEntity() { + void insertShouldInsertVersionedEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -309,7 +312,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-250 - public void insertShouldInsertWithOptionsEntity() { + void insertShouldInsertWithOptionsEntity() { InsertOptions insertOptions = InsertOptions.builder().withIfNotExists().build(); @@ -325,7 +328,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-560 - public void insertShouldInsertWithNulls() { + void insertShouldInsertWithNulls() { InsertOptions insertOptions = InsertOptions.builder().withInsertNulls().build(); @@ -341,7 +344,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void insertShouldTranslateException() { + void insertShouldTranslateException() { reset(session); when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException()); @@ -356,7 +359,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void insertShouldNotApplyInsert() { + void insertShouldNotApplyInsert() { when(resultSet.wasApplied()).thenReturn(false); @@ -368,7 +371,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292, DATACASS-618 - public void updateShouldUpdateEntity() { + void updateShouldUpdateEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -384,7 +387,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-618 - public void updateShouldUpdateVersionedEntity() { + void updateShouldUpdateVersionedEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -401,7 +404,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-250 - public void updateShouldUpdateEntityWithOptions() { + void updateShouldUpdateEntityWithOptions() { when(resultSet.wasApplied()).thenReturn(true); @@ -418,7 +421,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldUpdateEntityWithLwt() { + void updateShouldUpdateEntityWithLwt() { UpdateOptions options = UpdateOptions.builder().ifCondition(where("firstname").is("Walter")).build(); User user = new User("heisenberg", "Walter", "White"); @@ -431,7 +434,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldApplyUpdateQuery() { + void updateShouldApplyUpdateQuery() { Query query = Query.query(where("id").is("heisenberg")); Update update = Update.update("firstname", "Walter"); @@ -444,7 +447,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldApplyUpdateQueryWitLwt() { + void updateShouldApplyUpdateQueryWitLwt() { Filter ifCondition = Filter.from(where("firstname").is("Walter"), where("lastname").is("White")); @@ -461,7 +464,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void updateShouldTranslateException() { + void updateShouldTranslateException() { reset(session); when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException()); @@ -476,7 +479,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void deleteByIdShouldRemoveEntity() { + void deleteByIdShouldRemoveEntity() { when(resultSet.wasApplied()).thenReturn(true); @@ -490,7 +493,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void deleteShouldRemoveEntity() { + void deleteShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -501,7 +504,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-575 - public void deleteShouldRemoveEntityWithLwt() { + void deleteShouldRemoveEntityWithLwt() { User user = new User("heisenberg", "Walter", "White"); DeleteOptions options = DeleteOptions.builder().ifCondition(where("firstname").is("Walter")).build(); @@ -514,7 +517,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-575 - public void deleteShouldRemoveByQueryWithLwt() { + void deleteShouldRemoveByQueryWithLwt() { DeleteOptions options = DeleteOptions.builder().ifCondition(where("firstname").is("Walter")).build(); Query query = Query.query(where("id").is("heisenberg")).queryOptions(options); @@ -527,7 +530,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void deleteShouldTranslateException() { + void deleteShouldTranslateException() { reset(session); when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException()); @@ -542,7 +545,7 @@ public class CassandraTemplateUnitTests { } @Test // DATACASS-292 - public void truncateShouldRemoveEntities() { + void truncateShouldRemoveEntities() { template.truncate(User.class); @@ -550,7 +553,7 @@ public class CassandraTemplateUnitTests { assertThat(statementCaptor.getValue().getQuery()).isEqualTo("TRUNCATE users"); } - interface UserProjection { + private interface UserProjection { String getFirstname(); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/DeleteOptionsUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/DeleteOptionsUnitTests.java index f1fd7c945..79b81b7e1 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/DeleteOptionsUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/DeleteOptionsUnitTests.java @@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*; import java.time.Duration; import java.time.Instant; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.query.Query; @@ -31,10 +31,10 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel; * * @author Mark Paluch */ -public class DeleteOptionsUnitTests { +class DeleteOptionsUnitTests { @Test // DATACASS-575, DATACASS-708 - public void shouldConfigureDeleteOptions() { + void shouldConfigureDeleteOptions() { Instant now = Instant.ofEpochSecond(1234); @@ -54,7 +54,7 @@ public class DeleteOptionsUnitTests { } @Test // DATACASS-575 - public void buildDeleteOptionsMutate() { + void buildDeleteOptionsMutate() { DeleteOptions deleteOptions = DeleteOptions.builder() // .ttl(10) // @@ -73,7 +73,7 @@ public class DeleteOptionsUnitTests { } @Test // DATACASS-575 - public void shouldApplyFilterCondition() { + void shouldApplyFilterCondition() { DeleteOptions deleteOptions = DeleteOptions.builder() // .withIfExists() // diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/EntityQueryUtilsUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/EntityQueryUtilsUnitTests.java index c2726e3e7..b22843740 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/EntityQueryUtilsUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/EntityQueryUtilsUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core; import static org.assertj.core.api.Assertions.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.datastax.oss.driver.api.core.CqlIdentifier; import com.datastax.oss.driver.api.core.cql.SimpleStatement; @@ -29,10 +29,10 @@ import com.datastax.oss.driver.api.querybuilder.select.Select; * * @author Mark Paluch */ -public class EntityQueryUtilsUnitTests { +class EntityQueryUtilsUnitTests { @Test // DATACASS-106 - public void shouldRetrieveTableNameFromSelect() { + void shouldRetrieveTableNameFromSelect() { Select select = QueryBuilder.selectFrom("ks", "tbl").all().where(); @@ -42,7 +42,7 @@ public class EntityQueryUtilsUnitTests { } @Test // DATACASS-642 - public void shouldRetrieveQuotedTableNameFromSelect() { + void shouldRetrieveQuotedTableNameFromSelect() { Select select = QueryBuilder.selectFrom(CqlIdentifier.fromCql("\"table\"")).all().where(); @@ -52,7 +52,7 @@ public class EntityQueryUtilsUnitTests { } @Test // DATACASS-106 - public void shouldRetrieveTableNameFromSimpleStatement() { + void shouldRetrieveTableNameFromSimpleStatement() { assertThat(EntityQueryUtils.getTableName(SimpleStatement.newInstance("SELECT * FROM table"))) .isEqualTo(CqlIdentifier.fromInternal("table")); @@ -61,7 +61,7 @@ public class EntityQueryUtilsUnitTests { } @Test // DATACASS-106 - public void shouldRetrieveQuotedTableNameFromSimpleStatement() { + void shouldRetrieveQuotedTableNameFromSimpleStatement() { CqlIdentifier tableName = EntityQueryUtils.getTableName(SimpleStatement.newInstance("SELECT * from \"table\"")); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java index ffc8ab14d..970b0e646 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableDeleteOperationSupportIntegrationTests.java @@ -23,8 +23,8 @@ import lombok.Data; import java.util.Collections; -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.cassandra.core.convert.MappingCassandraConverter; @@ -32,7 +32,7 @@ import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -41,15 +41,15 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class ExecutableDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ExecutableDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate template; + private CassandraAdminTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { template = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template.dropTable(true, CqlIdentifier.fromCql("person")); @@ -69,7 +69,7 @@ public class ExecutableDeleteOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void removeAllMatching() { + void removeAllMatching() { WriteResult deleteResult = this.template.delete(Person.class).matching(query(where("id").is(han.id))).all(); @@ -78,7 +78,7 @@ public class ExecutableDeleteOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void removeAllMatchingWithAlternateDomainTypeAndCollection() { + void removeAllMatchingWithAlternateDomainTypeAndCollection() { WriteResult deleteResult = this.template.delete(Jedi.class).inTable("person") .matching(query(where("id").in(han.id, luke.id))).all(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java index 5edd56477..e979abd61 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableInsertOperationSupportIntegrationTests.java @@ -21,14 +21,14 @@ import lombok.Data; import java.util.Collections; -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.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -37,15 +37,15 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class ExecutableInsertOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ExecutableInsertOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate template; + private CassandraAdminTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { template = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template.dropTable(true, CqlIdentifier.fromCql("person")); @@ -68,22 +68,22 @@ public class ExecutableInsertOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void domainTypeIsRequired() { + void domainTypeIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert((Class) null)); } @Test // DATACASS-485 - public void tableIsRequiredOnSet() { + void tableIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).inTable((String) null)); } @Test // DATACASS-485 - public void optionsIsRequiredOnSet() { + void optionsIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).withOptions(null)); } @Test // DATACASS-485 - public void insertOne() { + void insertOne() { WriteResult insertResult = this.template.insert(Person.class).inTable("person").one(han); @@ -92,7 +92,7 @@ public class ExecutableInsertOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void insertOneWithOptions() { + void insertOneWithOptions() { this.template.insert(Person.class).inTable("person").one(han); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java index 15ef8b4d6..e2a4a7410 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableSelectOperationSupportIntegrationTests.java @@ -25,8 +25,8 @@ import lombok.NoArgsConstructor; import java.util.stream.Stream; -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.dao.IncorrectResultSizeDataAccessException; import org.springframework.data.annotation.Id; @@ -37,22 +37,22 @@ import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for {@link ExecutableSelectOperationSupport}. * * @author Mark Paluch */ -public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate template; + private CassandraAdminTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { this.template = new CassandraAdminTemplate(session, new MappingCassandraConverter()); @@ -83,102 +83,104 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void domainTypeIsRequired() { + void domainTypeIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(null)); } @Test // DATACASS-485 - public void returnTypeIsRequiredOnSet() { + void returnTypeIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).as(null)); } @Test // DATACASS-485 - public void tableIsRequiredOnSet() { + void tableIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).inTable((String) null)); } @Test // DATACASS-485 - public void findAll() { + void findAll() { assertThat(this.template.query(Person.class).all()).containsExactlyInAnyOrder(han, luke); } @Test // DATACASS-485 - public void findAllWithCollection() { + void findAllWithCollection() { assertThat(this.template.query(Human.class).inTable("person").all()).hasSize(2); } @Test // DATACASS-485 - public void findAllWithProjection() { + void findAllWithProjection() { assertThat(this.template.query(Person.class).as(Jedi.class).all()).hasOnlyElementsOfType(Jedi.class).hasSize(2); } @Test // DATACASS-485 - public void findByReturningAllValuesAsClosedInterfaceProjection() { + void findByReturningAllValuesAsClosedInterfaceProjection() { assertThat(this.template.query(Person.class).as(PersonProjection.class).all()) .hasOnlyElementsOfTypes(PersonProjection.class); } @Test // DATACASS-485 - public void findAllBy() { + void findAllBy() { assertThat(this.template.query(Person.class).matching(queryLuke()).all()).containsExactlyInAnyOrder(luke); } @Test // DATACASS-485 - public void findAllByWithCollectionUsingMappingInformation() { + void findAllByWithCollectionUsingMappingInformation() { assertThat(this.template.query(Jedi.class).inTable("person").all()) .isNotEmpty().hasOnlyElementsOfType(Jedi.class); } @Test // DATACASS-485 - public void findAllByWithCollection() { + void findAllByWithCollection() { assertThat(this.template.query(Human.class).inTable("person").matching(queryLuke()).all()).hasSize(1); } @Test // DATACASS-485 - public void findAllByWithProjection() { + void findAllByWithProjection() { assertThat(this.template.query(Person.class).as(Jedi.class).all()) .hasOnlyElementsOfType(Jedi.class).isNotEmpty(); } @Test // DATACASS-485 - public void findBy() { + void findBy() { assertThat(this.template.query(Person.class).matching(queryLuke()).one()).contains(luke); } @Test // DATACASS-485 - public void findByNoMatch() { + void findByNoMatch() { assertThat(this.template.query(Person.class).matching(querySpock()).one()).isEmpty(); } - @Test(expected = IncorrectResultSizeDataAccessException.class) // DATACASS-485 - public void findByTooManyResults() { - this.template.query(Person.class).one(); + @Test // DATACASS-485 + void findByTooManyResults() { + assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class) + .isThrownBy(() -> this.template.query(Person.class).one()); } @Test // DATACASS-485 - public void findByReturningOneValue() { + void findByReturningOneValue() { assertThat(this.template.query(Person.class).matching(queryLuke()).oneValue()).isEqualTo(luke); } - @Test(expected = IncorrectResultSizeDataAccessException.class) // DATACASS-485 - public void findByReturningOneValueButTooManyResults() { - this.template.query(Person.class).oneValue(); + @Test // DATACASS-485 + void findByReturningOneValueButTooManyResults() { + assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class) + .isThrownBy(() -> this.template.query(Person.class).oneValue()); } @Test // DATACASS-485 - public void findByReturningFirstValue() { + void findByReturningFirstValue() { assertThat(this.template.query(Person.class).matching(queryLuke()).firstValue()).isEqualTo(luke); } @Test // DATACASS-485 - public void findByReturningFirstValueForManyResults() { + void findByReturningFirstValueForManyResults() { assertThat(this.template.query(Person.class).firstValue()).isIn(han, luke); } @Test // DATACASS-485 - public void findByReturningFirstValueAsClosedInterfaceProjection() { + void findByReturningFirstValueAsClosedInterfaceProjection() { PersonProjection result = this.template .query(Person.class) @@ -191,7 +193,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void findByReturningFirstValueAsOpenInterfaceProjection() { + void findByReturningFirstValueAsOpenInterfaceProjection() { PersonSpELProjection result = this.template .query(Person.class) @@ -204,7 +206,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void streamAll() { + void streamAll() { try (Stream stream = this.template.query(Person.class).stream()) { assertThat(stream).containsExactlyInAnyOrder(han, luke); @@ -212,7 +214,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void streamAllWithCollection() { + void streamAllWithCollection() { Stream stream = this.template.query(Human.class).inTable("person").stream(); @@ -220,7 +222,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void streamAllWithProjection() { + void streamAllWithProjection() { try (Stream stream = this.template.query(Person.class).as(Jedi.class).stream()) { assertThat(stream).hasOnlyElementsOfType(Jedi.class).hasSize(2); @@ -228,7 +230,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void streamAllReturningResultsAsClosedInterfaceProjection() { + void streamAllReturningResultsAsClosedInterfaceProjection() { TerminatingSelect operation = this.template.query(Person.class).as(PersonProjection.class); @@ -242,7 +244,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void streamAllReturningResultsAsOpenInterfaceProjection() { + void streamAllReturningResultsAsOpenInterfaceProjection() { TerminatingSelect operation = this.template.query(Person.class).as(PersonSpELProjection.class); @@ -256,7 +258,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void streamAllBy() { + void streamAllBy() { Stream stream = this.template.query(Person.class).matching(queryLuke()).stream(); @@ -264,28 +266,28 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void firstShouldReturnFirstEntryInCollection() { + void firstShouldReturnFirstEntryInCollection() { assertThat(this.template.query(Person.class).first()).isNotEmpty(); } @Test // DATACASS-485 - public void countShouldReturnNrOfElementsInCollectionWhenNoQueryPresent() { + void countShouldReturnNrOfElementsInCollectionWhenNoQueryPresent() { assertThat(this.template.query(Person.class).count()).isEqualTo(2); } @Test // DATACASS-485 - public void countShouldReturnNrOfElementsMatchingQuery() { + void countShouldReturnNrOfElementsMatchingQuery() { assertThat(this.template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname())) .withAllowFiltering()).count()).isEqualTo(1); } @Test // DATACASS-485 - public void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() { + void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() { assertThat(this.template.query(Person.class).exists()).isTrue(); } @Test // DATACASS-485 - public void existsShouldReturnFalseIfNoElementExistsInCollection() { + void existsShouldReturnFalseIfNoElementExistsInCollection() { this.template.truncate(Person.class); @@ -293,17 +295,17 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void existsShouldReturnTrueIfAtLeastOneElementMatchesQuery() { + void existsShouldReturnTrueIfAtLeastOneElementMatchesQuery() { assertThat(this.template.query(Person.class).matching(queryLuke()).exists()).isTrue(); } @Test // DATACASS-485 - public void existsShouldReturnFalseWhenNoElementMatchesQuery() { + void existsShouldReturnFalseWhenNoElementMatchesQuery() { assertThat(this.template.query(Person.class).matching(querySpock()).exists()).isFalse(); } @Test // DATACASS-485 - public void returnsTargetObjectDirectlyIfProjectionInterfaceIsImplemented() { + void returnsTargetObjectDirectlyIfProjectionInterfaceIsImplemented() { assertThat(this.template.query(Person.class).as(Contact.class).all()).allMatch(it -> it instanceof Person); } @@ -315,7 +317,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe return query(where("firstname").is("spock")).withAllowFiltering(); } - interface Contact {} + private interface Contact {} @Data @Table @@ -325,7 +327,7 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe @Indexed String lastname; } - interface PersonProjection { + private interface PersonProjection { String getFirstname(); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java index 4572e58ca..3ac88f951 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ExecutableUpdateOperationSupportIntegrationTests.java @@ -24,8 +24,8 @@ import lombok.Data; import java.util.Collections; -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.cassandra.core.convert.MappingCassandraConverter; @@ -33,7 +33,7 @@ import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -42,15 +42,15 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate template; + private CassandraAdminTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { template = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template.dropTable(true, CqlIdentifier.fromCql("person")); @@ -69,23 +69,23 @@ public class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void domainTypeIsRequired() { + void domainTypeIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(null)); } @Test // DATACASS-485 - public void queryIsRequired() { + void queryIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(Person.class).matching(null)); } @Test // DATACASS-485 - public void tableIsRequiredOnSet() { + void tableIsRequiredOnSet() { assertThatIllegalArgumentException() .isThrownBy(() -> this.template.update(Person.class).inTable((CqlIdentifier) null)); } @Test // DATACASS-485 - public void updateAllMatching() { + void updateAllMatching() { WriteResult updateResult = this.template.update(Person.class).matching(queryHan()) .apply(update("firstname", "Han")); @@ -96,7 +96,7 @@ public class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKe } @Test // DATACASS-485 - public void updateWithDifferentDomainClassAndCollection() { + void updateWithDifferentDomainClassAndCollection() { WriteResult updateResult = this.template.update(Jedi.class).inTable("person") .matching(query(where("id").is(han.getId()))).apply(update("name", "Han")); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/InsertOptionsUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/InsertOptionsUnitTests.java index a4732fb54..f2e053204 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/InsertOptionsUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/InsertOptionsUnitTests.java @@ -22,7 +22,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.datastax.oss.driver.api.core.DefaultConsistencyLevel; @@ -32,10 +32,10 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel; * @author Mark Paluch * @author Lukasz Antoniak */ -public class InsertOptionsUnitTests { +class InsertOptionsUnitTests { @Test // DATACASS-250, DATACASS-155, DATACASS-708 - public void shouldConfigureInsertOptions() { + void shouldConfigureInsertOptions() { Instant now = LocalDateTime.now().toInstant(ZoneOffset.UTC); @@ -53,7 +53,7 @@ public class InsertOptionsUnitTests { } @Test // DATACASS-56 - public void buildInsertOptionsMutate() { + void buildInsertOptionsMutate() { InsertOptions insertOptions = InsertOptions.builder().ttl(10).timestamp(1519222753).withIfNotExists().build(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java index 7dae8e3e9..84418097d 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/OptimisticLockingIntegrationTests.java @@ -15,14 +15,13 @@ */ package org.springframework.data.cassandra.core; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.*; import lombok.Data; import lombok.experimental.Wither; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.data.annotation.Id; @@ -30,19 +29,19 @@ import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.annotation.Version; import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for optimistic locking through {@link CassandraTemplate}. * * @author Mark Paluch */ -public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraTemplate template; + private CassandraTemplate template; - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); @@ -55,7 +54,7 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-576 - public void shouldInsertVersioned() { + void shouldInsertVersioned() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -68,7 +67,7 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-576 - public void duplicateInsertShouldFail() { + void duplicateInsertShouldFail() { template.insert(new VersionedEntity(42)); @@ -77,7 +76,7 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-576 - public void shouldUpdateVersioned() { + void shouldUpdateVersioned() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -92,7 +91,7 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-576 - public void updateForOutdatedEntityShouldFail() { + void updateForOutdatedEntityShouldFail() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -103,7 +102,7 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-576 - public void shouldDeleteVersionedEntity() { + void shouldDeleteVersionedEntity() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -117,7 +116,7 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI } @Test // DATACASS-576 - public void deleteForOutdatedEntityShouldFail() { + void deleteForOutdatedEntityShouldFail() { template.insert(new VersionedEntity(42)); @@ -139,12 +138,12 @@ public class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingI final String name; - public VersionedEntity(long id) { + private VersionedEntity(long id) { this(id, 0, null); } @PersistenceConstructor - public VersionedEntity(long id, long version, String name) { + private VersionedEntity(long id, long version, String name) { this.id = id; this.version = version; this.name = name; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraBatchTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraBatchTemplateIntegrationTests.java index ab1de118a..554def35e 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraBatchTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraBatchTemplateIntegrationTests.java @@ -26,8 +26,8 @@ import java.util.Collections; import java.util.Random; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.ReactiveResultSet; import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate; @@ -37,7 +37,7 @@ import org.springframework.data.cassandra.domain.FlatGroup; import org.springframework.data.cassandra.domain.Group; import org.springframework.data.cassandra.domain.GroupKey; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for {@link ReactiveCassandraBatchTemplate}. @@ -45,15 +45,15 @@ import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingInte * @author Oleh Dokuka * @author Mark Paluch */ -public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - Group walter = new Group(new GroupKey("users", "0x1", "walter")); - Group mike = new Group(new GroupKey("users", "0x1", "mike")); + private Group walter = new Group(new GroupKey("users", "0x1", "walter")); + private Group mike = new Group(new GroupKey("users", "0x1", "mike")); - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); CassandraTemplate cassandraTemplate = new CassandraTemplate(this.session, converter); @@ -74,7 +74,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldInsertEntities() { + void shouldInsertEntities() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); Mono execution = batchOperations.insert(walter).insert(mike).execute(); @@ -88,7 +88,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldInsertCollectionOfEntities() { + void shouldInsertCollectionOfEntities() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); Mono loadedMono = batchOperations.insert(Arrays.asList(walter, mike)).execute() @@ -101,7 +101,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldInsertCollectionOfEntitiesWithTtl() { + void shouldInsertCollectionOfEntitiesWithTtl() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -120,7 +120,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldInsertMonoOfEntitiesWithTtl() { + void shouldInsertMonoOfEntitiesWithTtl() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -139,7 +139,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateEntities() { + void shouldUpdateEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -154,7 +154,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateMonoEntities() { + void shouldUpdateMonoEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -169,7 +169,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateCollectionOfEntities() { + void shouldUpdateCollectionOfEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -184,7 +184,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateCollectionOfEntitiesWithTtl() { + void shouldUpdateCollectionOfEntitiesWithTtl() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -204,7 +204,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateMonoCollectionOfEntitiesWithTtl() { + void shouldUpdateMonoCollectionOfEntitiesWithTtl() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -224,7 +224,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateMonoOfEntities() { + void shouldUpdateMonoOfEntities() { FlatGroup walter = new FlatGroup("users", "0x1", "walter"); FlatGroup mike = new FlatGroup("users", "0x1", "mike"); @@ -242,7 +242,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldUpdateMonoCollectionOfEntities() { + void shouldUpdateMonoCollectionOfEntities() { FlatGroup walter = new FlatGroup("users", "0x1", "walter"); FlatGroup mike = new FlatGroup("users", "0x1", "mike"); @@ -261,7 +261,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldDeleteEntities() { + void shouldDeleteEntities() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); @@ -274,7 +274,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldDeleteCollectionOfEntities() { + void shouldDeleteCollectionOfEntities() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); @@ -287,7 +287,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldDeleteMonoOfEntities() { + void shouldDeleteMonoOfEntities() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); @@ -300,7 +300,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldApplyTimestampToAllEntities() { + void shouldApplyTimestampToAllEntities() { walter.setEmail("walter@white.com"); mike.setEmail("mike@sauls.com"); @@ -318,7 +318,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldNotExecuteTwice() { + void shouldNotExecuteTwice() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); @@ -329,7 +329,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldNotAllowModificationAfterExecution() { + void shouldNotAllowModificationAfterExecution() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); @@ -339,7 +339,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldNotAllowModificationAfterExecutionMonoCase() { + void shouldNotAllowModificationAfterExecutionMonoCase() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); @@ -350,7 +350,7 @@ public class ReactiveCassandraBatchTemplateIntegrationTests extends AbstractKeys } @Test // DATACASS-574 - public void shouldSupportMultithreadedMerge() { + void shouldSupportMultithreadedMerge() { ReactiveCassandraBatchOperations batchOperations = new ReactiveCassandraBatchTemplate(template); Random random = new Random(); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java index a154e78e1..3be5990ef 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateIntegrationTests.java @@ -19,12 +19,11 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.cassandra.core.query.Criteria.*; import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; import reactor.test.StepVerifier.FirstStep; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate; @@ -37,7 +36,7 @@ import org.springframework.data.cassandra.core.query.Update; import org.springframework.data.cassandra.domain.User; import org.springframework.data.cassandra.domain.UserToken; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; @@ -48,12 +47,12 @@ import com.datastax.oss.driver.api.core.uuid.Uuids; * * @author Mark Paluch */ -public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); CassandraTemplate cassandraTemplate = new CassandraTemplate(this.session, converter); @@ -68,7 +67,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void insertShouldInsertEntity() { + void insertShouldInsertEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -81,7 +80,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-250, DATACASS-573 - public void insertShouldCreateEntityWithLwt() { + void insertShouldCreateEntityWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -97,7 +96,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-250 - public void insertShouldNotUpdateEntityWithLwt() { + void insertShouldNotUpdateEntityWithLwt() { InsertOptions lwtOptions = InsertOptions.builder().withIfNotExists().build(); @@ -115,7 +114,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void shouldInsertEntityAndCount() { + void shouldInsertEntityAndCount() { User user = new User("heisenberg", "Walter", "White"); @@ -125,7 +124,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void shouldInsertEntityAndCountByQuery() { + void shouldInsertEntityAndCountByQuery() { User user = new User("heisenberg", "Walter", "White"); @@ -141,7 +140,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void shouldInsertAndExistsByQueryEntities() { + void shouldInsertAndExistsByQueryEntities() { User user = new User("heisenberg", "Walter", "White"); @@ -157,7 +156,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void updateShouldUpdateEntity() { + void updateShouldUpdateEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -171,7 +170,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-292 - public void updateShouldNotCreateEntityWithLwt() { + void updateShouldNotCreateEntityWithLwt() { UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build(); @@ -184,7 +183,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-292 - public void updateShouldUpdateEntityWithLwt() { + void updateShouldUpdateEntityWithLwt() { UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build(); @@ -200,7 +199,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-343 - public void updateShouldUpdateEntityByQuery() { + void updateShouldUpdateEntityByQuery() { User user = new User("heisenberg", "Walter", "White"); @@ -214,7 +213,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-343 - public void deleteByQueryShouldRemoveEntity() { + void deleteByQueryShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); template.insert(user).block(); @@ -226,7 +225,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-343 - public void deleteColumnsByQueryShouldRemoveColumn() { + void deleteColumnsByQueryShouldRemoveColumn() { User user = new User("heisenberg", "Walter", "White"); template.insert(user).block(); @@ -241,7 +240,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void deleteShouldRemoveEntity() { + void deleteShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -253,7 +252,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-335 - public void deleteByIdShouldRemoveEntity() { + void deleteByIdShouldRemoveEntity() { User user = new User("heisenberg", "Walter", "White"); @@ -265,7 +264,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-606 - public void deleteShouldRemoveEntityWithLwt() { + void deleteShouldRemoveEntityWithLwt() { DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build(); @@ -284,7 +283,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-606 - public void deleteByQueryShouldRemoveEntityWithLwt() { + void deleteByQueryShouldRemoveEntityWithLwt() { DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build(); @@ -305,7 +304,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-343 - public void shouldSelectByQueryWithSorting() { + void shouldSelectByQueryWithSorting() { UserToken token1 = new UserToken(); token1.setUserId(Uuids.endOf(System.currentTimeMillis())); @@ -326,7 +325,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-343 - public void shouldSelectOneByQuery() { + void shouldSelectOneByQuery() { UserToken token1 = new UserToken(); token1.setUserId(Uuids.endOf(System.currentTimeMillis())); @@ -341,7 +340,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-529 - public void shouldReturnEmptySliceOnEmptyResult() { + void shouldReturnEmptySliceOnEmptyResult() { Query query = Query.query(where("id").is("foo")).pageRequest(CassandraPageRequest.first(10)); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java index fc9ecb37a..ae54df33c 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplateUnitTests.java @@ -24,13 +24,15 @@ import reactor.core.publisher.Flux; 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.mockito.ArgumentCaptor; import org.mockito.Captor; 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.cassandra.ReactiveResultSet; import org.springframework.data.cassandra.ReactiveSession; @@ -57,8 +59,9 @@ import com.datastax.oss.driver.api.core.type.DataTypes; * * @author Mark Paluch */ -@RunWith(MockitoJUnitRunner.class) -public class ReactiveCassandraTemplateUnitTests { +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class ReactiveCassandraTemplateUnitTests { @Mock ReactiveSession session; @Mock ReactiveResultSet reactiveResultSet; @@ -68,14 +71,14 @@ public class ReactiveCassandraTemplateUnitTests { @Captor ArgumentCaptor statementCaptor; - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - Object beforeSave; + private Object beforeSave; - Object beforeConvert; + private Object beforeConvert; - @Before - public void setUp() { + @BeforeEach + void setUp() { template = new ReactiveCassandraTemplate(session); @@ -102,7 +105,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void selectUsingCqlShouldReturnMappedResults() { + void selectUsingCqlShouldReturnMappedResults() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -127,7 +130,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void selectShouldTranslateException() { + void selectShouldTranslateException() { when(reactiveResultSet.rows()).thenThrow(new NoNodeAvailableException()); @@ -138,7 +141,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void selectOneByIdShouldReturnMappedResults() { + void selectOneByIdShouldReturnMappedResults() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -162,7 +165,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-313 - public void selectProjectedOneShouldReturnMappedResults() { + void selectProjectedOneShouldReturnMappedResults() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); when(columnDefinitions.contains(any(CqlIdentifier.class))).thenReturn(true); @@ -185,7 +188,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-696 - public void selectOneShouldNull() { + void selectOneShouldNull() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -194,7 +197,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void existsShouldReturnExistingElement() { + void existsShouldReturnExistingElement() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -205,7 +208,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void existsShouldReturnNonExistingElement() { + void existsShouldReturnNonExistingElement() { when(reactiveResultSet.rows()).thenReturn(Flux.empty()); @@ -216,7 +219,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-512 - public void existsByQueryShouldReturnExistingElement() { + void existsByQueryShouldReturnExistingElement() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -227,7 +230,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-512 - public void existsByQueryShouldReturnNonExistingElement() { + void existsByQueryShouldReturnNonExistingElement() { when(reactiveResultSet.rows()).thenReturn(Flux.empty()); @@ -238,7 +241,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void countShouldExecuteCountQueryElement() { + void countShouldExecuteCountQueryElement() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); when(row.getLong(0)).thenReturn(42L); @@ -251,7 +254,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-512 - public void countByQueryShouldExecuteCountQueryElement() { + void countByQueryShouldExecuteCountQueryElement() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); when(row.getLong(0)).thenReturn(42L); @@ -264,7 +267,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335, DATACASS-618 - public void insertShouldInsertEntity() { + void insertShouldInsertEntity() { when(reactiveResultSet.wasApplied()).thenReturn(true); when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -280,7 +283,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-618 - public void insertShouldInsertVersionedEntity() { + void insertShouldInsertVersionedEntity() { when(reactiveResultSet.wasApplied()).thenReturn(true); when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -296,7 +299,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void insertShouldTranslateException() { + void insertShouldTranslateException() { reset(session); when(session.execute(any(Statement.class))).thenReturn(Mono.error(new NoNodeAvailableException())); @@ -309,7 +312,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335, DATACASS-618 - public void updateShouldUpdateEntity() { + void updateShouldUpdateEntity() { when(reactiveResultSet.wasApplied()).thenReturn(true); when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -326,7 +329,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-618 - public void updateShouldUpdateVersionedEntity() { + void updateShouldUpdateVersionedEntity() { when(reactiveResultSet.wasApplied()).thenReturn(true); when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -344,7 +347,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldUpdateEntityWithOptions() { + void updateShouldUpdateEntityWithOptions() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -362,7 +365,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldUpdateEntityWithLwt() { + void updateShouldUpdateEntityWithLwt() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -380,7 +383,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldApplyUpdateQuery() { + void updateShouldApplyUpdateQuery() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -398,7 +401,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void updateShouldApplyUpdateQueryWitLwt() { + void updateShouldApplyUpdateQueryWitLwt() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -420,7 +423,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void deleteShouldRemoveEntity() { + void deleteShouldRemoveEntity() { when(reactiveResultSet.wasApplied()).thenReturn(true); when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -434,7 +437,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void deleteShouldRemoveEntityWithLwt() { + void deleteShouldRemoveEntityWithLwt() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -452,7 +455,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-575 - public void deleteShouldRemoveByQueryWithLwt() { + void deleteShouldRemoveByQueryWithLwt() { when(reactiveResultSet.rows()).thenReturn(Flux.just(row)); @@ -470,7 +473,7 @@ public class ReactiveCassandraTemplateUnitTests { } @Test // DATACASS-335 - public void truncateShouldRemoveEntities() { + void truncateShouldRemoveEntities() { template.truncate(User.class).as(StepVerifier::create).verifyComplete(); @@ -478,7 +481,7 @@ public class ReactiveCassandraTemplateUnitTests { assertThat(statementCaptor.getValue().getQuery()).isEqualTo("TRUNCATE users"); } - interface UserProjection { + private interface UserProjection { String getFirstname(); } } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java index 05749f575..5013d4d88 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveDeleteOperationSupportIntegrationTests.java @@ -24,8 +24,8 @@ import reactor.test.StepVerifier; import java.util.Collections; -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.cassandra.core.convert.MappingCassandraConverter; @@ -34,7 +34,7 @@ import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -43,17 +43,17 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate admin; + private CassandraAdminTemplate admin; - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { admin = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template = new ReactiveCassandraTemplate(new DefaultBridgedReactiveSession(session)); @@ -76,7 +76,7 @@ public class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void removeAllMatching() { + void removeAllMatching() { Mono writeResult = this.template .delete(Person.class) @@ -87,7 +87,7 @@ public class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void removeAllMatchingWithAlternateDomainTypeAndCollection() { + void removeAllMatchingWithAlternateDomainTypeAndCollection() { Mono writeResult = this.template .delete(Jedi.class).inTable("person") diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java index 10dacc56e..a06b0cfae 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveInsertOperationSupportIntegrationTests.java @@ -23,15 +23,15 @@ import reactor.test.StepVerifier; import java.util.Collections; -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.cassandra.core.convert.MappingCassandraConverter; import org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession; import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -40,17 +40,17 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate admin; + private CassandraAdminTemplate admin; - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { admin = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template = new ReactiveCassandraTemplate(new DefaultBridgedReactiveSession(session)); @@ -75,22 +75,22 @@ public class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void domainTypeIsRequired() { + void domainTypeIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert((Class) null)); } @Test // DATACASS-485 - public void optionsIsRequiredOnSet() { + void optionsIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).withOptions(null)); } @Test // DATACASS-485 - public void tableIsRequiredOnSet() { + void tableIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).inTable((String) null)); } @Test // DATACASS-485, DATACASS-573 - public void insertOne() { + void insertOne() { Mono> writeResult = this.template.insert(Person.class).inTable("person").one(han); @@ -104,7 +104,7 @@ public class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485, DATACASS-573 - public void insertOneWithOptions() { + void insertOneWithOptions() { this.template.insert(Person.class).inTable("person").one(han); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java index b860a1607..df11847d5 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveOptimisticLockingIntegrationTests.java @@ -15,15 +15,14 @@ */ package org.springframework.data.cassandra.core; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import lombok.Data; import lombok.experimental.Wither; - 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.dao.OptimisticLockingFailureException; import org.springframework.data.annotation.Id; @@ -34,19 +33,19 @@ import org.springframework.data.cassandra.core.cql.CqlTemplate; import org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for optimistic locking through {@link ReactiveCassandraTemplate}. * * @author Mark Paluch */ -public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - @Before - public void setUp() { + @BeforeEach + void setUp() { MappingCassandraConverter converter = new MappingCassandraConverter(); @@ -61,7 +60,7 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-576 - public void shouldInsertVersioned() { + void shouldInsertVersioned() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -77,7 +76,7 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-576 - public void duplicateInsertShouldFail() { + void duplicateInsertShouldFail() { template.insert(new VersionedEntity(42)) // .as(StepVerifier::create) // @@ -90,7 +89,7 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-576 - public void shouldUpdateVersioned() { + void shouldUpdateVersioned() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -106,7 +105,7 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-576 - public void updateForOutdatedEntityShouldFail() { + void updateForOutdatedEntityShouldFail() { template.insert(new VersionedEntity(42)) // .as(StepVerifier::create) // @@ -119,7 +118,7 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-576 - public void shouldDeleteVersionedEntity() { + void shouldDeleteVersionedEntity() { VersionedEntity versionedEntity = new VersionedEntity(42); @@ -134,7 +133,7 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC } @Test // DATACASS-576 - public void deleteForOutdatedEntityShouldFail() { + void deleteForOutdatedEntityShouldFail() { template.insert(new VersionedEntity(42))// .as(StepVerifier::create) // @@ -161,12 +160,12 @@ public class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceC final String name; - public VersionedEntity(long id) { + private VersionedEntity(long id) { this(id, 0, null); } @PersistenceConstructor - public VersionedEntity(long id, long version, String name) { + private VersionedEntity(long id, long version, String name) { this.id = id; this.version = version; this.name = name; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java index 7febfcb3f..c605a0f62 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveSelectOperationSupportIntegrationTests.java @@ -26,8 +26,8 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; 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.beans.factory.annotation.Value; import org.springframework.dao.IncorrectResultSizeDataAccessException; import org.springframework.data.annotation.Id; @@ -38,24 +38,24 @@ import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; import org.springframework.data.cassandra.repository.support.SchemaTestUtils; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; /** * Integration tests for {@link ExecutableSelectOperationSupport}. * * @author Mark Paluch */ -public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate admin; + private CassandraAdminTemplate admin; - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { admin = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template = new ReactiveCassandraTemplate(new DefaultBridgedReactiveSession(session)); @@ -85,22 +85,22 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void domainTypeIsRequired() { + void domainTypeIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(null)); } @Test // DATACASS-485 - public void returnTypeIsRequiredOnSet() { + void returnTypeIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).as(null)); } @Test // DATACASS-485 - public void tableIsRequiredOnSet() { + void tableIsRequiredOnSet() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).inTable((String) null)); } @Test // DATACASS-485 - public void findAll() { + void findAll() { Flux result = this.template.query(Person.class).all(); @@ -111,7 +111,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findAllWithCollection() { + void findAllWithCollection() { Flux result = this.template.query(Human.class).inTable("person").all(); @@ -119,7 +119,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findAllWithProjection() { + void findAllWithProjection() { Flux result = this.template.query(Person.class).as(Jedi.class).all(); @@ -130,7 +130,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByReturningAllValuesAsClosedInterfaceProjection() { + void findByReturningAllValuesAsClosedInterfaceProjection() { Flux result = this.template.query(Person.class).as(PersonProjection.class).all(); @@ -141,7 +141,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findAllBy() { + void findAllBy() { Flux result = this.template.query(Person.class).matching(queryLuke()).all(); @@ -149,7 +149,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findAllByWithCollectionUsingMappingInformation() { + void findAllByWithCollectionUsingMappingInformation() { Flux result = this.template.query(Jedi.class).inTable("person").all(); @@ -160,7 +160,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findAllByWithCollection() { + void findAllByWithCollection() { Flux result = this.template.query(Human.class).inTable("person").matching(queryLuke()).all(); @@ -168,7 +168,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findAllByWithProjection() { + void findAllByWithProjection() { Flux result = this.template.query(Person.class).as(Jedi.class).all(); @@ -179,7 +179,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findBy() { + void findBy() { Mono result = this.template.query(Person.class).matching(queryLuke()).one(); @@ -187,7 +187,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByNoMatch() { + void findByNoMatch() { Mono result = this.template.query(Person.class).matching(querySpock()).one(); @@ -195,7 +195,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByTooManyResults() { + void findByTooManyResults() { Mono result = this.template.query(Person.class).one(); @@ -203,7 +203,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByReturningFirst() { + void findByReturningFirst() { Mono result = this.template.query(Person.class).matching(queryLuke()).first(); @@ -211,7 +211,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByReturningFirstForManyResults() { + void findByReturningFirstForManyResults() { Mono result = this.template.query(Person.class).first(); @@ -221,7 +221,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByReturningFirstAsClosedInterfaceProjection() { + void findByReturningFirstAsClosedInterfaceProjection() { Mono result = this.template .query(Person.class) @@ -236,7 +236,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void findByReturningFirstAsOpenInterfaceProjection() { + void findByReturningFirstAsOpenInterfaceProjection() { Mono result = this.template .query(Person.class) @@ -251,7 +251,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void countShouldReturnNumberOfElementsInCollectionWhenNoQueryPresent() { + void countShouldReturnNumberOfElementsInCollectionWhenNoQueryPresent() { Mono count = this.template.query(Person.class).count(); @@ -259,7 +259,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void countShouldReturnNrOfElementsMatchingQuery() { + void countShouldReturnNrOfElementsMatchingQuery() { Mono count = this.template .query(Person.class) @@ -270,7 +270,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() { + void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() { Mono exists = this.template.query(Person.class).exists(); @@ -278,7 +278,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void existsShouldReturnFalseIfNoElementExistsInCollection() { + void existsShouldReturnFalseIfNoElementExistsInCollection() { this.template.truncate(Person.class).as(StepVerifier::create).verifyComplete(); @@ -288,7 +288,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void existsShouldReturnTrueIfAtLeastOneElementMatchesQuery() { + void existsShouldReturnTrueIfAtLeastOneElementMatchesQuery() { Mono exists = this.template.query(Person.class).matching(queryLuke()).exists(); @@ -296,7 +296,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void existsShouldReturnFalseWhenNoElementMatchesQuery() { + void existsShouldReturnFalseWhenNoElementMatchesQuery() { Mono exists = this.template.query(Person.class).matching(querySpock()).exists(); @@ -304,7 +304,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void returnsTargetObjectDirectlyIfProjectionInterfaceIsImplemented() { + void returnsTargetObjectDirectlyIfProjectionInterfaceIsImplemented() { Flux result = this.template.query(Person.class).as(Contact.class).all(); @@ -322,7 +322,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys return query(where("firstname").is("spock")).withAllowFiltering(); } - interface Contact {} + private interface Contact {} @Data @Table @@ -332,7 +332,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys @Indexed String lastname; } - interface PersonProjection { + private interface PersonProjection { String getFirstname(); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java index b3db91296..eb0f3a024 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/ReactiveUpdateOperationSupportIntegrationTests.java @@ -26,8 +26,8 @@ import reactor.test.StepVerifier; import java.util.Collections; -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.cassandra.core.convert.MappingCassandraConverter; @@ -36,7 +36,7 @@ import org.springframework.data.cassandra.core.mapping.Column; import org.springframework.data.cassandra.core.mapping.Indexed; import org.springframework.data.cassandra.core.mapping.Table; import org.springframework.data.cassandra.core.query.Query; -import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest; +import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests; import com.datastax.oss.driver.api.core.CqlIdentifier; @@ -45,17 +45,17 @@ import com.datastax.oss.driver.api.core.CqlIdentifier; * * @author Mark Paluch */ -public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest { +class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests { - CassandraAdminTemplate admin; + private CassandraAdminTemplate admin; - ReactiveCassandraTemplate template; + private ReactiveCassandraTemplate template; - Person han; - Person luke; + private Person han; + private Person luke; - @Before - public void setUp() { + @BeforeEach + void setUp() { admin = new CassandraAdminTemplate(session, new MappingCassandraConverter()); template = new ReactiveCassandraTemplate(new DefaultBridgedReactiveSession(session)); @@ -76,23 +76,23 @@ public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void domainTypeIsRequired() { + void domainTypeIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(null)); } @Test // DATACASS-485 - public void queryIsRequired() { + void queryIsRequired() { assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(Person.class).matching(null)); } @Test // DATACASS-485 - public void tableIsRequiredOnSet() { + void tableIsRequiredOnSet() { assertThatIllegalArgumentException() .isThrownBy(() -> this.template.update(Person.class).inTable((CqlIdentifier) null)); } @Test // DATACASS-485 - public void updateAllMatching() { + void updateAllMatching() { Mono writeResult = this.template.update(Person.class).matching(queryHan()) .apply(update("firstname", "Han")); @@ -101,7 +101,7 @@ public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeys } @Test // DATACASS-485 - public void updateWithDifferentDomainClassAndCollection() { + void updateWithDifferentDomainClassAndCollection() { Mono writeResult = this.template.update(Jedi.class).inTable("person") .matching(query(where("id").is(han.getId()))).apply(update("name", "Han")); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/StatementFactoryUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/StatementFactoryUnitTests.java index 891e86a91..f7a950aec 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/StatementFactoryUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/StatementFactoryUnitTests.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.data.annotation.Id; import org.springframework.data.cassandra.core.convert.CassandraConverter; @@ -53,19 +53,21 @@ import com.datastax.oss.driver.api.querybuilder.select.Select; * * @author Mark Paluch */ -public class StatementFactoryUnitTests { +class StatementFactoryUnitTests { - CassandraConverter converter = new MappingCassandraConverter(); + private CassandraConverter converter = new MappingCassandraConverter(); - UpdateMapper updateMapper = new UpdateMapper(converter); + private UpdateMapper updateMapper = new UpdateMapper(converter); - StatementFactory statementFactory = new StatementFactory(updateMapper, updateMapper); + private StatementFactory statementFactory = new StatementFactory(updateMapper, updateMapper); - CassandraPersistentEntity groupEntity = converter.getMappingContext().getRequiredPersistentEntity(Group.class); - CassandraPersistentEntity personEntity = converter.getMappingContext().getRequiredPersistentEntity(Person.class); + private CassandraPersistentEntity groupEntity = converter.getMappingContext() + .getRequiredPersistentEntity(Group.class); + private CassandraPersistentEntity personEntity = converter.getMappingContext() + .getRequiredPersistentEntity(Person.class); @Test // DATACASS-343 - public void shouldMapSimpleSelectQuery() { + void shouldMapSimpleSelectQuery() { StatementBuilder