DATACASS-789 - Migrate tests to JUnit 5.

Use JUnit Jupiter annotations. Replace RunWith with JUnit Extensions. Replace CassandraRule with CassandraExtension to spin up embedded cassandra and to create keyspaces per test container.
This commit is contained in:
Mark Paluch
2020-07-27 15:32:09 +02:00
parent e9801aaf9a
commit 555b4da821
255 changed files with 3755 additions and 3738 deletions

View File

@@ -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() {

View File

@@ -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));
}
}

View File

@@ -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);

View File

@@ -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");

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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))

View File

@@ -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() {

View File

@@ -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();
}
}

View File

@@ -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 -> {

View File

@@ -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<String> expectedIds = new LinkedHashSet<>();

View File

@@ -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<SimpleStatement> 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<Boolean> 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<AsyncResultSet> {
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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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()));
}
}

View File

@@ -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<Class<?>> 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<Class<?>> 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;
}

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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<String> 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";

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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<SimpleStatement> 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();
}
}

View File

@@ -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() //

View File

@@ -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\""));

View File

@@ -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();

View File

@@ -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);

View File

@@ -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<Person> 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<Human> 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<Jedi> 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<PersonProjection> 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<PersonSpELProjection> 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<Person> 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();
}

View File

@@ -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"));

View File

@@ -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();

View File

@@ -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;

View File

@@ -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<WriteResult> 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<Group> 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();

View File

@@ -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));

View File

@@ -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<SimpleStatement> 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();
}
}

View File

@@ -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> 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> writeResult = this.template
.delete(Jedi.class).inTable("person")

View File

@@ -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<EntityWriteResult<Person>> 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);

View File

@@ -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;

View File

@@ -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<Person> 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<Human> 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<Jedi> 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<PersonProjection> 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<Person> 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<Jedi> 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<Human> 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<Jedi> 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<Person> 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<Person> 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<Person> 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<Person> 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<Person> 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<PersonProjection> result = this.template
.query(Person.class)
@@ -236,7 +236,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
}
@Test // DATACASS-485
public void findByReturningFirstAsOpenInterfaceProjection() {
void findByReturningFirstAsOpenInterfaceProjection() {
Mono<PersonSpELProjection> result = this.template
.query(Person.class)
@@ -251,7 +251,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
}
@Test // DATACASS-485
public void countShouldReturnNumberOfElementsInCollectionWhenNoQueryPresent() {
void countShouldReturnNumberOfElementsInCollectionWhenNoQueryPresent() {
Mono<Long> 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<Long> count = this.template
.query(Person.class)
@@ -270,7 +270,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
}
@Test // DATACASS-485
public void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() {
void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() {
Mono<Boolean> 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<Boolean> 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<Boolean> 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<Contact> 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();
}

View File

@@ -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> 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> writeResult = this.template.update(Jedi.class).inTable("person")
.matching(query(where("id").is(han.getId()))).apply(update("name", "Han"));

View File

@@ -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<Select> select = statementFactory.select(Query.empty(),
converter.getMappingContext().getRequiredPersistentEntity(Group.class));
@@ -74,7 +76,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-708
public void selectShouldApplyQueryOptions() {
void selectShouldApplyQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder() //
.executionProfile("foo") //
@@ -90,7 +92,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldMapSelectQueryWithColumnsAndCriteria() {
void shouldMapSelectQueryWithColumnsAndCriteria() {
Query query = Query.query(Criteria.where("foo").is("bar")).columns(Columns.from("age"));
@@ -100,7 +102,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-549
public void shouldMapSelectQueryNotEquals() {
void shouldMapSelectQueryNotEquals() {
Query query = Query.query(Criteria.where("foo").ne("bar")).columns(Columns.from("age"));
@@ -110,7 +112,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-549
public void shouldMapSelectQueryIsNotNull() {
void shouldMapSelectQueryIsNotNull() {
Query query = Query.query(Criteria.where("foo").isNotNull()).columns(Columns.from("age"));
@@ -121,7 +123,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldMapSelectQueryWithTtlColumns() {
void shouldMapSelectQueryWithTtlColumns() {
Query query = Query.empty().columns(Columns.empty().ttl("email"));
@@ -132,7 +134,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldMapSelectQueryWithSortLimitAndAllowFiltering() {
void shouldMapSelectQueryWithSortLimitAndAllowFiltering() {
Query query = Query.empty().sort(Sort.by("id.hashPrefix")).limit(10).withAllowFiltering();
@@ -144,7 +146,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldMapDeleteQueryWithColumns() {
void shouldMapDeleteQueryWithColumns() {
Query query = Query.empty().columns(Columns.from("age"));
@@ -155,7 +157,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldMapDeleteQueryWithTimestampColumns() {
void shouldMapDeleteQueryWithTimestampColumns() {
DeleteOptions options = DeleteOptions.builder().timestamp(1234).build();
Query query = Query.query(Criteria.where("foo").is("bar")).queryOptions(options);
@@ -168,7 +170,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-708
public void deleteShouldApplyQueryOptions() {
void deleteShouldApplyQueryOptions() {
Person person = new Person();
person.id = "foo";
@@ -187,7 +189,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateInsert() {
void shouldCreateInsert() {
Person person = new Person();
person.id = "foo";
@@ -198,7 +200,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-708
public void insertShouldApplyQueryOptions() {
void insertShouldApplyQueryOptions() {
Person person = new Person();
person.id = "foo";
@@ -216,7 +218,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateInsertIfNotExists() {
void shouldCreateInsertIfNotExists() {
InsertOptions options = InsertOptions.builder().withIfNotExists().build();
Person person = new Person();
@@ -229,7 +231,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetInsertNulls() {
void shouldCreateSetInsertNulls() {
InsertOptions options = InsertOptions.builder().withInsertNulls().build();
Person person = new Person();
@@ -242,7 +244,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetInsertWithTtl() {
void shouldCreateSetInsertWithTtl() {
WriteOptions options = WriteOptions.builder().ttl(Duration.ofMinutes(1)).build();
Person person = new Person();
@@ -255,7 +257,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetInsertWithTimestamp() {
void shouldCreateSetInsertWithTimestamp() {
WriteOptions options = WriteOptions.builder().timestamp(1234).build();
Person person = new Person();
@@ -268,7 +270,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSetUpdate() {
void shouldCreateSetUpdate() {
Query query = Query.query(Criteria.where("foo").is("bar"));
@@ -280,7 +282,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateWithTtl() {
void shouldCreateSetUpdateWithTtl() {
WriteOptions options = WriteOptions.builder().ttl(Duration.ofMinutes(1)).build();
Query query = Query.query(Criteria.where("foo").is("bar")).queryOptions(options);
@@ -293,7 +295,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateWithTimestamp() {
void shouldCreateSetUpdateWithTimestamp() {
WriteOptions options = WriteOptions.builder().timestamp(1234).build();
Query query = Query.query(Criteria.where("foo").is("bar")).queryOptions(options);
@@ -306,7 +308,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343, DATACASS-712
public void shouldCreateSetAtIndexUpdate() {
void shouldCreateSetAtIndexUpdate() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().set("list").atIndex(10).to("Euro"), personEntity);
@@ -315,7 +317,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSetAtKeyUpdate() {
void shouldCreateSetAtKeyUpdate() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().set("map").atKey("baz").to("Euro"), personEntity);
@@ -324,7 +326,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldAddToMap() {
void shouldAddToMap() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().addTo("map").entry("foo", "Euro"), personEntity);
@@ -333,7 +335,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldPrependAllToList() {
void shouldPrependAllToList() {
Update update = Update.empty().addTo("list").prependAll("foo", "Euro");
@@ -345,7 +347,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldAppendAllToList() {
void shouldAppendAllToList() {
Update update = Update.empty().addTo("list").appendAll("foo", "Euro");
@@ -357,7 +359,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldRemoveFromList() {
void shouldRemoveFromList() {
Update update = Update.empty().remove("list", "Euro");
@@ -369,7 +371,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldClearList() {
void shouldClearList() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().clear("list"), personEntity);
@@ -378,7 +380,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldAddAllToSet() {
void shouldAddAllToSet() {
Update update = Update.empty().addTo("set").appendAll("foo", "Euro");
@@ -390,7 +392,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldRemoveFromSet() {
void shouldRemoveFromSet() {
Update update = Update.empty().remove("set", "Euro");
@@ -402,7 +404,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldClearSet() {
void shouldClearSet() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().clear("set"), personEntity);
@@ -411,7 +413,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldCreateIncrementUpdate() {
void shouldCreateIncrementUpdate() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().increment("number"), personEntity);
@@ -420,7 +422,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-735
public void shouldCreateIncrementLongUpdate() {
void shouldCreateIncrementLongUpdate() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().increment("number", Long.MAX_VALUE), personEntity);
@@ -430,7 +432,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-343
public void shouldCreateDecrementUpdate() {
void shouldCreateDecrementUpdate() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().decrement("number"), personEntity);
@@ -439,7 +441,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-735
public void shouldCreateDecrementLongUpdate() {
void shouldCreateDecrementLongUpdate() {
StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update = statementFactory
.update(Query.empty(), Update.empty().decrement("number", Long.MAX_VALUE), personEntity);
@@ -449,7 +451,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-569
public void shouldCreateSetUpdateIfExists() {
void shouldCreateSetUpdateIfExists() {
Query query = Query.query(Criteria.where("foo").is("bar"))
.queryOptions(UpdateOptions.builder().withIfExists().build());
@@ -462,7 +464,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateIfCondition() {
void shouldCreateSetUpdateIfCondition() {
Query query = Query.query(Criteria.where("foo").is("bar"))
.queryOptions(UpdateOptions.builder().ifCondition(Criteria.where("foo").is("baz")).build());
@@ -475,7 +477,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-708
public void updateShouldApplyQueryOptions() {
void updateShouldApplyQueryOptions() {
UpdateOptions queryOptions = UpdateOptions.builder() //
.executionProfile("foo") //
@@ -493,7 +495,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateFromObject() {
void shouldCreateSetUpdateFromObject() {
Person person = new Person();
person.id = "foo";
@@ -507,7 +509,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateFromObjectIfExists() {
void shouldCreateSetUpdateFromObjectIfExists() {
UpdateOptions options = UpdateOptions.builder().withIfExists().build();
Person person = new Person();
@@ -521,7 +523,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateFromObjectIfCondition() {
void shouldCreateSetUpdateFromObjectIfCondition() {
UpdateOptions options = UpdateOptions.builder().ifCondition(Criteria.where("foo").is("bar")).build();
Person person = new Person();
@@ -535,7 +537,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateFromObjectWithTtl() {
void shouldCreateSetUpdateFromObjectWithTtl() {
WriteOptions options = WriteOptions.builder().ttl(Duration.ofMinutes(1)).build();
Person person = new Person();
@@ -548,7 +550,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateFromObjectWithTimestamp() {
void shouldCreateSetUpdateFromObjectWithTimestamp() {
WriteOptions options = WriteOptions.builder().timestamp(1234).build();
Person person = new Person();
@@ -561,7 +563,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-656
public void shouldCreateSetUpdateFromObjectWithEmptyCollections() {
void shouldCreateSetUpdateFromObjectWithEmptyCollections() {
Person person = new Person();
person.id = "foo";
@@ -576,7 +578,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-708
public void updateObjectShouldApplyQueryOptions() {
void updateObjectShouldApplyQueryOptions() {
WriteOptions queryOptions = WriteOptions.builder() //
.executionProfile("foo") //
@@ -597,7 +599,7 @@ public class StatementFactoryUnitTests {
}
@Test // DATACASS-512
public void shouldCreateCountQuery() {
void shouldCreateCountQuery() {
Query query = Query.query(Criteria.where("foo").is("bar"));
@@ -611,16 +613,16 @@ public class StatementFactoryUnitTests {
@SuppressWarnings("unused")
static class Person {
@Id String id;
@Id private String id;
Integer number;
List<String> list;
private List<String> list;
Map<String, String> map;
@Column("set_col") Set<String> set;
@Column("set_col") private Set<String> set;
@Column("first_name") String firstName;
@Column("first_name") private String firstName;
}
}

View File

@@ -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;
@@ -32,10 +32,10 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
* @author Mark Paluch
* @author Lukasz Antoniak
*/
public class UpdateOptionsUnitTests {
class UpdateOptionsUnitTests {
@Test // DATACASS-250, DATACASS-155, DATACASS-708
public void shouldConfigureUpdateOptions() {
void shouldConfigureUpdateOptions() {
Instant now = Instant.ofEpochSecond(1234);
@@ -54,7 +54,7 @@ public class UpdateOptionsUnitTests {
}
@Test // DATACASS-56, DATACASS-155
public void buildUpdateOptionsMutate() {
void buildUpdateOptionsMutate() {
UpdateOptions updateOptions = UpdateOptions.builder() //
.ttl(10) //
@@ -76,7 +76,7 @@ public class UpdateOptionsUnitTests {
}
@Test // DATACASS-575
public void shouldApplyFilterCondition() {
void shouldApplyFilterCondition() {
UpdateOptions updateOptions = UpdateOptions.builder() //
.withIfExists() //

View File

@@ -15,11 +15,11 @@
*/
package org.springframework.data.cassandra.core.convert;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import org.joda.time.LocalTime;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.convert.CassandraJodaTimeConverters.LocalTimeToMillisOfDayConverter;
import org.springframework.data.cassandra.core.convert.CassandraJodaTimeConverters.MillisOfDayToLocalTimeConverter;
@@ -28,17 +28,17 @@ import org.springframework.data.cassandra.core.convert.CassandraJodaTimeConverte
*
* @author Mark Paluch
*/
public class CassandraJodaTimeConvertersUnitTests {
class CassandraJodaTimeConvertersUnitTests {
@Test // DATACASS-302
public void shouldConvertLongToLocalTime() {
void shouldConvertLongToLocalTime() {
assertThat(MillisOfDayToLocalTimeConverter.INSTANCE.convert(3723000L))
.isEqualTo(LocalTime.fromMillisOfDay(3723000L));
}
@Test // DATACASS-302
public void shouldConvertLocalTimeToLong() {
void shouldConvertLocalTimeToLong() {
assertThat(LocalTimeToMillisOfDayConverter.INSTANCE.convert(LocalTime.MIDNIGHT)).isZero();
assertThat(LocalTimeToMillisOfDayConverter.INSTANCE.convert(LocalTime.fromMillisOfDay(3723000L)))

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import java.time.LocalTime;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.convert.CassandraJsr310Converters.LocalTimeToMillisOfDayConverter;
import org.springframework.data.cassandra.core.convert.CassandraJsr310Converters.MillisOfDayToLocalTimeConverter;
@@ -30,16 +30,16 @@ import org.springframework.data.cassandra.core.convert.CassandraJsr310Converters
* @author Mark Paluch
* @author Hurelhuyag
*/
public class CassandraJsr310ConvertersUnitTests {
class CassandraJsr310ConvertersUnitTests {
@Test // DATACASS-302, DATACASS-694
public void shouldConvertLongToLocalTime() {
void shouldConvertLongToLocalTime() {
assertThat(MillisOfDayToLocalTimeConverter.INSTANCE.convert(3_723_000_000_000L)).isEqualTo(LocalTime.of(1, 2, 3));
}
@Test // DATACASS-302, DATACASS-694
public void shouldConvertLocalTimeToLong() {
void shouldConvertLocalTimeToLong() {
assertThat(LocalTimeToMillisOfDayConverter.INSTANCE.convert(LocalTime.MIDNIGHT)).isZero();
assertThat(LocalTimeToMillisOfDayConverter.INSTANCE.convert(LocalTime.of(1, 2, 3))).isEqualTo(3_723_000_000_000L);

View File

@@ -15,30 +15,31 @@
*/
package org.springframework.data.cassandra.core.convert;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.threeten.bp.LocalTime;
import org.springframework.data.cassandra.core.convert.CassandraThreeTenBackPortConverters.LocalTimeToMillisOfDayConverter;
import org.springframework.data.cassandra.core.convert.CassandraThreeTenBackPortConverters.MillisOfDayToLocalTimeConverter;
import org.threeten.bp.LocalTime;
/**
* Unit tests for {@link CassandraThreeTenBackPortConverters}.
*
* @author Mark Paluch
*/
public class CassandraThreeTenBackPortConvertersUnitTests {
class CassandraThreeTenBackPortConvertersUnitTests {
@Test // DATACASS-302
public void shouldConvertLongToLocalTime() {
void shouldConvertLongToLocalTime() {
assertThat(MillisOfDayToLocalTimeConverter.INSTANCE.convert(3723000L))
.isEqualTo(LocalTime.of(1, 2, 3));
}
@Test // DATACASS-302
public void shouldConvertLocalTimeToLong() {
void shouldConvertLocalTimeToLong() {
assertThat(LocalTimeToMillisOfDayConverter.INSTANCE.convert(LocalTime.MIDNIGHT)).isZero();
assertThat(LocalTimeToMillisOfDayConverter.INSTANCE.convert(LocalTime.of(1, 2, 3)))

View File

@@ -39,9 +39,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import org.junit.Before;
import org.junit.Ignore;
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.CassandraOperations;
@@ -49,7 +48,7 @@ import org.springframework.data.cassandra.core.CassandraTemplate;
import org.springframework.data.cassandra.domain.AllPossibleTypes;
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.util.Version;
import com.datastax.oss.driver.api.core.cql.ResultSet;
@@ -68,16 +67,16 @@ import com.datastax.oss.driver.api.core.type.TupleType;
* @soundtrack DJ THT meets Scarlet - Live 2 Dance (Extended Mix) (Zgin Remix)
*/
@SuppressWarnings("Since15")
public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
static final Version VERSION_3_10 = Version.parse("3.10");
static boolean initialized = false;
private static final Version VERSION_3_10 = Version.parse("3.10");
private static boolean initialized = false;
CassandraOperations operations;
Version cassandraVersion;
private CassandraOperations operations;
private Version cassandraVersion;
@Before
public void before() {
@BeforeEach
void before() {
operations = new CassandraTemplate(session);
cassandraVersion = CassandraVersion.get(session);
@@ -104,7 +103,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteInetAddress() throws Exception {
void shouldReadAndWriteInetAddress() throws Exception {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setInet(InetAddress.getByName("127.0.0.1"));
@@ -116,7 +115,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteUUID() {
void shouldReadAndWriteUUID() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setUuid(UUID.randomUUID());
@@ -128,7 +127,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBoxedShort() {
void shouldReadAndWriteBoxedShort() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedShort(Short.MAX_VALUE);
@@ -140,7 +139,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWritePrimitiveShort() {
void shouldReadAndWritePrimitiveShort() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveShort(Short.MAX_VALUE);
@@ -152,7 +151,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-271
public void shouldReadAndWriteBoxedByte() {
void shouldReadAndWriteBoxedByte() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedByte(Byte.MAX_VALUE);
@@ -164,7 +163,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-271
public void shouldReadAndWritePrimitiveByte() {
void shouldReadAndWritePrimitiveByte() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveByte(Byte.MAX_VALUE);
@@ -176,7 +175,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBoxedLong() {
void shouldReadAndWriteBoxedLong() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedLong(Long.MAX_VALUE);
@@ -188,7 +187,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWritePrimitiveLong() {
void shouldReadAndWritePrimitiveLong() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveLong(Long.MAX_VALUE);
@@ -200,7 +199,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBoxedInteger() {
void shouldReadAndWriteBoxedInteger() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedInteger(Integer.MAX_VALUE);
@@ -212,7 +211,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWritePrimitiveInteger() {
void shouldReadAndWritePrimitiveInteger() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveInteger(Integer.MAX_VALUE);
@@ -224,7 +223,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBoxedFloat() {
void shouldReadAndWriteBoxedFloat() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedFloat(Float.MAX_VALUE);
@@ -236,7 +235,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWritePrimitiveFloat() {
void shouldReadAndWritePrimitiveFloat() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveFloat(Float.MAX_VALUE);
@@ -248,7 +247,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBoxedDouble() {
void shouldReadAndWriteBoxedDouble() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedDouble(Double.MAX_VALUE);
@@ -260,7 +259,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWritePrimitiveDouble() {
void shouldReadAndWritePrimitiveDouble() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveDouble(Double.MAX_VALUE);
@@ -272,7 +271,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBoxedBoolean() {
void shouldReadAndWriteBoxedBoolean() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBoxedBoolean(Boolean.TRUE);
@@ -284,7 +283,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWritePrimitiveBoolean() {
void shouldReadAndWritePrimitiveBoolean() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setPrimitiveBoolean(Boolean.TRUE);
@@ -296,7 +295,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280, DATACASS-271
public void shouldReadAndWriteTimestamp() {
void shouldReadAndWriteTimestamp() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setTimestamp(new Date(1));
@@ -308,7 +307,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-271
public void shouldReadAndWriteDate() {
void shouldReadAndWriteDate() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setDate(LocalDate.ofEpochDay(1));
@@ -320,7 +319,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBigInteger() {
void shouldReadAndWriteBigInteger() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBigInteger(new BigInteger("123456"));
@@ -332,7 +331,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBigDecimal() {
void shouldReadAndWriteBigDecimal() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBigDecimal(new BigDecimal("123456.7890123"));
@@ -344,7 +343,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteBlob() {
void shouldReadAndWriteBlob() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setBlob(ByteBuffer.wrap("Hello".getBytes()));
@@ -359,7 +358,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteSetOfString() {
void shouldReadAndWriteSetOfString() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setSetOfString(Collections.singleton("hello"));
@@ -371,7 +370,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteEmptySetOfString() {
void shouldReadAndWriteEmptySetOfString() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setSetOfString(new HashSet<>());
@@ -383,7 +382,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteListOfString() {
void shouldReadAndWriteListOfString() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setListOfString(Collections.singletonList("hello"));
@@ -395,7 +394,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteEmptyListOfString() {
void shouldReadAndWriteEmptyListOfString() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setListOfString(new ArrayList<>());
@@ -407,7 +406,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteMapOfString() {
void shouldReadAndWriteMapOfString() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setMapOfString(Collections.singletonMap("hello", "world"));
@@ -419,7 +418,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteEmptyMapOfString() {
void shouldReadAndWriteEmptyMapOfString() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setMapOfString(new HashMap<>());
@@ -431,7 +430,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteEnum() {
void shouldReadAndWriteEnum() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setAnEnum(Condition.MINT);
@@ -443,7 +442,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteListOfEnum() {
void shouldReadAndWriteListOfEnum() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setListOfEnum(Collections.singletonList(Condition.MINT));
@@ -455,7 +454,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-280
public void shouldReadAndWriteSetOfEnum() {
void shouldReadAndWriteSetOfEnum() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setSetOfEnum(Collections.singleton(Condition.MINT));
@@ -467,7 +466,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-284
public void shouldReadAndWriteTupleType() {
void shouldReadAndWriteTupleType() {
TupleType tupleType = DataTypes.tupleOf(DataTypes.TEXT, DataTypes.BIGINT);
@@ -484,7 +483,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-284
public void shouldReadAndWriteListOfTuples() {
void shouldReadAndWriteListOfTuples() {
TupleType tupleType = DataTypes.tupleOf(DataTypes.TEXT, DataTypes.BIGINT);
@@ -502,7 +501,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-271
public void shouldReadAndWriteTime() {
void shouldReadAndWriteTime() {
// writing of time is not supported with Insert/Update statements as they mix up types.
// The only way to insert a time right now seems a PreparedStatement
@@ -518,7 +517,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteLocalDate() {
void shouldReadAndWriteLocalDate() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -532,7 +531,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteLocalDateTime() {
void shouldReadAndWriteLocalDateTime() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -546,7 +545,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296, DATACASS-563
public void shouldReadAndWriteLocalTime() {
void shouldReadAndWriteLocalTime() {
assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(VERSION_3_10));
@@ -562,7 +561,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-694, DATACASS-727
public void shouldReadLocalTimeFromDriver() {
void shouldReadLocalTimeFromDriver() {
assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(VERSION_3_10));
@@ -578,7 +577,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-694, DATACASS-727
public void shouldWriteLocalTimeThroughDriver() {
void shouldWriteLocalTimeThroughDriver() {
assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(VERSION_3_10));
@@ -591,7 +590,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296, DATACASS-563
public void shouldReadAndWriteJodaLocalTime() {
void shouldReadAndWriteJodaLocalTime() {
assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(VERSION_3_10));
@@ -607,7 +606,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteInstant() {
void shouldReadAndWriteInstant() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -622,7 +621,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteZoneId() {
void shouldReadAndWriteZoneId() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -636,7 +635,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteJodaLocalDate() {
void shouldReadAndWriteJodaLocalDate() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -650,7 +649,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296, DATACASS-727
public void shouldReadAndWriteJodaDateTime() {
void shouldReadAndWriteJodaDateTime() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -664,7 +663,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteBpLocalDate() {
void shouldReadAndWriteBpLocalDate() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -678,7 +677,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteBpLocalDateTime() {
void shouldReadAndWriteBpLocalDateTime() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -692,7 +691,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296, DATACASS-563
public void shouldReadAndWriteBpLocalTime() {
void shouldReadAndWriteBpLocalTime() {
assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(VERSION_3_10));
@@ -708,7 +707,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296, DATACASS-727
public void shouldReadAndWriteBpInstant() {
void shouldReadAndWriteBpInstant() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -722,7 +721,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
}
@Test // DATACASS-296
public void shouldReadAndWriteBpZoneId() {
void shouldReadAndWriteBpZoneId() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -735,23 +734,8 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
assertThat(loaded.getBpZoneId()).isEqualTo(entity.getBpZoneId());
}
@Test // DATACASS-285
@Ignore("Counter columns are not supported with Spring Data Cassandra as the value of counter columns can only be incremented/decremented, not set")
public void shouldReadAndWriteCounter() {
CounterEntity entity = new CounterEntity("1");
entity.setCount(1);
operations.update(entity);
CounterEntity loaded = operations.selectOneById(entity.getId(), CounterEntity.class);
assertThat(loaded.getCount()).isEqualTo(entity.getCount());
}
@Test // DATACASS-429, DATACASS-727
public void shouldReadAndWriteDuration() {
void shouldReadAndWriteDuration() {
assumeTrue(cassandraVersion.isGreaterThanOrEqualTo(VERSION_3_10));

View File

@@ -24,7 +24,7 @@ import java.util.Set;
import java.util.UUID;
import org.assertj.core.api.SoftAssertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentEntity;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.core.mapping.CassandraPersistentProperty;
@@ -50,13 +50,13 @@ import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry;
*/
public class ColumnTypeResolverUnitTests {
CassandraMappingContext mappingContext = new CassandraMappingContext();
ColumnTypeResolver resolver = new DefaultColumnTypeResolver(mappingContext,
private CassandraMappingContext mappingContext = new CassandraMappingContext();
private ColumnTypeResolver resolver = new DefaultColumnTypeResolver(mappingContext,
SchemaFactory.ShallowUserTypeResolver.INSTANCE, () -> CodecRegistry.DEFAULT,
mappingContext::getCustomConversions);
@Test // DATACASS-743
public void shouldResolveSimpleType() {
void shouldResolveSimpleType() {
assertThat(resolver.resolve("foo").getType()).isEqualTo(String.class);
assertThat(resolver.resolve(ClassTypeInformation.from(String.class)).getType()).isEqualTo(String.class);
@@ -69,7 +69,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveEnumType() {
void shouldResolveEnumType() {
assertThat(resolver.resolve(MyEnum.INSTANCE).getType()).isEqualTo(String.class);
assertThat(resolver.resolve(ClassTypeInformation.from(MyEnum.class)).getType()).isEqualTo(String.class);
@@ -84,7 +84,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderCassandraType() {
void shouldConsiderCassandraType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -94,7 +94,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveSimpleListType() {
void shouldResolveSimpleListType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -104,7 +104,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveListOfEnumType() {
void shouldResolveListOfEnumType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -114,7 +114,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderListWithCassandraType() {
void shouldConsiderListWithCassandraType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -124,7 +124,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveSimpleSetType() {
void shouldResolveSimpleSetType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -134,7 +134,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveSetOfEnumType() {
void shouldResolveSetOfEnumType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -145,7 +145,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderSetWithCassandraType() {
void shouldConsiderSetWithCassandraType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -155,7 +155,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveSimpleMapType() {
void shouldResolveSimpleMapType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -165,7 +165,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldResolveMapOfEnumType() {
void shouldResolveMapOfEnumType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -176,7 +176,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderMapWithCassandraType() {
void shouldConsiderMapWithCassandraType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -186,7 +186,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-743
public void shouldReportEmptyTupleType() {
void shouldReportEmptyTupleType() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -197,7 +197,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-375, DATACASS-743
public void UuidshouldMapToUUIDByDefault() {
void UuidshouldMapToUUIDByDefault() {
CassandraPersistentProperty uuidProperty = mappingContext.getRequiredPersistentEntity(TypeWithUUIDColumn.class)
.getRequiredPersistentProperty("uuid");
@@ -209,7 +209,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-465
public void listPropertyWithFrozenAnnotation() {
void listPropertyWithFrozenAnnotation() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -219,7 +219,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-465
public void listPropertyWithFrozenAnnotationOnElement() {
void listPropertyWithFrozenAnnotationOnElement() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -235,7 +235,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-465
public void setPropertyWithFrozenAnnotation() {
void setPropertyWithFrozenAnnotation() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -245,7 +245,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-465
public void setPropertyWithFrozenAnnotationOnElement() {
void setPropertyWithFrozenAnnotationOnElement() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -261,7 +261,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-465
public void mapPropertyWithFrozenAnnotationOnKey() {
void mapPropertyWithFrozenAnnotationOnKey() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -286,7 +286,7 @@ public class ColumnTypeResolverUnitTests {
}
@Test // DATACASS-465
public void mapPropertyWithFrozenAnnotationOnValue() {
void mapPropertyWithFrozenAnnotationOnValue() {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
@@ -356,7 +356,7 @@ public class ColumnTypeResolverUnitTests {
}
}
static class TypeWithUUIDColumn {
private static class TypeWithUUIDColumn {
UUID uuid;

View File

@@ -29,8 +29,8 @@ import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.annotation.Id;
@@ -38,7 +38,7 @@ import org.springframework.data.cassandra.core.CassandraTemplate;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
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;
import org.springframework.data.convert.CustomConversions;
import org.springframework.util.StringUtils;
@@ -51,12 +51,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*
* @author Mark Paluch
*/
public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
CassandraTemplate cassandraOperations;
private CassandraTemplate cassandraOperations;
@Before
public void setUp() {
@BeforeEach
void setUp() {
MappingCassandraConverter converter = createConverter();
cassandraOperations = new CassandraTemplate(session, converter);
@@ -66,7 +66,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-296
public void shouldInsertCustomConvertedObject() {
void shouldInsertCustomConvertedObject() {
Employee employee = new Employee();
employee.setId("employee-id");
@@ -81,7 +81,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-296
public void shouldUpdateCustomConvertedObject() {
void shouldUpdateCustomConvertedObject() {
Employee employee = new Employee();
employee.setId("employee-id");
@@ -98,7 +98,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-296
public void shouldInsertCustomConvertedObjectWithCollections() {
void shouldInsertCustomConvertedObjectWithCollections() {
Employee employee = new Employee();
employee.setId("employee-id");
@@ -118,7 +118,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-296
public void shouldUpdateCustomConvertedObjectWithCollections() {
void shouldUpdateCustomConvertedObjectWithCollections() {
Employee employee = new Employee();
employee.setId("employee-id");
@@ -137,7 +137,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-296
public void shouldLoadCustomConvertedObject() {
void shouldLoadCustomConvertedObject() {
cassandraOperations.getCqlOperations().execute(
"INSERT INTO employee (id, person) VALUES('employee-id', '{\"firstname\":\"Homer\",\"lastname\":\"Simpson\"}')");
@@ -151,7 +151,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-296
public void shouldLoadCustomConvertedWithCollectionsObject() {
void shouldLoadCustomConvertedWithCollectionsObject() {
cassandraOperations.getCqlOperations().execute(
"INSERT INTO employee (id, people) VALUES('employee-id', {'{\"firstname\":\"Apu\",\"lastname\":\"Nahasapeemapetilon\"}'})");
@@ -165,7 +165,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-607
public void shouldApplyCustomReadConverterIfOnlyReadIsCustomized() {
void shouldApplyCustomReadConverterIfOnlyReadIsCustomized() {
MappingCassandraConverter converter = createConverter(converters -> {
converters.add(new PersonReadConverter());
@@ -234,7 +234,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
/**
* @author Mark Paluch
*/
static class PersonReadConverter implements Converter<String, Person> {
private static class PersonReadConverter implements Converter<String, Person> {
public Person convert(String source) {
@@ -253,7 +253,7 @@ public class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIn
/**
* @author Mark Paluch
*/
static class PersonWriteConverter implements Converter<Person, String> {
private static class PersonWriteConverter implements Converter<Person, String> {
public String convert(Person source) {

View File

@@ -21,8 +21,8 @@ import static org.junit.Assume.*;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.cassandra.core.cql.generator.CreateIndexCqlGenerator;
@@ -35,7 +35,7 @@ import org.springframework.data.cassandra.core.mapping.Indexed;
import org.springframework.data.cassandra.core.mapping.SASI;
import org.springframework.data.cassandra.core.mapping.SASI.StandardAnalyzed;
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.util.Version;
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -47,14 +47,14 @@ import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
*
* @author Mark Paluch
*/
public class IndexCreationIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class IndexCreationIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
private CassandraMappingContext mappingContext = new CassandraMappingContext();
private SchemaFactory schemaFactory = new SchemaFactory(new MappingCassandraConverter(mappingContext));
private Version cassandraVersion;
@Before
public void before() {
@BeforeEach
void before() {
cassandraVersion = CassandraVersion.get(session);
@@ -62,7 +62,7 @@ public class IndexCreationIntegrationTests extends AbstractKeyspaceCreatingInteg
}
@Test
public void shouldCreateSecondaryIndex() throws InterruptedException {
void shouldCreateSecondaryIndex() throws InterruptedException {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(WithSecondaryIndex.class);
CreateTableSpecification createTable = schemaFactory.getCreateTableSpecificationFor(entity);
@@ -80,7 +80,7 @@ public class IndexCreationIntegrationTests extends AbstractKeyspaceCreatingInteg
}
@Test
public void shouldCreateSasiIndex() throws InterruptedException {
void shouldCreateSasiIndex() throws InterruptedException {
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(WithSasiIndex.class);
CreateTableSpecification createTable = schemaFactory.getCreateTableSpecificationFor(entity);
@@ -100,7 +100,7 @@ public class IndexCreationIntegrationTests extends AbstractKeyspaceCreatingInteg
return session.refreshSchema().getKeyspace(session.getKeyspace().get()).flatMap(it -> it.getTable(tableName)).get();
}
static class WithSecondaryIndex {
private static class WithSecondaryIndex {
@Id String id;
@@ -109,7 +109,7 @@ public class IndexCreationIntegrationTests extends AbstractKeyspaceCreatingInteg
Map<String, @Indexed String> map;
}
static class WithSasiIndex {
private static class WithSasiIndex {
@Id String id;

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.annotation.AccessType;
import org.springframework.data.annotation.AccessType.Type;
@@ -42,12 +42,12 @@ import com.datastax.oss.driver.api.core.CqlIdentifier;
*
* @author Mark Paluch
*/
public class IndexSpecificationFactoryUnitTests {
class IndexSpecificationFactoryUnitTests {
CassandraMappingContext mappingContext = new CassandraMappingContext();
private CassandraMappingContext mappingContext = new CassandraMappingContext();
@Test // DATACASS-213
public void createIndexShouldConsiderAnnotatedProperties() {
void createIndexShouldConsiderAnnotatedProperties() {
CreateIndexSpecification firstname = createIndexFor(IndexedType.class, "firstname");
@@ -65,7 +65,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-213
public void createMapKeyIndexShouldConsiderAnnotatedAccessors() {
void createMapKeyIndexShouldConsiderAnnotatedAccessors() {
CreateIndexSpecification entries = createIndexFor(IndexedMapKeyProperty.class, "entries");
@@ -76,7 +76,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-213
public void createMapValueIndexShouldConsiderAnnotatedAccessors() {
void createMapValueIndexShouldConsiderAnnotatedAccessors() {
CreateIndexSpecification entries = createIndexFor(MapValueIndexProperty.class, "entries");
@@ -87,7 +87,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-306
public void createIndexForSimpleSasiShouldApplyIndexOptions() {
void createIndexForSimpleSasiShouldApplyIndexOptions() {
CreateIndexSpecification simpleSasi = createIndexFor(IndexedType.class, "simpleSasi");
@@ -101,7 +101,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-306
public void createIndexForStandardAnalyzedSasiShouldApplyIndexOptions() {
void createIndexForStandardAnalyzedSasiShouldApplyIndexOptions() {
CreateIndexSpecification simpleSasi = createIndexFor(IndexedType.class, "sasiStandard");
@@ -113,7 +113,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-306
public void createIndexForStandardAnalyzedSasiWithOptionsShouldApplyIndexOptions() {
void createIndexForStandardAnalyzedSasiWithOptionsShouldApplyIndexOptions() {
CreateIndexSpecification simpleSasi = createIndexFor(IndexedType.class, "sasiStandardWithOptions");
@@ -125,7 +125,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-306
public void createIndexForStandardAnalyzedSasiWithLowercaseShouldApplyIndexOptions() {
void createIndexForStandardAnalyzedSasiWithLowercaseShouldApplyIndexOptions() {
CreateIndexSpecification simpleSasi = createIndexFor(IndexedType.class, "sasiStandardLowercase");
@@ -135,7 +135,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-306
public void createIndexForNonTokenizingAnalyzedSasiShouldApplyIndexOptions() {
void createIndexForNonTokenizingAnalyzedSasiShouldApplyIndexOptions() {
CreateIndexSpecification simpleSasi = createIndexFor(IndexedType.class, "sasiNontokenizing");
@@ -146,7 +146,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@Test // DATACASS-306
public void createIndexForNonTokenizingAnalyzedSasiWithLowercaseShouldApplyIndexOptions() {
void createIndexForNonTokenizingAnalyzedSasiWithLowercaseShouldApplyIndexOptions() {
CreateIndexSpecification simpleSasi = createIndexFor(IndexedType.class, "sasiNontokenizingLowercase");
@@ -164,7 +164,7 @@ public class IndexSpecificationFactoryUnitTests {
return mappingContext.getRequiredPersistentEntity(type).getRequiredPersistentProperty(property);
}
static class IndexedType {
private static class IndexedType {
@PrimaryKeyColumn("first_name") @Indexed("my_index") String firstname;
@@ -190,7 +190,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@AccessType(Type.PROPERTY)
static class IndexedMapKeyProperty {
private static class IndexedMapKeyProperty {
public Map<@Indexed String, String> getEntries() {
return null;
@@ -200,7 +200,7 @@ public class IndexSpecificationFactoryUnitTests {
}
@AccessType(Type.PROPERTY)
static class MapValueIndexProperty {
private static class MapValueIndexProperty {
public Map<String, String> getEntries() {
return null;

View File

@@ -24,10 +24,13 @@ import lombok.Data;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentEntity;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.core.mapping.Element;
@@ -45,17 +48,18 @@ import com.datastax.oss.driver.api.core.type.TupleType;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.Silent.class)
public class MappingCassandraConverterMappedTupleUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class MappingCassandraConverterMappedTupleUnitTests {
CassandraMappingContext mappingContext;
private CassandraMappingContext mappingContext;
MappingCassandraConverter mappingCassandraConverter;
private MappingCassandraConverter mappingCassandraConverter;
Row rowMock;
private Row rowMock;
@Before
public void setUp() {
@BeforeEach
void setUp() {
this.mappingContext = new CassandraMappingContext();
this.mappingCassandraConverter = new MappingCassandraConverter(mappingContext);
@@ -63,7 +67,7 @@ public class MappingCassandraConverterMappedTupleUnitTests {
}
@Test // DATACASS-523
public void shouldReadMappedTupleValue() {
void shouldReadMappedTupleValue() {
BasicCassandraPersistentEntity<?> entity = this.mappingContext.getRequiredPersistentEntity(MappedTuple.class);
@@ -86,7 +90,7 @@ public class MappingCassandraConverterMappedTupleUnitTests {
}
@Test // DATACASS-523
public void shouldWriteMappedTuple() {
void shouldWriteMappedTuple() {
MappedTuple tuple = new MappedTuple("hello", 1);
Person person = new Person("Jon Doe", tuple);

View File

@@ -26,9 +26,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -50,8 +49,7 @@ import org.springframework.data.cassandra.core.mapping.UserDefinedType;
import org.springframework.data.cassandra.domain.AllPossibleTypes;
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.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.ResultSet;
@@ -66,8 +64,7 @@ import com.datastax.oss.driver.api.querybuilder.insert.RegularInsert;
*
* @author Mark Paluch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
private static AtomicBoolean initialized = new AtomicBoolean();
@@ -95,8 +92,8 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
@Autowired MappingCassandraConverter converter;
@Autowired CqlSession session;
@Before
public void setUp() {
@BeforeEach
void setUp() {
if (initialized.compareAndSet(false, true)) {
@@ -125,7 +122,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
}
@Test // DATACASS-651
public void shouldInsertRowWithTuple() {
void shouldInsertRowWithTuple() {
TupleType tupleType = DataTypes.tupleOf(DataTypes.TEXT, DataTypes.INT);
@@ -147,7 +144,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
}
@Test // DATACASS-523
public void shouldInsertRowWithComplexTuple() {
void shouldInsertRowWithComplexTuple() {
Person person = new Person();
@@ -174,7 +171,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
}
@Test // DATACASS-523
public void shouldReadRowWithComplexTuple() {
void shouldReadRowWithComplexTuple() {
this.session.execute("INSERT INTO person (id,mappedtuple,mappedtuples) VALUES (" + "'foo'," //
+ "({zip:'myzip'},['EUR','USD'],'bar')," //
@@ -196,7 +193,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
}
@Test // DATACASS-651
public void shouldInsertRowWithTupleMap() {
void shouldInsertRowWithTupleMap() {
Person person = new Person();
person.setId("foo");
@@ -224,7 +221,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
}
@Test // DATACASS-651
public void shouldReadRowWithMapOfTuples() {
void shouldReadRowWithMapOfTuples() {
this.session.execute("INSERT INTO person (id,mapoftuples,mapoftuplevalues) VALUES "
+ "('foo',{'foo':(NULL,['EUR','USD'],'bar')},{'mykey':('hello',42)});\n");
@@ -242,7 +239,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
}
@Test // DATACASS-741
public void shouldReadTupleWithValue() {
void shouldReadTupleWithValue() {
this.session.execute("INSERT INTO person (id,mappedtuplewithvalue) VALUES (" + "'foo'," //
+ "({zip:'myzip'},['EUR','USD'],'bar'));\n");
@@ -281,9 +278,9 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
@Tuple
static class MappedTupleWithValue {
final @Element(0) AddressUserType addressUserType;
final @Element(1) List<Currency> currency;
final @Transient String myName;
private final @Element(0) AddressUserType addressUserType;
private final @Element(1) List<Currency> currency;
private final @Transient String myName;
public MappedTupleWithValue(AddressUserType addressUserType, List<Currency> currency,
@Value("#root.getString(2)") String myName) {

View File

@@ -28,9 +28,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@@ -47,8 +46,7 @@ import org.springframework.data.cassandra.core.mapping.UserTypeResolver;
import org.springframework.data.cassandra.domain.AllPossibleTypes;
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.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
@@ -61,8 +59,7 @@ import com.datastax.oss.driver.api.core.data.UdtValue;
*
* @author Mark Paluch
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
private static AtomicBoolean initialized = new AtomicBoolean();
@@ -90,8 +87,8 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
@Autowired CqlSession session;
@Autowired MappingCassandraConverter converter;
@Before
public void setUp() {
@BeforeEach
void setUp() {
if (initialized.compareAndSet(false, true)) {
@@ -129,7 +126,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldReadMappedUdt() {
void shouldReadMappedUdt() {
session.execute("INSERT INTO addressbook (id, currentaddress) " + "VALUES ('1', "
+ "{zip:'69469', city: 'Weinheim', streetlines: ['Heckenpfad', '14']})");
@@ -146,7 +143,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldWriteMappedUdt() {
void shouldWriteMappedUdt() {
AddressUserType addressUserType = new AddressUserType();
addressUserType.setZip("69469");
@@ -164,7 +161,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldReadMappedUdtCollection() {
void shouldReadMappedUdtCollection() {
session.execute("INSERT INTO addressbook (id, previousaddresses) " + "VALUES ('1', "
+ " [{zip:'53773', city: 'Bonn'}, {zip:'12345', city: 'Bonn'}])");
@@ -182,7 +179,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldWriteMappedUdtCollection() {
void shouldWriteMappedUdtCollection() {
AddressUserType addressUserType = new AddressUserType();
addressUserType.setZip("69469");
@@ -200,7 +197,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldReadUdt() {
void shouldReadUdt() {
session.execute("INSERT INTO addressbook (id, alternate) " + "VALUES ('1', "
+ "{zip:'69469', city: 'Weinheim', streetlines: ['Heckenpfad', '14']})");
@@ -214,7 +211,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldWriteUdt() {
void shouldWriteUdt() {
CassandraPersistentEntity<?> persistentEntity = converter.getMappingContext()
.getRequiredPersistentEntity(AddressUserType.class);
@@ -236,7 +233,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldWriteUdtPk() {
void shouldWriteUdtPk() {
AddressUserType addressUserType = new AddressUserType();
addressUserType.setZip("69469");
@@ -253,7 +250,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldWriteMappedUdtPk() {
void shouldWriteMappedUdtPk() {
CassandraPersistentEntity<?> persistentEntity = converter.getMappingContext()
.getRequiredPersistentEntity(AddressUserType.class);
@@ -276,7 +273,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldReadUdtWithCustomConversion() {
void shouldReadUdtWithCustomConversion() {
session.execute("INSERT INTO bank (id, currency) " + "VALUES ('1', {currency:'EUR'})");
@@ -288,7 +285,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldReadUdtListWithCustomConversion() {
void shouldReadUdtListWithCustomConversion() {
session.execute("INSERT INTO bank (id, othercurrencies) " + "VALUES ('1', [{currency:'EUR'}])");
@@ -299,7 +296,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172, DATACASS-400
public void shouldWriteUdtWithCustomConversion() {
void shouldWriteUdtWithCustomConversion() {
Bank bank = new Bank(null, Currency.getInstance("EUR"), null);
@@ -309,7 +306,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldWriteUdtWhereWherePrimaryKeyWithCustomConversion() {
void shouldWriteUdtWhereWherePrimaryKeyWithCustomConversion() {
Money money = new Money();
money.setCurrency(Currency.getInstance("EUR"));
@@ -323,7 +320,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172, DATACASS-400
public void shouldWriteUdtUpdateAssignmentsWithCustomConversion() {
void shouldWriteUdtUpdateAssignmentsWithCustomConversion() {
MoneyTransfer money = new MoneyTransfer("1", Currency.getInstance("EUR"));
@@ -333,7 +330,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172, DATACASS-400
public void shouldWriteUdtListWithCustomConversion() {
void shouldWriteUdtListWithCustomConversion() {
Bank bank = new Bank(null, null, Collections.singletonList(Currency.getInstance("EUR")));
@@ -343,7 +340,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172
public void shouldReadNestedUdt() {
void shouldReadNestedUdt() {
session.execute("INSERT INTO car (id, engine) VALUES ('1', {manufacturer: {name:'a good one'}})");
@@ -356,7 +353,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-172, DATACASS-400
public void shouldWriteNestedUdt() {
void shouldWriteNestedUdt() {
Engine engine = new Engine(new Manufacturer("a good one"));
@@ -369,7 +366,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
@Test // DATACASS-487
public void shouldReadUdtInMap() {
void shouldReadUdtInMap() {
this.session.execute("INSERT INTO supplier (id, acceptedCurrencies)"
+ " VALUES ('1', {{name:'a good one'}:[{currency:'EUR'},{currency:'USD'}]})");
@@ -485,7 +482,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
private static class CurrencyToUDTConverter implements Converter<Currency, UdtValue> {
final UserTypeResolver userTypeResolver;
private final UserTypeResolver userTypeResolver;
CurrencyToUDTConverter(UserTypeResolver userTypeResolver) {
this.userTypeResolver = userTypeResolver;

View File

@@ -29,11 +29,14 @@ import java.util.LinkedHashMap;
import java.util.List;
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.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.ReadOnlyProperty;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
@@ -54,29 +57,31 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
* @author Mark Paluch
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.Silent.class) // there are some unused stubbings in RowMockUtil but they're used in other
public class MappingCassandraConverterUDTUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class MappingCassandraConverterUDTUnitTests {
@Mock UserTypeResolver userTypeResolver;
com.datastax.oss.driver.api.core.type.UserDefinedType manufacturer = UserDefinedTypeBuilder.forName("manufacturer")
private com.datastax.oss.driver.api.core.type.UserDefinedType manufacturer = UserDefinedTypeBuilder
.forName("manufacturer")
.withField("name", DataTypes.TEXT).withField("displayname", DataTypes.TEXT).build();
com.datastax.oss.driver.api.core.type.UserDefinedType currency = UserDefinedTypeBuilder.forName("mycurrency")
private com.datastax.oss.driver.api.core.type.UserDefinedType currency = UserDefinedTypeBuilder.forName("mycurrency")
.withField("currency", DataTypes.TEXT).build();
com.datastax.oss.driver.api.core.type.UserDefinedType withnullableembeddedtype = UserDefinedTypeBuilder
private com.datastax.oss.driver.api.core.type.UserDefinedType withnullableembeddedtype = UserDefinedTypeBuilder
.forName("withnullableembeddedtype").withField("value", DataTypes.TEXT).withField("firstname", DataTypes.TEXT)
.withField("age", DataTypes.INT).build();
com.datastax.oss.driver.api.core.type.UserDefinedType withprefixednullableembeddedtype = UserDefinedTypeBuilder
private com.datastax.oss.driver.api.core.type.UserDefinedType withprefixednullableembeddedtype = UserDefinedTypeBuilder
.forName("withnullableembeddedtype").withField("value", DataTypes.TEXT)
.withField("prefixfirstname", DataTypes.TEXT).withField("prefixage", DataTypes.INT).build();
Row rowMock;
private Row rowMock;
CassandraMappingContext mappingContext;
MappingCassandraConverter mappingCassandraConverter;
private CassandraMappingContext mappingContext;
private MappingCassandraConverter mappingCassandraConverter;
@Before
public void setUp() {
@BeforeEach
void setUp() {
mappingContext = new CassandraMappingContext();
mappingContext.setUserTypeResolver(userTypeResolver);
@@ -93,7 +98,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-487, DATACASS-623
public void shouldReadMappedUdtInMap() {
void shouldReadMappedUdtInMap() {
UdtValue key = manufacturer.newValue().setString("name", "a good one").setString("displayname", "my displayName");
UdtValue value1 = currency.newValue().setString("currency", "EUR");
@@ -116,7 +121,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-487, DATACASS-623
public void shouldWriteMappedUdtInMap() {
void shouldWriteMappedUdtInMap() {
Map<Manufacturer, List<Currency>> currencies = Collections.singletonMap(new Manufacturer("a good one", "foo"),
Arrays.asList(new Currency("EUR"), new Currency("USD")));
@@ -140,7 +145,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-167
public void writeFlattensEmbeddedType() {
void writeFlattensEmbeddedType() {
OuterWithNullableEmbeddedType entity = new OuterWithNullableEmbeddedType();
entity.id = "id-1";
@@ -160,7 +165,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-167
public void writeNullEmbeddedType() {
void writeNullEmbeddedType() {
OuterWithNullableEmbeddedType entity = new OuterWithNullableEmbeddedType();
entity.id = "id-1";
@@ -178,7 +183,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-167
public void writePrefixesEmbeddedType() {
void writePrefixesEmbeddedType() {
OuterWithPrefixedNullableEmbeddedType entity = new OuterWithPrefixedNullableEmbeddedType();
entity.id = "id-1";
@@ -198,7 +203,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-167
public void readEmbeddedType() {
void readEmbeddedType() {
UdtValue udtValue = withnullableembeddedtype.newValue().setString("value", "value-string")
.setString("firstname", "fn").setInt("age", 30);
@@ -215,7 +220,7 @@ public class MappingCassandraConverterUDTUnitTests {
}
@Test // DATACASS-167
public void readPrefixedEmbeddedType() {
void readPrefixedEmbeddedType() {
UdtValue udtValue = withprefixednullableembeddedtype.newValue().setString("value", "value-string")
.setString("prefixfirstname", "fn").setInt("prefixage", 30);

View File

@@ -38,8 +38,8 @@ import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.*;
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.data.annotation.Id;
import org.springframework.data.annotation.ReadOnlyProperty;
@@ -76,13 +76,13 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
*/
public class MappingCassandraConverterUnitTests {
Row rowMock;
private Row rowMock;
CassandraMappingContext mappingContext;
MappingCassandraConverter mappingCassandraConverter;
private CassandraMappingContext mappingContext;
private MappingCassandraConverter mappingCassandraConverter;
@Before
public void setUp() {
@BeforeEach
void setUp() {
this.mappingContext = new CassandraMappingContext();
@@ -91,7 +91,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void insertEnumShouldMapToString() {
void insertEnumShouldMapToString() {
WithEnumColumns withEnumColumns = new WithEnumColumns();
@@ -105,7 +105,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void shouldWriteEnumSet() {
void shouldWriteEnumSet() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setSetOfEnum(Collections.singleton(CassandraTypeMappingIntegrationTests.Condition.MINT));
@@ -118,7 +118,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-255
public void insertEnumMapsToOrdinal() {
void insertEnumMapsToOrdinal() {
EnumToOrdinalMapping enumToOrdinalMapping = new EnumToOrdinalMapping();
enumToOrdinalMapping.setAsOrdinal(Condition.USED);
@@ -131,7 +131,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-255, DATACASS-652
public void selectEnumMapsToOrdinal() {
void selectEnumMapsToOrdinal() {
rowMock = RowMockUtil.newRowMock(column("asOrdinal", 1, DataTypes.INT));
@@ -141,7 +141,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void insertEnumAsPrimaryKeyShouldMapToString() {
void insertEnumAsPrimaryKeyShouldMapToString() {
EnumPrimaryKey key = new EnumPrimaryKey();
key.setCondition(Condition.MINT);
@@ -154,7 +154,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void insertEnumInCompositePrimaryKeyShouldMapToString() {
void insertEnumInCompositePrimaryKeyShouldMapToString() {
EnumCompositePrimaryKey key = new EnumCompositePrimaryKey();
key.setCondition(Condition.MINT);
@@ -170,7 +170,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void updateEnumAsPrimaryKeyShouldMapToString() {
void updateEnumAsPrimaryKeyShouldMapToString() {
EnumPrimaryKey key = new EnumPrimaryKey();
key.setCondition(Condition.MINT);
@@ -183,7 +183,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void writeWhereEnumInCompositePrimaryKeyShouldMapToString() {
void writeWhereEnumInCompositePrimaryKeyShouldMapToString() {
EnumCompositePrimaryKey key = new EnumCompositePrimaryKey();
key.setCondition(Condition.MINT);
@@ -199,7 +199,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-260
public void writeWhereEnumAsPrimaryKeyShouldMapToString() {
void writeWhereEnumAsPrimaryKeyShouldMapToString() {
EnumPrimaryKey key = new EnumPrimaryKey();
key.setCondition(Condition.MINT);
@@ -212,7 +212,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadStringCorrectly() {
void shouldReadStringCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", "foo", DataTypes.TEXT));
@@ -222,7 +222,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadIntegerCorrectly() {
void shouldReadIntegerCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", 2, DataTypes.VARINT));
@@ -232,7 +232,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadLongCorrectly() {
void shouldReadLongCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", 2, DataTypes.VARINT));
@@ -242,7 +242,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadDoubleCorrectly() {
void shouldReadDoubleCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", 2D, DataTypes.DOUBLE));
@@ -252,7 +252,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadFloatCorrectly() {
void shouldReadFloatCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", 2F, DataTypes.DOUBLE));
@@ -262,7 +262,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadBigIntegerCorrectly() {
void shouldReadBigIntegerCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", BigInteger.valueOf(2), DataTypes.BIGINT));
@@ -272,7 +272,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadBigDecimalCorrectly() {
void shouldReadBigDecimalCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", BigDecimal.valueOf(2), DataTypes.DECIMAL));
@@ -282,7 +282,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadUUIDCorrectly() {
void shouldReadUUIDCorrectly() {
UUID uuid = UUID.randomUUID();
@@ -294,7 +294,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadInetAddressCorrectly() throws UnknownHostException {
void shouldReadInetAddressCorrectly() throws UnknownHostException {
InetAddress localHost = InetAddress.getLoopbackAddress();
rowMock = RowMockUtil.newRowMock(column("foo", localHost, DataTypes.UUID));
@@ -305,7 +305,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280, DATACASS-271
public void shouldReadTimestampCorrectly() {
void shouldReadTimestampCorrectly() {
Instant instant = Instant.now();
@@ -317,7 +317,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280, DATACASS-271
public void shouldReadInstantTimestampCorrectly() {
void shouldReadInstantTimestampCorrectly() {
Instant instant = Instant.now();
@@ -329,7 +329,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-656
public void shouldReadAndWriteTimestampFromObject() {
void shouldReadAndWriteTimestampFromObject() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setInstant(Instant.now());
@@ -344,7 +344,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-656, DATACASS-727
public void shouldReadAndWriteTimestampFromObjectWithConversion() {
void shouldReadAndWriteTimestampFromObjectWithConversion() {
AllPossibleTypes entity = new AllPossibleTypes("1");
entity.setInstant(Instant.now());
@@ -361,7 +361,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-656
public void shouldReadAndWriteTimeFromObjectWithConversion() {
void shouldReadAndWriteTimeFromObjectWithConversion() {
AllPossibleTypes entity = new AllPossibleTypes("1");
@@ -375,7 +375,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-271
public void shouldReadDateCorrectly() {
void shouldReadDateCorrectly() {
LocalDate date = LocalDate.ofEpochDay(1234);
@@ -387,7 +387,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-280
public void shouldReadBooleanCorrectly() {
void shouldReadBooleanCorrectly() {
rowMock = RowMockUtil.newRowMock(column("foo", true, DataTypes.BOOLEAN));
@@ -397,7 +397,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadLocalDateCorrectly() {
void shouldReadLocalDateCorrectly() {
LocalDateTime now = LocalDateTime.now();
Instant instant = now.toInstant(ZoneOffset.UTC);
@@ -413,7 +413,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateCorrectly() {
void shouldCreateInsertWithLocalDateCorrectly() {
java.time.LocalDate now = java.time.LocalDate.now();
@@ -428,7 +428,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateUpdateWithLocalDateCorrectly() {
void shouldCreateUpdateWithLocalDateCorrectly() {
java.time.LocalDate now = java.time.LocalDate.now();
@@ -443,7 +443,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateListUsingCassandraDate() {
void shouldCreateInsertWithLocalDateListUsingCassandraDate() {
java.time.LocalDate now = java.time.LocalDate.now();
java.time.LocalDate localDate = java.time.LocalDate.of(2010, 7, 4);
@@ -462,7 +462,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateSetUsingCassandraDate() {
void shouldCreateInsertWithLocalDateSetUsingCassandraDate() {
java.time.LocalDate now = java.time.LocalDate.now();
java.time.LocalDate localDate = java.time.LocalDate.of(2010, 7, 4);
@@ -481,7 +481,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadLocalDateTimeUsingCassandraDateCorrectly() {
void shouldReadLocalDateTimeUsingCassandraDateCorrectly() {
rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataTypes.ASCII),
column("localDate", LocalDate.of(2010, 7, 4), DataTypes.DATE));
@@ -496,7 +496,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296, DATACASS-400
public void shouldCreateInsertWithLocalDateUsingCassandraDateCorrectly() {
void shouldCreateInsertWithLocalDateUsingCassandraDateCorrectly() {
TypeWithLocalDateMappedToDate typeWithLocalDate = new TypeWithLocalDateMappedToDate(null,
java.time.LocalDate.of(2010, 7, 4));
@@ -509,7 +509,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateUpdateWithLocalDateUsingCassandraDateCorrectly() {
void shouldCreateUpdateWithLocalDateUsingCassandraDateCorrectly() {
TypeWithLocalDateMappedToDate typeWithLocalDate = new TypeWithLocalDateMappedToDate(null,
java.time.LocalDate.of(2010, 7, 4));
@@ -522,7 +522,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadLocalDateTimeCorrectly() {
void shouldReadLocalDateTimeCorrectly() {
LocalDateTime now = LocalDateTime.now();
Instant instant = now.toInstant(ZoneOffset.UTC);
@@ -538,7 +538,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadInstantCorrectly() {
void shouldReadInstantCorrectly() {
LocalDateTime now = LocalDateTime.now();
Instant instant = now.toInstant(ZoneOffset.UTC);
@@ -553,7 +553,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadZoneIdCorrectly() {
void shouldReadZoneIdCorrectly() {
rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataTypes.ASCII),
column("zoneId", "Europe/Paris", DataTypes.TEXT));
@@ -565,7 +565,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadJodaLocalDateTimeUsingCassandraDateCorrectly() {
void shouldReadJodaLocalDateTimeUsingCassandraDateCorrectly() {
rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataTypes.ASCII),
column("localDate", LocalDate.of(2010, 7, 4), DataTypes.DATE));
@@ -580,7 +580,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateInsertWithJodaLocalDateUsingCassandraDateCorrectly() {
void shouldCreateInsertWithJodaLocalDateUsingCassandraDateCorrectly() {
TypeWithJodaLocalDateMappedToDate typeWithLocalDate = new TypeWithJodaLocalDateMappedToDate();
typeWithLocalDate.localDate = new org.joda.time.LocalDate(2010, 7, 4);
@@ -593,7 +593,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateUpdateWithJodaLocalDateUsingCassandraDateCorrectly() {
void shouldCreateUpdateWithJodaLocalDateUsingCassandraDateCorrectly() {
TypeWithJodaLocalDateMappedToDate typeWithLocalDate = new TypeWithJodaLocalDateMappedToDate();
typeWithLocalDate.localDate = new org.joda.time.LocalDate(2010, 7, 4);
@@ -606,7 +606,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldReadThreeTenBpLocalDateTimeUsingCassandraDateCorrectly() {
void shouldReadThreeTenBpLocalDateTimeUsingCassandraDateCorrectly() {
rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataTypes.ASCII),
column("localDate", LocalDate.of(2010, 7, 4), DataTypes.DATE));
@@ -621,7 +621,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateInsertWithThreeTenBpLocalDateUsingCassandraDateCorrectly() {
void shouldCreateInsertWithThreeTenBpLocalDateUsingCassandraDateCorrectly() {
TypeWithThreeTenBpLocalDateMappedToDate typeWithLocalDate = new TypeWithThreeTenBpLocalDateMappedToDate();
typeWithLocalDate.localDate = org.threeten.bp.LocalDate.of(2010, 7, 4);
@@ -634,7 +634,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-296
public void shouldCreateUpdateWithThreeTenBpLocalDateUsingCassandraDateCorrectly() {
void shouldCreateUpdateWithThreeTenBpLocalDateUsingCassandraDateCorrectly() {
TypeWithThreeTenBpLocalDateMappedToDate typeWithLocalDate = new TypeWithThreeTenBpLocalDateMappedToDate();
typeWithLocalDate.localDate = org.threeten.bp.LocalDate.of(2010, 7, 4);
@@ -647,7 +647,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-206
public void updateShouldUseSpecifiedColumnNames() {
void updateShouldUseSpecifiedColumnNames() {
UserToken userToken = new UserToken();
userToken.setUserId(UUID.randomUUID());
@@ -667,7 +667,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionUsingPlainId() {
void shouldWriteWhereConditionUsingPlainId() {
Where where = new Where();
@@ -677,7 +677,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionUsingEntity() {
void shouldWriteWhereConditionUsingEntity() {
Where where = new Where();
@@ -689,14 +689,15 @@ public class MappingCassandraConverterUnitTests {
assertThat(where).containsEntry(CqlIdentifier.fromCql("id"), "42");
}
@Test(expected = IllegalArgumentException.class) // DATACASS-308
public void shouldFailWriteWhereConditionUsingEntityWithNullId() {
@Test // DATACASS-308
void shouldFailWriteWhereConditionUsingEntityWithNullId() {
mappingCassandraConverter.write(new User(), new Where(), mappingContext.getRequiredPersistentEntity(User.class));
assertThatIllegalArgumentException().isThrownBy(() -> mappingCassandraConverter.write(new User(), new Where(),
mappingContext.getRequiredPersistentEntity(User.class)));
}
@Test // DATACASS-308
public void shouldWriteWhereConditionUsingMapId() {
void shouldWriteWhereConditionUsingMapId() {
Where where = new Where();
@@ -706,7 +707,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForCompositeKeyUsingEntity() {
void shouldWriteWhereConditionForCompositeKeyUsingEntity() {
Where where = new Where();
@@ -722,7 +723,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForCompositeKeyUsingMapId() {
void shouldWriteWhereConditionForCompositeKeyUsingMapId() {
Where where = new Where();
@@ -734,7 +735,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForMapIdKeyUsingEntity() {
void shouldWriteWhereConditionForMapIdKeyUsingEntity() {
Where where = new Where();
@@ -749,7 +750,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteEnumWhereCondition() {
void shouldWriteEnumWhereCondition() {
Where where = new Where();
@@ -760,7 +761,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForMapIdKeyUsingMapId() {
void shouldWriteWhereConditionForMapIdKeyUsingMapId() {
Where where = new Where();
@@ -772,7 +773,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForTypeWithPkClassKeyUsingEntity() {
void shouldWriteWhereConditionForTypeWithPkClassKeyUsingEntity() {
Where where = new Where();
@@ -789,15 +790,15 @@ public class MappingCassandraConverterUnitTests {
assertThat(where).containsEntry(CqlIdentifier.fromCql("lastname"), "White");
}
@Test(expected = IllegalArgumentException.class) // DATACASS-308
public void shouldFailWritingWhereConditionForTypeWithPkClassKeyUsingEntityWithNullId() {
@Test // DATACASS-308
void shouldFailWritingWhereConditionForTypeWithPkClassKeyUsingEntityWithNullId() {
mappingCassandraConverter.write(new TypeWithKeyClass(), new Where(),
mappingContext.getRequiredPersistentEntity(TypeWithKeyClass.class));
assertThatIllegalArgumentException().isThrownBy(() -> mappingCassandraConverter.write(new TypeWithKeyClass(),
new Where(), mappingContext.getRequiredPersistentEntity(TypeWithKeyClass.class)));
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForTypeWithPkClassKeyUsingKey() {
void shouldWriteWhereConditionForTypeWithPkClassKeyUsingKey() {
Where where = new Where();
@@ -812,7 +813,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-463
public void shouldReadTypeWithCompositePrimaryKeyCorrectly() {
void shouldReadTypeWithCompositePrimaryKeyCorrectly() {
// condition, localDate
Row row = RowMockUtil.newRowMock(column("condition", "MINT", DataTypes.TEXT),
@@ -825,7 +826,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-672
public void shouldReadTypeCompositePrimaryKeyUsingEntityInstantiatorAndPropertyPopulationInKeyCorrectly() {
void shouldReadTypeCompositePrimaryKeyUsingEntityInstantiatorAndPropertyPopulationInKeyCorrectly() {
// condition, localDate
Row row = RowMockUtil.newRowMock(column("firstname", "Walter", DataTypes.TEXT),
@@ -839,7 +840,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-308
public void shouldWriteWhereConditionForTypeWithPkClassKeyUsingMapId() {
void shouldWriteWhereConditionForTypeWithPkClassKeyUsingMapId() {
Where where = new Where();
@@ -850,15 +851,15 @@ public class MappingCassandraConverterUnitTests {
assertThat(where).containsEntry(CqlIdentifier.fromCql("lastname"), "White");
}
@Test(expected = IllegalArgumentException.class) // DATACASS-308
public void shouldFailWhereConditionForTypeWithPkClassKeyUsingMapIdHavingUnknownProperty() {
@Test // DATACASS-308
void shouldFailWhereConditionForTypeWithPkClassKeyUsingMapIdHavingUnknownProperty() {
mappingCassandraConverter.write(id("unknown", "Walter"), new Where(),
mappingContext.getRequiredPersistentEntity(TypeWithMapId.class));
assertThatIllegalArgumentException().isThrownBy(() -> mappingCassandraConverter.write(id("unknown", "Walter"),
new Where(), mappingContext.getRequiredPersistentEntity(TypeWithMapId.class)));
}
@Test // DATACASS-362
public void shouldWriteWhereCompositeIdUsingCompositeKeyClass() {
void shouldWriteWhereCompositeIdUsingCompositeKeyClass() {
Where where = new Where();
@@ -873,7 +874,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-362
public void writeWhereCompositeIdUsingCompositeKeyClassViaMapId() {
void writeWhereCompositeIdUsingCompositeKeyClassViaMapId() {
Where where = new Where();
@@ -886,7 +887,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-487
public void shouldReadConvertedMap() {
void shouldReadConvertedMap() {
LocalDate date1 = LocalDate.of(2018, 1, 1);
LocalDate date2 = LocalDate.of(2019, 1, 1);
@@ -906,7 +907,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-487
public void shouldWriteConvertedMap() {
void shouldWriteConvertedMap() {
java.time.LocalDate date1 = java.time.LocalDate.of(2018, 1, 1);
java.time.LocalDate date2 = java.time.LocalDate.of(2019, 1, 1);
@@ -931,7 +932,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-189
public void writeShouldSkipTransientProperties() {
void writeShouldSkipTransientProperties() {
WithTransient withTransient = new WithTransient();
withTransient.firstname = "Foo";
@@ -947,7 +948,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-623
public void writeShouldSkipTransientReadProperties() {
void writeShouldSkipTransientReadProperties() {
WithTransient withTransient = new WithTransient();
withTransient.firstname = "Foo";
@@ -962,7 +963,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-741
public void shouldComputeValueInConstructor() {
void shouldComputeValueInConstructor() {
rowMock = RowMockUtil.newRowMock(RowMockUtil.column("id", "id", DataTypes.TEXT),
RowMockUtil.column("fn", "fn", DataTypes.TEXT));
@@ -974,7 +975,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderCassandraTypeOnList() {
void shouldConsiderCassandraTypeOnList() {
TypeWithConvertedCollections value = new TypeWithConvertedCollections();
value.conditionList = Arrays.asList(Condition.MINT, Condition.USED);
@@ -987,7 +988,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderCassandraTypeOnSet() {
void shouldConsiderCassandraTypeOnSet() {
TypeWithConvertedCollections value = new TypeWithConvertedCollections();
value.conditionSet = new LinkedHashSet<>(Arrays.asList(Condition.MINT, Condition.USED));
@@ -1000,7 +1001,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-743
public void shouldConsiderCassandraTypeOnMap() {
void shouldConsiderCassandraTypeOnMap() {
TypeWithConvertedCollections value = new TypeWithConvertedCollections();
value.conditionMap = Collections.singletonMap(Condition.MINT, Condition.USED);
@@ -1021,7 +1022,7 @@ public class MappingCassandraConverterUnitTests {
}
@Table
public static class EnumToOrdinalMapping {
private static class EnumToOrdinalMapping {
@PrimaryKey private String id;
@@ -1035,17 +1036,17 @@ public class MappingCassandraConverterUnitTests {
this.id = id;
}
public Condition getAsOrdinal() {
private Condition getAsOrdinal() {
return asOrdinal;
}
public void setAsOrdinal(Condition asOrdinal) {
private void setAsOrdinal(Condition asOrdinal) {
this.asOrdinal = asOrdinal;
}
}
@Table
public static class WithEnumColumns {
private static class WithEnumColumns {
@PrimaryKey private String id;
@@ -1063,7 +1064,7 @@ public class MappingCassandraConverterUnitTests {
return condition;
}
public void setCondition(Condition condition) {
private void setCondition(Condition condition) {
this.condition = condition;
}
}
@@ -1073,7 +1074,7 @@ public class MappingCassandraConverterUnitTests {
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private Condition condition;
public EnumCompositePrimaryKey() {}
private EnumCompositePrimaryKey() {}
public EnumCompositePrimaryKey(Condition condition) {
this.condition = condition;
@@ -1083,7 +1084,7 @@ public class MappingCassandraConverterUnitTests {
return condition;
}
public void setCondition(Condition condition) {
private void setCondition(Condition condition) {
this.condition = condition;
}
}
@@ -1105,7 +1106,7 @@ public class MappingCassandraConverterUnitTests {
}
@Table
public static class EnumPrimaryKey {
private static class EnumPrimaryKey {
@PrimaryKey private Condition condition;
@@ -1113,17 +1114,17 @@ public class MappingCassandraConverterUnitTests {
return condition;
}
public void setCondition(Condition condition) {
private void setCondition(Condition condition) {
this.condition = condition;
}
}
@Table
public static class CompositeKeyThing {
private static class CompositeKeyThing {
@PrimaryKey private EnumCompositePrimaryKey key;
public CompositeKeyThing() {}
private CompositeKeyThing() {}
public CompositeKeyThing(EnumCompositePrimaryKey key) {
this.key = key;
@@ -1133,7 +1134,7 @@ public class MappingCassandraConverterUnitTests {
return key;
}
public void setKey(EnumCompositePrimaryKey key) {
private void setKey(EnumCompositePrimaryKey key) {
this.key = key;
}
}
@@ -1143,10 +1144,10 @@ public class MappingCassandraConverterUnitTests {
}
@PrimaryKeyClass
public static class CompositeKeyWithPropertyAccessors {
private static class CompositeKeyWithPropertyAccessors {
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String firstname;
@PrimaryKeyColumn String lastname;
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) private String firstname;
@PrimaryKeyColumn private String lastname;
}
@Table
@@ -1157,15 +1158,15 @@ public class MappingCassandraConverterUnitTests {
}
@Table
public static class TypeWithLocalDate {
private static class TypeWithLocalDate {
@PrimaryKey private String id;
java.time.LocalDate localDate;
java.time.LocalDateTime localDateTime;
private java.time.LocalDate localDate;
private java.time.LocalDateTime localDateTime;
List<java.time.LocalDate> list;
Set<java.time.LocalDate> set;
private List<java.time.LocalDate> list;
private Set<java.time.LocalDate> set;
}
/**
@@ -1184,76 +1185,78 @@ public class MappingCassandraConverterUnitTests {
* Uses Cassandra's {@link Name#DATE} which maps by default to Joda {@link LocalDate}
*/
@Table
public static class TypeWithJodaLocalDateMappedToDate {
private static class TypeWithJodaLocalDateMappedToDate {
@PrimaryKey private String id;
@CassandraType(type = CassandraType.Name.DATE) org.joda.time.LocalDate localDate;
@CassandraType(type = CassandraType.Name.DATE) private org.joda.time.LocalDate localDate;
}
/**
* Uses Cassandra's {@link Name#DATE} which maps by default to Joda {@link LocalDate}
*/
@Table
public static class TypeWithThreeTenBpLocalDateMappedToDate {
private static class TypeWithThreeTenBpLocalDateMappedToDate {
@PrimaryKey private String id;
@CassandraType(type = CassandraType.Name.DATE) org.threeten.bp.LocalDate localDate;
@CassandraType(type = CassandraType.Name.DATE) private org.threeten.bp.LocalDate localDate;
}
@Table
public static class TypeWithInstant {
private static class TypeWithInstant {
@PrimaryKey private String id;
Instant instant;
private Instant instant;
}
@Table
public static class TypeWithZoneId {
private static class TypeWithZoneId {
@PrimaryKey private String id;
ZoneId zoneId;
private ZoneId zoneId;
}
@Table
public static class TypeWithConvertedMap {
private static class TypeWithConvertedMap {
@PrimaryKey private String id;
Map<ZoneId, List<java.time.LocalDate>> times;
private Map<ZoneId, List<java.time.LocalDate>> times;
}
static class WithTransient {
private static class WithTransient {
@Id String id;
String firstname;
String lastname;
@Transient String displayName;
@ReadOnlyProperty String computedName;
private String firstname;
private String lastname;
@Transient private String displayName;
@ReadOnlyProperty private String computedName;
}
public static class TypeWithConvertedCollections {
private static class TypeWithConvertedCollections {
@CassandraType(type = CassandraType.Name.LIST,
typeArguments = CassandraType.Name.INT) List<Condition> conditionList;
typeArguments = CassandraType.Name.INT) private List<Condition> conditionList;
@CassandraType(type = CassandraType.Name.SET, typeArguments = CassandraType.Name.INT) Set<Condition> conditionSet;
@CassandraType(type = CassandraType.Name.SET,
typeArguments = CassandraType.Name.INT) private Set<Condition> conditionSet;
@CassandraType(type = CassandraType.Name.MAP,
typeArguments = { CassandraType.Name.INT, CassandraType.Name.INT }) Map<Condition, Condition> conditionMap;
typeArguments = { CassandraType.Name.INT,
CassandraType.Name.INT }) private Map<Condition, Condition> conditionMap;
}
static class WithValue {
private static class WithValue {
final @Id String id;
final @Transient String firstname;
private final @Id String id;
private final @Transient String firstname;
public WithValue(String id, @Value("#root.getString(1)") String firstname) {
private WithValue(String id, @Value("#root.getString(1)") String firstname) {
this.id = id;
this.firstname = firstname;
}
@@ -1295,7 +1298,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-167
public void writeFlattensEmbeddedType() {
void writeFlattensEmbeddedType() {
WithNullableEmbeddedType entity = new WithNullableEmbeddedType();
entity.id = "id-1";
@@ -1316,7 +1319,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-167
public void writePrefixesEmbeddedType() {
void writePrefixesEmbeddedType() {
WithPrefixedNullableEmbeddedType entity = new WithPrefixedNullableEmbeddedType();
entity.id = "id-1";
@@ -1337,7 +1340,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-167
public void writeNullEmbeddedType() {
void writeNullEmbeddedType() {
WithNullableEmbeddedType entity = new WithNullableEmbeddedType();
entity.id = "id-1";
@@ -1355,7 +1358,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-167
public void readEmbeddedType() {
void readEmbeddedType() {
Row source = RowMockUtil.newRowMock(column("id", "id-1", DataTypes.TEXT), column("age", 30, DataTypes.INT),
column("firstname", "fn", DataTypes.TEXT));
@@ -1365,7 +1368,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-167
public void readPrefixedEmbeddedType() {
void readPrefixedEmbeddedType() {
Row source = RowMockUtil.newRowMock(column("id", "id-1", DataTypes.TEXT), column("prefixage", 30, DataTypes.INT),
column("prefixfirstname", "fn", DataTypes.TEXT));
@@ -1375,7 +1378,7 @@ public class MappingCassandraConverterUnitTests {
}
@Test // DATACASS-167
public void readEmbeddedTypeWhenSourceDoesNotContainValues() {
void readEmbeddedTypeWhenSourceDoesNotContainValues() {
Row source = RowMockUtil.newRowMock(column("id", "id-1", DataTypes.TEXT));

View File

@@ -32,11 +32,14 @@ import java.util.stream.Collectors;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.data.annotation.Id;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.core.mapping.CassandraPersistentEntity;
@@ -70,24 +73,25 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class QueryMapperUnitTests {
CassandraMappingContext mappingContext = new CassandraMappingContext();
private CassandraMappingContext mappingContext = new CassandraMappingContext();
CassandraPersistentEntity<?> persistentEntity;
private CassandraPersistentEntity<?> persistentEntity;
MappingCassandraConverter cassandraConverter;
private MappingCassandraConverter cassandraConverter;
QueryMapper queryMapper;
private QueryMapper queryMapper;
com.datastax.oss.driver.api.core.type.UserDefinedType userType = UserDefinedTypeBuilder.forName("address")
private com.datastax.oss.driver.api.core.type.UserDefinedType userType = UserDefinedTypeBuilder.forName("address")
.withField("street", DataTypes.TEXT).build();
@Mock UserTypeResolver userTypeResolver;
@Before
public void before() {
@BeforeEach
void before() {
CassandraCustomConversions customConversions = new CassandraCustomConversions(
Collections.singletonList(CurrencyConverter.INSTANCE));
@@ -107,7 +111,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapSimpleQuery() {
void shouldMapSimpleQuery() {
Query query = Query.query(Criteria.where("foo_name").is("bar"));
@@ -120,7 +124,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapEnumToString() {
void shouldMapEnumToString() {
Query query = Query.query(Criteria.where("foo_name").is(State.Active));
@@ -132,7 +136,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapEnumToNumber() {
void shouldMapEnumToNumber() {
Query query = Query.query(Criteria.where("number").is(State.Inactive));
@@ -144,7 +148,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapEnumToNumberIn() {
void shouldMapEnumToNumberIn() {
Query query = Query.query(Criteria.where("number").in(State.Inactive));
@@ -157,7 +161,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapApplyingCustomConversion() {
void shouldMapApplyingCustomConversion() {
Query query = Query.query(Criteria.where("foo_name").is(Currency.getInstance("EUR")));
@@ -170,7 +174,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapApplyingCustomConversionInCollection() {
void shouldMapApplyingCustomConversionInCollection() {
Query query = Query.query(Criteria.where("foo_name").in(Currency.getInstance("EUR")));
@@ -183,7 +187,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapApplyingUdtValueConversion() {
void shouldMapApplyingUdtValueConversion() {
Query query = Query.query(Criteria.where("address").is(new Address("21 Jump-Street")));
@@ -198,7 +202,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapApplyingUdtValueCollectionConversion() {
void shouldMapApplyingUdtValueCollectionConversion() {
Query query = Query.query(Criteria.where("address").in(new Address("21 Jump-Street")));
@@ -215,7 +219,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapCollectionApplyingUdtValueCollectionConversion() {
void shouldMapCollectionApplyingUdtValueCollectionConversion() {
Query query = Query.query(Criteria.where("address").in(new Address("21 Jump-Street")));
@@ -231,7 +235,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-487
public void shouldMapUdtMapContainsKey() {
void shouldMapUdtMapContainsKey() {
Query query = Query.query(Criteria.where("relocations").containsKey(new Address("21 Jump-Street")));
@@ -246,7 +250,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-487
public void shouldMapUdtMapContains() {
void shouldMapUdtMapContains() {
Query query = Query.query(Criteria.where("relocations").contains(new Address("21 Jump-Street")));
@@ -261,7 +265,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapPropertyToColumnName() {
void shouldMapPropertyToColumnName() {
Query query = Query.query(Criteria.where("firstName").is("bar"));
@@ -275,7 +279,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSelectExpression() {
void shouldCreateSelectExpression() {
List<Selector> selectors = queryMapper.getMappedSelectors(Columns.empty(), persistentEntity);
@@ -283,7 +287,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSelectExpressionWithTTL() {
void shouldCreateSelectExpressionWithTTL() {
List<String> selectors = queryMapper
.getMappedSelectors(Columns.from("number", "foo").ttl("firstName"),
@@ -294,7 +298,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldIncludeColumnsSelectExpressionWithTTL() {
void shouldIncludeColumnsSelectExpressionWithTTL() {
List<CqlIdentifier> selectors = queryMapper.getMappedColumnNames(Columns.from("number", "foo").ttl("firstName"),
persistentEntity);
@@ -303,7 +307,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapQueryWithCompositePrimaryKeyClass() {
void shouldMapQueryWithCompositePrimaryKeyClass() {
Filter filter = Filter.from(Criteria.where("key.firstname").is("foo"));
@@ -314,7 +318,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-343
public void shouldMapSortWithCompositePrimaryKeyClass() {
void shouldMapSortWithCompositePrimaryKeyClass() {
Sort sort = Sort.by("key.firstname");
@@ -324,16 +328,17 @@ public class QueryMapperUnitTests {
assertThat(mappedObject).contains(new Order(Direction.ASC, "first_name"));
}
@Test(expected = IllegalArgumentException.class) // DATACASS-343
public void shouldFailMappingSortByCompositePrimaryKeyClass() {
@Test // DATACASS-343
void shouldFailMappingSortByCompositePrimaryKeyClass() {
Sort sort = Sort.by("key");
queryMapper.getMappedSort(sort, mappingContext.getRequiredPersistentEntity(TypeWithKeyClass.class));
assertThatIllegalArgumentException().isThrownBy(
() -> queryMapper.getMappedSort(sort, mappingContext.getRequiredPersistentEntity(TypeWithKeyClass.class)));
}
@Test // DATACASS-343
public void shouldMapColumnWithCompositePrimaryKeyClass() {
void shouldMapColumnWithCompositePrimaryKeyClass() {
Columns columnNames = Columns.from("key.firstname");
@@ -344,7 +349,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-523
public void shouldMapTuple() {
void shouldMapTuple() {
MappedTuple tuple = new MappedTuple("foo");
@@ -361,7 +366,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-302
public void shouldMapTime() {
void shouldMapTime() {
Filter filter = Filter.from(Criteria.where("localTime").gt(LocalTime.fromMillisOfDay(1000)));
@@ -373,14 +378,14 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-523
public void referencingTupleElementsInQueryShouldFail() {
void referencingTupleElementsInQueryShouldFail() {
assertThatIllegalArgumentException()
.isThrownBy(() -> this.queryMapper.getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")),
this.mappingContext.getRequiredPersistentEntity(Person.class)));
}
@Test // DATACASS-167
public void shouldMapEmbeddedType() {
void shouldMapEmbeddedType() {
Filter filter = Filter.from(Criteria.where("nested.firstname").is("spring"));
@@ -391,7 +396,7 @@ public class QueryMapperUnitTests {
}
@Test // DATACASS-167
public void shouldMapPrefixedEmbeddedType() {
void shouldMapPrefixedEmbeddedType() {
Filter filter = Filter.from(Criteria.where("nested.firstname").is("spring"));

View File

@@ -18,26 +18,26 @@ package org.springframework.data.cassandra.core.convert;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.BDDMockito.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.cql.ColumnDefinitions;
import com.datastax.oss.driver.api.core.cql.Row;
/**
* Unit tests for {@link ColumnReader}.
* Unit tests for {@link RowReader}.
*
* @author Christopher Batey
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class RowReaderUnitTests {
@ExtendWith(MockitoExtension.class)
class RowReaderUnitTests {
public static final String NON_EXISTENT_COLUMN = "column_name";
private static final String NON_EXISTENT_COLUMN = "column_name";
@Mock Row row;
@@ -45,59 +45,39 @@ public class RowReaderUnitTests {
private RowReader underTest;
@Before
public void setup() {
@BeforeEach
void setup() {
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
underTest = new RowReader(row);
}
@Test(expected = IllegalArgumentException.class)
public void throwsIllegalArgumentExceptionIfColumnDoesNotExistByName() {
@Test
void throwsIllegalArgumentExceptionIfColumnDoesNotExistByName() {
when(columnDefinitions.firstIndexOf(NON_EXISTENT_COLUMN)).thenReturn(-1);
try {
underTest.get(NON_EXISTENT_COLUMN);
fail("Expected illegal argument exception");
} catch (IllegalArgumentException expected) {
assertThatIllegalArgumentException().isThrownBy(() -> underTest.get(NON_EXISTENT_COLUMN))
.withMessageContaining("Column [%s] does not exist in table", NON_EXISTENT_COLUMN);
assertThat(expected).hasMessage("Column [%s] does not exist in table", NON_EXISTENT_COLUMN);
assertThat(expected).hasNoCause();
throw expected;
}
}
@Test(expected = IllegalArgumentException.class)
public void throwsIllegalArgumentExceptionIfColumnDoesNotExistByCqlIdentifier() {
@Test
void throwsIllegalArgumentExceptionIfColumnDoesNotExistByCqlIdentifier() {
when(columnDefinitions.firstIndexOf(NON_EXISTENT_COLUMN)).thenReturn(-1);
try {
underTest.get(CqlIdentifier.fromCql(NON_EXISTENT_COLUMN));
} catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("Column [%s] does not exist in table", NON_EXISTENT_COLUMN);
assertThat(expected).hasNoCause();
throw expected;
}
assertThatIllegalArgumentException().isThrownBy(() -> underTest.get(CqlIdentifier.fromCql(NON_EXISTENT_COLUMN)))
.withMessageContaining("Column [%s] does not exist in table", NON_EXISTENT_COLUMN);
}
@Test(expected = IllegalArgumentException.class)
public void throwsIllegalArgumentExceptionIfColumnDoesNotExistByCqlIdentifierAndType() {
@Test
void throwsIllegalArgumentExceptionIfColumnDoesNotExistByCqlIdentifierAndType() {
when(columnDefinitions.firstIndexOf(NON_EXISTENT_COLUMN)).thenReturn(-1);
try {
underTest.get(CqlIdentifier.fromCql(NON_EXISTENT_COLUMN), String.class);
} catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("Column [%s] does not exist in table", NON_EXISTENT_COLUMN);
assertThat(expected).hasNoCause();
throw expected;
}
assertThatIllegalArgumentException()
.isThrownBy(() -> underTest.get(underTest.get(CqlIdentifier.fromCql(NON_EXISTENT_COLUMN), String.class)))
.withMessageContaining("Column [%s] does not exist in table", NON_EXISTENT_COLUMN);
}
}

View File

@@ -33,8 +33,8 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.annotation.Id;
import org.springframework.data.cassandra.core.cql.Ordering;
@@ -70,11 +70,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
public class SchemaFactoryUnitTests {
CassandraMappingContext ctx = new CassandraMappingContext();
SchemaFactory schemaFactory;
private CassandraMappingContext ctx = new CassandraMappingContext();
private SchemaFactory schemaFactory;
@Before
public void before() {
@BeforeEach
void before() {
List<Converter<?, ?>> converters = new ArrayList<>();
converters.add(new PersonReadConverter());
@@ -87,7 +87,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-340
public void createdTableSpecificationShouldConsiderClusterColumnOrdering() {
void createdTableSpecificationShouldConsiderClusterColumnOrdering() {
CassandraPersistentEntity<?> persistentEntity = ctx
.getRequiredPersistentEntity(EntityWithOrderedClusteredColumns.class);
@@ -111,7 +111,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-340
public void createdTableSpecificationShouldConsiderPrimaryKeyClassClusterColumnOrdering() {
void createdTableSpecificationShouldConsiderPrimaryKeyClassClusterColumnOrdering() {
CassandraPersistentEntity<?> persistentEntity = ctx
.getRequiredPersistentEntity(EntityWithPrimaryKeyWithOrderedClusteredColumns.class);
@@ -135,7 +135,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-487
public void shouldCreateTableForMappedAndConvertedColumn() {
void shouldCreateTableForMappedAndConvertedColumn() {
UserDefinedType mappedudt = UserDefinedTypeBuilder.forName("mappedudt").withField("foo", DataTypes.ASCII).build();
@@ -155,8 +155,8 @@ public class SchemaFactoryUnitTests {
@PrimaryKeyClass
private static class CompositePrimaryKeyClassWithProperties implements Serializable {
String firstname;
String lastname;
private String firstname;
private String lastname;
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED)
public String getFirstname() {
@@ -178,7 +178,7 @@ public class SchemaFactoryUnitTests {
}
@Table
static class EntityWithOrderedClusteredColumns {
private static class EntityWithOrderedClusteredColumns {
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String species;
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.CLUSTERED, ordering = Ordering.ASCENDING) String breed;
@@ -202,7 +202,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-213
public void createIndexShouldConsiderAnnotatedProperties() {
void createIndexShouldConsiderAnnotatedProperties() {
List<CreateIndexSpecification> specifications = schemaFactory
.getCreateIndexSpecificationsFor(ctx.getRequiredPersistentEntity(IndexedType.class));
@@ -223,7 +223,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-213
public void createIndexForClusteredPrimaryKeyShouldConsiderAnnotatedAccessors() {
void createIndexForClusteredPrimaryKeyShouldConsiderAnnotatedAccessors() {
List<CreateIndexSpecification> specifications = schemaFactory
.getCreateIndexSpecificationsFor(ctx.getRequiredPersistentEntity(CompositeKeyEntity.class));
@@ -237,7 +237,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-284, DATACASS-651
public void shouldRejectUntypedTuples() {
void shouldRejectUntypedTuples() {
assertThatThrownBy(() -> this.schemaFactory
.getCreateTableSpecificationFor(this.ctx.getRequiredPersistentEntity(UntypedTupleEntity.class)))
@@ -249,7 +249,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-284
public void shouldCreateTableForTypedTupleType() {
void shouldCreateTableForTypedTupleType() {
CreateTableSpecification tableSpecification = this.schemaFactory
.getCreateTableSpecificationFor(this.ctx.getRequiredPersistentEntity(TypedTupleEntity.class));
@@ -263,7 +263,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-651
public void shouldCreateTableForEntityWithMapOfTuples() {
void shouldCreateTableForEntityWithMapOfTuples() {
CreateTableSpecification tableSpecification = this.schemaFactory
.getCreateTableSpecificationFor(this.ctx.getRequiredPersistentEntity(EntityWithMapOfTuples.class));
@@ -282,7 +282,7 @@ public class SchemaFactoryUnitTests {
.orElseThrow(() -> new NoSuchElementException(column));
}
static class IndexedType {
private static class IndexedType {
@PrimaryKeyColumn("first_name") @Indexed("my_index") String firstname;
@@ -296,18 +296,18 @@ public class SchemaFactoryUnitTests {
@PrimaryKeyColumn("last_name") @Indexed("my_index") String lastname;
}
static class CompositeKeyEntity {
private static class CompositeKeyEntity {
@PrimaryKey CompositeKeyWithIndex key;
}
static class InvalidMapIndex {
private static class InvalidMapIndex {
@Indexed Map<@Indexed String, String> mixed;
}
@Test // DATACASS-506
public void shouldCreatedUserTypeSpecificationsWithAnnotatedTypeName() {
void shouldCreatedUserTypeSpecificationsWithAnnotatedTypeName() {
assertThat(schemaFactory.getCreateUserTypeSpecificationFor(ctx.getRequiredPersistentEntity(WithUdt.class)))
.isNotNull();
@@ -316,7 +316,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-172
public void createTableForComplexPrimaryKeyShouldFail() {
void createTableForComplexPrimaryKeyShouldFail() {
try {
schemaFactory
@@ -346,7 +346,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void customConversionTestShouldCreateCorrectTableDefinition() {
void customConversionTestShouldCreateCorrectTableDefinition() {
CassandraPersistentEntity<?> persistentEntity = ctx.getRequiredPersistentEntity(Employee.class);
@@ -370,7 +370,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void customConversionTestShouldHonorTypeAnnotationAndCreateCorrectTableDefinition() {
void customConversionTestShouldHonorTypeAnnotationAndCreateCorrectTableDefinition() {
CassandraPersistentEntity<?> persistentEntity = ctx.getRequiredPersistentEntity(Employee.class);
@@ -387,7 +387,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToVarchar() {
void columnsShouldMapToVarchar() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -398,7 +398,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToTinyInt() {
void columnsShouldMapToTinyInt() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -407,7 +407,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToSmallInt() {
void columnsShouldMapToSmallInt() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -416,7 +416,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToBigInt() {
void columnsShouldMapToBigInt() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -425,7 +425,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToVarInt() {
void columnsShouldMapToVarInt() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -433,7 +433,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToDecimal() {
void columnsShouldMapToDecimal() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -441,7 +441,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToInt() {
void columnsShouldMapToInt() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -450,7 +450,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToFloat() {
void columnsShouldMapToFloat() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -459,7 +459,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToDouble() {
void columnsShouldMapToDouble() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -468,7 +468,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToBoolean() {
void columnsShouldMapToBoolean() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -477,7 +477,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToDate() {
void columnsShouldMapToDate() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -487,7 +487,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToTimestamp() {
void columnsShouldMapToTimestamp() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -501,7 +501,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToTimestampUsingOverrides() {
void columnsShouldMapToTimestampUsingOverrides() {
CreateTableSpecification specification = getCreateTableSpecificationFor(TypeWithOverrides.class);
@@ -510,7 +510,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-296
public void columnsShouldMapToBlob() {
void columnsShouldMapToBlob() {
CreateTableSpecification specification = getCreateTableSpecificationFor(AllPossibleTypes.class);
@@ -518,7 +518,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-172
public void columnsShouldMapToUdt() {
void columnsShouldMapToUdt() {
CreateTableSpecification specification = getCreateTableSpecificationFor(WithUdtFields.class);
@@ -528,7 +528,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-172
public void columnsShouldMapToMappedUserType() {
void columnsShouldMapToMappedUserType() {
UserDefinedType mappedUdt = new SchemaFactory.ShallowUserDefinedType("mappedudt", true);
@@ -550,7 +550,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-523
public void columnsShouldMapToTuple() {
void columnsShouldMapToTuple() {
UserDefinedType mappedUdt = mock(UserDefinedType.class, "mappedudt");
UserDefinedType human_udt = mock(UserDefinedType.class, "human_udt");
@@ -583,7 +583,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-678
public void createTableSpecificationShouldConsiderCustomTableName() {
void createTableSpecificationShouldConsiderCustomTableName() {
CqlIdentifier customTableName = CqlIdentifier.fromCql("my_custom_came");
@@ -732,12 +732,12 @@ public class SchemaFactoryUnitTests {
}
@Table
static class EntityWithComplexPrimaryKeyColumn {
private static class EntityWithComplexPrimaryKeyColumn {
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) Object complexObject;
}
@Table
static class EntityWithComplexId {
private static class EntityWithComplexId {
@Id Object complexObject;
}
@@ -747,7 +747,7 @@ public class SchemaFactoryUnitTests {
}
@Table
static class EntityWithPrimaryKeyClassWithComplexId {
private static class EntityWithPrimaryKeyClassWithComplexId {
@Id PrimaryKeyClassWithComplexId primaryKeyClassWithComplexId;
}
@@ -785,36 +785,36 @@ public class SchemaFactoryUnitTests {
}
@org.springframework.data.cassandra.core.mapping.UserDefinedType(value = "NestedType")
public static class Nested {
static class Nested {
String s1;
@CassandraType(type = Name.UDT, userTypeName = "AnotherNestedType") AnotherNested anotherNested;
}
@org.springframework.data.cassandra.core.mapping.UserDefinedType(value = "AnotherNestedType")
public static class AnotherNested {
static class AnotherNested {
String str;
}
@Table
static class TypedTupleEntity {
private static class TypedTupleEntity {
@Id String id;
@CassandraType(type = Name.TUPLE, typeArguments = { Name.VARCHAR, Name.BIGINT }) TupleValue typed;
}
@Table
static class EntityWithMapOfTuples {
private static class EntityWithMapOfTuples {
@Id String id;
Map<String, MappedTuple> map;
}
@Table
static class UntypedTupleEntity {
private static class UntypedTupleEntity {
@Id String id;
TupleValue untyped;
}
@Table
static class UntypedTupleMapEntity {
private static class UntypedTupleMapEntity {
@Id String id;
Map<String, TupleValue> untyped;
}
@@ -837,7 +837,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-167
public void createTableSpecificationShouldConsiderEmbeddedType() {
void createTableSpecificationShouldConsiderEmbeddedType() {
CreateTableSpecification specification = getCreateTableSpecificationFor(TypeWithEmbedded.class);
@@ -851,7 +851,7 @@ public class SchemaFactoryUnitTests {
}
@Test // DATACASS-167
public void createIndexSpecificationShouldConsiderEmbeddedType() {
void createIndexSpecificationShouldConsiderEmbeddedType() {
List<CreateIndexSpecification> specifications = schemaFactory
.getCreateIndexSpecificationsFor(ctx.getRequiredPersistentEntity(TypeWithEmbedded.class));

View File

@@ -30,11 +30,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.data.annotation.Id;
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
@@ -59,27 +61,29 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
* @author Christoph Strobl
* @author Marko Janković
*/
@RunWith(MockitoJUnitRunner.class)
public class UpdateMapperUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class UpdateMapperUnitTests {
CassandraMappingContext mappingContext = new CassandraMappingContext();
private CassandraMappingContext mappingContext = new CassandraMappingContext();
CassandraPersistentEntity<?> persistentEntity;
private CassandraPersistentEntity<?> persistentEntity;
Currency currencyEUR = Currency.getInstance("EUR");
Currency currencyUSD = Currency.getInstance("USD");
private Currency currencyEUR = Currency.getInstance("EUR");
private Currency currencyUSD = Currency.getInstance("USD");
MappingCassandraConverter cassandraConverter;
private MappingCassandraConverter cassandraConverter;
UpdateMapper updateMapper;
private UpdateMapper updateMapper;
com.datastax.oss.driver.api.core.type.UserDefinedType manufacturer = UserDefinedTypeBuilder.forName("manufacturer")
private com.datastax.oss.driver.api.core.type.UserDefinedType manufacturer = UserDefinedTypeBuilder
.forName("manufacturer")
.withField("name", DataTypes.TEXT).build();
@Mock UserTypeResolver userTypeResolver;
@Before
public void before() {
@BeforeEach
void before() {
CassandraCustomConversions customConversions = new CassandraCustomConversions(
Collections.singletonList(CurrencyConverter.INSTANCE));
@@ -99,7 +103,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSimpleUpdate() {
void shouldCreateSimpleUpdate() {
Update update = updateMapper.getMappedObject(Update.empty().set("firstName", "foo"), persistentEntity);
@@ -108,7 +112,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-487
public void shouldReplaceUdtMap() {
void shouldReplaceUdtMap() {
Manufacturer manufacturer = new Manufacturer("foobar");
@@ -123,7 +127,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSetAtIndexUpdate() {
void shouldCreateSetAtIndexUpdate() {
Update update = updateMapper.getMappedObject(Update.empty().set("list").atIndex(10).to(currencyEUR),
persistentEntity);
@@ -133,7 +137,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateSetAtKeyUpdate() {
void shouldCreateSetAtKeyUpdate() {
Update update = updateMapper.getMappedObject(Update.empty().set("map").atKey("baz").to(currencyEUR),
persistentEntity);
@@ -143,7 +147,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-487
public void shouldCreateSetAtUdtKeyUpdate() {
void shouldCreateSetAtUdtKeyUpdate() {
Manufacturer manufacturer = new Manufacturer("foobar");
@@ -156,7 +160,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldAddToMap() {
void shouldAddToMap() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("map").entry("foo", currencyEUR),
persistentEntity);
@@ -166,7 +170,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-487
public void shouldAddUdtToMap() {
void shouldAddUdtToMap() {
Manufacturer manufacturer = new Manufacturer("foobar");
@@ -179,7 +183,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldPrependAllToList() {
void shouldPrependAllToList() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("list").prependAll("foo", currencyEUR),
persistentEntity);
@@ -189,7 +193,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldAppendAllToList() {
void shouldAppendAllToList() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("list").appendAll("foo", currencyEUR),
persistentEntity);
@@ -199,7 +203,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldRemoveFromList() {
void shouldRemoveFromList() {
Update update = updateMapper.getMappedObject(Update.empty().remove("list", currencyEUR), persistentEntity);
@@ -208,7 +212,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldClearList() {
void shouldClearList() {
Update update = updateMapper.getMappedObject(Update.empty().clear("list"), persistentEntity);
@@ -217,7 +221,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldPrependAllToSet() {
void shouldPrependAllToSet() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("set").prependAll(currencyUSD, currencyEUR),
persistentEntity);
@@ -227,7 +231,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldAppendAllToSet() {
void shouldAppendAllToSet() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("set").appendAll(currencyUSD, currencyEUR),
persistentEntity);
@@ -237,7 +241,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldPrependAllToSetViaColumnNameCollectionOfElements() {
void shouldPrependAllToSetViaColumnNameCollectionOfElements() {
Update update = updateMapper.getMappedObject(
Update.empty().addTo("set_col").prependAll(new LinkedHashSet<>(Arrays.asList(currencyUSD, currencyEUR))),
@@ -248,7 +252,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldAppendAllToSetViaColumnNameCollectionOfElements() {
void shouldAppendAllToSetViaColumnNameCollectionOfElements() {
Update update = updateMapper.getMappedObject(
Update.empty().addTo("set_col").appendAll(new LinkedHashSet<>(Arrays.asList(currencyUSD, currencyEUR))),
@@ -259,7 +263,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldAppendToSet() {
void shouldAppendToSet() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("set").append(currencyEUR),
persistentEntity);
@@ -269,7 +273,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldPrependToSet() {
void shouldPrependToSet() {
Update update = updateMapper.getMappedObject(Update.empty().addTo("set").prepend(currencyEUR),
persistentEntity);
@@ -279,7 +283,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-770
public void shouldRemoveFromSet() {
void shouldRemoveFromSet() {
Update update = updateMapper.getMappedObject(Update.empty().remove("set", currencyEUR), persistentEntity);
@@ -288,7 +292,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldClearSet() {
void shouldClearSet() {
Update update = updateMapper.getMappedObject(Update.empty().clear("set"), persistentEntity);
@@ -297,7 +301,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateIncrementUpdate() {
void shouldCreateIncrementUpdate() {
Update update = updateMapper.getMappedObject(Update.empty().increment("number"), persistentEntity);
@@ -306,7 +310,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-343
public void shouldCreateDecrementUpdate() {
void shouldCreateDecrementUpdate() {
Update update = updateMapper.getMappedObject(Update.empty().decrement("number"), persistentEntity);
@@ -315,7 +319,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-523
public void shouldMapTuple() {
void shouldMapTuple() {
Update update = this.updateMapper.getMappedObject(Update.empty().set("tuple", new MappedTuple("foo")),
this.persistentEntity);
@@ -325,7 +329,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-302, DATACASS-694
public void shouldMapTime() {
void shouldMapTime() {
Update update = this.updateMapper.getMappedObject(Update.empty().set("localTime", LocalTime.of(1, 2, 3)),
this.persistentEntity);
@@ -335,13 +339,13 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-523
public void referencingTupleElementsInQueryShouldFail() {
void referencingTupleElementsInQueryShouldFail() {
assertThatIllegalArgumentException().isThrownBy(
() -> this.updateMapper.getMappedObject(Update.empty().set("tuple.zip", "bar"), this.persistentEntity));
}
@Test // DATACASS-167
public void shouldMapEmbeddedEntity() {
void shouldMapEmbeddedEntity() {
Update update = this.updateMapper.getMappedObject(Update.empty().set("nested.firstname", "spring"),
mappingContext.getRequiredPersistentEntity(WithNullableEmbeddedType.class));
@@ -351,7 +355,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATACASS-167
public void shouldMapPrefixedEmbeddedEntity() {
void shouldMapPrefixedEmbeddedEntity() {
Update update = this.updateMapper.getMappedObject(Update.empty().set("nested.firstname", "spring"),
mappingContext.getRequiredPersistentEntity(WithPrefixedNullableEmbeddedType.class));

View File

@@ -23,10 +23,10 @@ import java.util.Map;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
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.test.util.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
import org.springframework.util.concurrent.CompletableToListenableFutureAdapter;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
@@ -36,13 +36,13 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
*
* @author Mark Paluch
*/
public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
private static final AtomicBoolean initialized = new AtomicBoolean();
private AsyncCqlTemplate template;
@Before
public void before() {
@BeforeEach
void before() {
if (initialized.compareAndSet(false, true)) {
session.execute("CREATE TABLE IF NOT EXISTS user (id text PRIMARY KEY, username text);");
@@ -56,7 +56,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void executeShouldRemoveRecords() {
void executeShouldRemoveRecords() {
getUninterruptibly(template.execute("DELETE FROM user WHERE id = 'WHITE'"));
@@ -64,7 +64,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryShouldInvokeCallback() {
void queryShouldInvokeCallback() {
List<String> result = new ArrayList<>();
getUninterruptibly(template.query("SELECT id FROM user;", row -> {
@@ -75,7 +75,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryForObjectShouldReturnFirstColumn() {
void queryForObjectShouldReturnFirstColumn() {
String id = getUninterruptibly(template.queryForObject("SELECT id FROM user;", String.class));
@@ -83,7 +83,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryForObjectShouldReturnMap() {
void queryForObjectShouldReturnMap() {
Map<String, Object> map = getUninterruptibly(template.queryForMap("SELECT * FROM user;"));
@@ -91,7 +91,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void executeStatementShouldRemoveRecords() {
void executeStatementShouldRemoveRecords() {
getUninterruptibly(template.execute(SimpleStatement.newInstance("DELETE FROM user WHERE id = 'WHITE'")));
@@ -99,7 +99,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryStatementShouldInvokeCallback() {
void queryStatementShouldInvokeCallback() {
List<String> result = new ArrayList<>();
getUninterruptibly(template.query(SimpleStatement.newInstance("SELECT id FROM user"), row -> {
@@ -110,7 +110,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnFirstColumn() {
void queryForObjectStatementShouldReturnFirstColumn() {
String id = getUninterruptibly(
template.queryForObject(SimpleStatement.newInstance("SELECT id FROM user"), String.class));
@@ -119,7 +119,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnMap() {
void queryForObjectStatementShouldReturnMap() {
Map<String, Object> map = getUninterruptibly(
template.queryForMap(SimpleStatement.newInstance("SELECT * FROM user")));
@@ -128,7 +128,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void executeWithArgsShouldRemoveRecords() {
void executeWithArgsShouldRemoveRecords() {
getUninterruptibly(template.execute("DELETE FROM user WHERE id = ?", "WHITE"));
@@ -136,7 +136,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryPreparedStatementShouldInvokeCallback() {
void queryPreparedStatementShouldInvokeCallback() {
List<String> result = new ArrayList<>();
getUninterruptibly(template.query("SELECT id FROM user WHERE id = ?;", row -> {
@@ -147,7 +147,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldInvokeCallback() {
void queryPreparedStatementCreatorShouldInvokeCallback() {
List<String> result = new ArrayList<>();
getUninterruptibly(template.query(session -> new CompletableToListenableFutureAdapter<>(
@@ -159,7 +159,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnFirstColumn() {
void queryForObjectWithArgsShouldReturnFirstColumn() {
String id = getUninterruptibly(template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE"));
@@ -167,7 +167,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
}
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnMap() {
void queryForObjectWithArgsShouldReturnMap() {
Map<String, Object> map = getUninterruptibly(template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE"));

View File

@@ -28,12 +28,14 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;
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.dao.EmptyResultDataAccessException;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
@@ -60,7 +62,8 @@ import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class AsyncCqlTemplateUnitTests {
@Mock CqlSession session;
@@ -70,10 +73,10 @@ public class AsyncCqlTemplateUnitTests {
@Mock BoundStatement boundStatement;
@Mock ColumnDefinitions columnDefinitions;
AsyncCqlTemplate template;
private AsyncCqlTemplate template;
@Before
public void setup() {
@BeforeEach
void setup() {
this.template = new AsyncCqlTemplate();
this.template.setSession(session);
@@ -84,7 +87,7 @@ public class AsyncCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void executeCallbackShouldTranslateExceptions() {
void executeCallbackShouldTranslateExceptions() {
try {
template.execute((AsyncSessionCallback<String>) session -> {
@@ -98,7 +101,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeCqlShouldTranslateExceptions() throws Exception {
void executeCqlShouldTranslateExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture.failed(new NoNodeAvailableException());
when(session.executeAsync(any(Statement.class))).thenReturn(resultSetFuture);
@@ -120,7 +123,7 @@ public class AsyncCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void executeCqlShouldCallExecution() {
void executeCqlShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -131,7 +134,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeCqlWithArgumentsShouldCallExecution() {
void executeCqlWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, asyncCqlTemplate -> {
@@ -142,7 +145,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForResultSetShouldCallExecution() {
void queryForResultSetShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -154,7 +157,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetExtractorShouldCallExecution() {
void queryWithResultSetExtractorShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -167,7 +170,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, asyncCqlTemplate -> {
@@ -180,7 +183,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryCqlShouldTranslateExceptions() throws Exception {
void queryCqlShouldTranslateExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture.failed(new NoNodeAvailableException());
when(session.executeAsync(any(Statement.class))).thenReturn(resultSetFuture);
@@ -199,7 +202,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldBeEmpty() throws Exception {
void queryForObjectCqlShouldBeEmpty() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.emptyList());
@@ -217,7 +220,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnRecord() {
void queryForObjectCqlShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -227,7 +230,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnNullValue() {
void queryForObjectCqlShouldReturnNullValue() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -237,7 +240,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldFailReturningManyRecords() throws Exception {
void queryForObjectCqlShouldFailReturningManyRecords() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Arrays.asList(row, row));
@@ -254,7 +257,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlWithTypeShouldReturnRecord() {
void queryForObjectCqlWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -268,7 +271,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForListCqlWithTypeShouldReturnRecord() {
void queryForListCqlWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Arrays.asList(row, row));
@@ -282,7 +285,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeCqlShouldReturnWasApplied() {
void executeCqlShouldReturnWasApplied() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.wasApplied()).thenReturn(true);
@@ -297,7 +300,7 @@ public class AsyncCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void executeStatementShouldCallExecution() {
void executeStatementShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -308,7 +311,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeStatementWithArgumentsShouldCallExecution() {
void executeStatementWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, asyncCqlTemplate -> {
@@ -319,7 +322,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForResultStatementSetShouldCallExecution() {
void queryForResultStatementSetShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -332,7 +335,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorShouldCallExecution() {
void queryWithResultSetStatementExtractorShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -345,7 +348,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, asyncCqlTemplate -> {
@@ -358,7 +361,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryStatementShouldTranslateExceptions() throws Exception {
void queryStatementShouldTranslateExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture.failed(new NoNodeAvailableException());
when(session.executeAsync(any(Statement.class))).thenReturn(resultSetFuture);
@@ -377,7 +380,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldBeEmpty() throws Exception {
void queryForObjectStatementShouldBeEmpty() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.emptyList());
@@ -396,7 +399,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnRecord() {
void queryForObjectStatementShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -407,7 +410,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnNullValue() {
void queryForObjectStatementShouldReturnNullValue() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -418,7 +421,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldFailReturningManyRecords() throws Exception {
void queryForObjectStatementShouldFailReturningManyRecords() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Arrays.asList(row, row));
@@ -436,7 +439,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementWithTypeShouldReturnRecord() {
void queryForObjectStatementWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -451,7 +454,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForListStatementWithTypeShouldReturnRecord() {
void queryForListStatementWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Arrays.asList(row, row));
@@ -466,7 +469,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeStatementShouldReturnWasApplied() {
void executeStatementShouldReturnWasApplied() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.wasApplied()).thenReturn(true);
@@ -481,7 +484,7 @@ public class AsyncCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void queryPreparedStatementWithCallbackShouldCallExecution() {
void queryPreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -497,7 +500,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executePreparedStatementWithCallbackShouldCallExecution() {
void executePreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(asyncCqlTemplate -> {
@@ -511,7 +514,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() throws Exception {
void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() throws Exception {
try {
template.execute(session -> {
@@ -537,7 +540,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() throws Exception {
void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() throws Exception {
ListenableFuture<?> future = template.execute(session -> new AsyncResult<>(preparedStatement), (session, ps) -> {
throw new NoNodeAvailableException();
@@ -554,7 +557,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldReturnResult() {
void queryPreparedStatementCreatorShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
when(session.executeAsync(boundStatement)).thenReturn(new TestResultSetFuture(resultSet));
@@ -568,7 +571,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
when(session.executeAsync(boundStatement)).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -584,7 +587,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslatePrepareStatementExceptions() throws Exception {
void queryPreparedStatementCreatorAndBinderShouldTranslatePrepareStatementExceptions() throws Exception {
ListenableFuture<AsyncResultSet> future = template
.query(session -> AsyncResult.forExecutionException(new NoNodeAvailableException()), ps -> {
@@ -602,7 +605,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateBindExceptions() throws Exception {
void queryPreparedStatementCreatorAndBinderShouldTranslateBindExceptions() throws Exception {
ListenableFuture<AsyncResultSet> future = template.query(session -> new AsyncResult<>(preparedStatement), ps -> {
throw new NoNodeAvailableException();
@@ -617,7 +620,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateExecutionExceptions() throws Exception {
void queryPreparedStatementCreatorAndBinderShouldTranslateExecutionExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture.failed(new NoNodeAvailableException());
@@ -637,7 +640,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
when(session.executeAsync(boundStatement)).thenReturn(new TestResultSetFuture(resultSet));
when(resultSet.currentPage()).thenReturn(Collections.singleton(row));
@@ -652,7 +655,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldBeEmpty() throws Exception {
void queryForObjectPreparedStatementShouldBeEmpty() throws Exception {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
.thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -674,7 +677,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldReturnRecord() {
void queryForObjectPreparedStatementShouldReturnRecord() {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
.thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -688,7 +691,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldFailReturningManyRecords() throws Exception {
void queryForObjectPreparedStatementShouldFailReturningManyRecords() throws Exception {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
.thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -709,7 +712,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
.thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -726,7 +729,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForListPreparedStatementWithTypeShouldReturnRecord() {
void queryForListPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
.thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -744,7 +747,7 @@ public class AsyncCqlTemplateUnitTests {
}
@Test // DATACASS-292
public void updatePreparedStatementShouldReturnApplied() {
void updatePreparedStatementShouldReturnApplied() {
when(session.prepareAsync("UPDATE user SET username = ?"))
.thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -808,9 +811,9 @@ public class AsyncCqlTemplateUnitTests {
private static class TestResultSetFuture extends CompletableFuture<AsyncResultSet> {
public TestResultSetFuture() {}
private TestResultSetFuture() {}
public TestResultSetFuture(AsyncResultSet result) {
private TestResultSetFuture(AsyncResultSet result) {
complete(result);
}
@@ -820,7 +823,7 @@ public class AsyncCqlTemplateUnitTests {
* @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);
@@ -832,7 +835,7 @@ public class AsyncCqlTemplateUnitTests {
public TestPreparedStatementFuture() {}
public TestPreparedStatementFuture(PreparedStatement ps) {
private TestPreparedStatementFuture(PreparedStatement ps) {
complete(ps);
}

View File

@@ -25,7 +25,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.util.concurrent.ListenableFuture;
@@ -37,15 +37,15 @@ import com.datastax.oss.driver.api.core.cql.Row;
*
* @author Mark Paluch
*/
public class AsyncResultStreamUnitTests {
class AsyncResultStreamUnitTests {
AsyncResultSet first = mock(AsyncResultSet.class);
AsyncResultSet last = mock(AsyncResultSet.class);
Row row1 = mock(Row.class);
Row row2 = mock(Row.class);
private AsyncResultSet first = mock(AsyncResultSet.class);
private AsyncResultSet last = mock(AsyncResultSet.class);
private Row row1 = mock(Row.class);
private Row row2 = mock(Row.class);
@Test // DATACASS-656
public void shouldIterateFirstPage() {
void shouldIterateFirstPage() {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));
@@ -57,7 +57,7 @@ public class AsyncResultStreamUnitTests {
}
@Test // DATACASS-656
public void shouldIterateMappedFirstPage() {
void shouldIterateMappedFirstPage() {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));
@@ -69,7 +69,7 @@ public class AsyncResultStreamUnitTests {
}
@Test // DATACASS-656
public void shouldIterateMappedPages() {
void shouldIterateMappedPages() {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));
when(last.currentPage()).thenReturn(Collections.singletonList(row2));
@@ -84,7 +84,7 @@ public class AsyncResultStreamUnitTests {
}
@Test // DATACASS-656
public void shouldPropagateExceptionOnIterate() {
void shouldPropagateExceptionOnIterate() {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));
@@ -102,7 +102,7 @@ public class AsyncResultStreamUnitTests {
}
@Test // DATACASS-656
public void shouldCollectFirstPage() throws ExecutionException, InterruptedException {
void shouldCollectFirstPage() throws ExecutionException, InterruptedException {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));
@@ -112,7 +112,7 @@ public class AsyncResultStreamUnitTests {
}
@Test // DATACASS-656
public void shouldCollectMappedPages() throws ExecutionException, InterruptedException {
void shouldCollectMappedPages() throws ExecutionException, InterruptedException {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));
when(last.currentPage()).thenReturn(Collections.singletonList(row2));
@@ -126,7 +126,7 @@ public class AsyncResultStreamUnitTests {
}
@Test // DATACASS-656
public void shouldPropagateExceptionOnCollect() {
void shouldPropagateExceptionOnCollect() {
when(first.currentPage()).thenReturn(Collections.singletonList(row1));

View File

@@ -28,46 +28,49 @@ import java.lang.reflect.Proxy;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
/**
* Unit tests for {@link CachedPreparedStatementCreator}.
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class CachedPreparedStatementCreatorUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class CachedPreparedStatementCreatorUnitTests {
PreparedStatement preparedStatement;
private PreparedStatement preparedStatement;
@Mock CqlSession sessionMock;
@Before
public void before() throws Exception {
@BeforeEach
void before() throws Exception {
preparedStatement = newProxy(PreparedStatement.class, new TestInvocationHandler());
when(sessionMock.prepare(anyString())).thenReturn(preparedStatement);
}
@Test // DATACASS-253
public void shouldRejectEmptyCql() {
void shouldRejectEmptyCql() {
assertThatIllegalArgumentException().isThrownBy(() -> new CachedPreparedStatementCreator(""));
}
@Test // DATACASS-253
public void shouldRejectNullCql() {
void shouldRejectNullCql() {
assertThatIllegalArgumentException().isThrownBy(() -> new CachedPreparedStatementCreator(null));
}
@Test // DATACASS-253
public void shouldCreatePreparedStatement() {
void shouldCreatePreparedStatement() {
CachedPreparedStatementCreator cachedPreparedStatementCreator = new CachedPreparedStatementCreator("my cql");
@@ -78,7 +81,7 @@ public class CachedPreparedStatementCreatorUnitTests {
}
@Test // DATACASS-253
public void shouldCacheCreatePreparedStatement() {
void shouldCacheCreatePreparedStatement() {
CachedPreparedStatementCreator cachedPreparedStatementCreator = new CachedPreparedStatementCreator("my cql");
@@ -92,7 +95,7 @@ public class CachedPreparedStatementCreatorUnitTests {
}
@Test // DATACASS-253
public void concurrentAccessToCreateStatementShouldBeSynchronized() throws Throwable {
void concurrentAccessToCreateStatementShouldBeSynchronized() throws Throwable {
CreatePreparedStatementIsThreadSafe concurrentPrepareStatement = new CreatePreparedStatementIsThreadSafe(
preparedStatement, new CachedPreparedStatementCreator("my cql"));
@@ -104,10 +107,10 @@ public class CachedPreparedStatementCreatorUnitTests {
private static class CreatePreparedStatementIsThreadSafe extends MultithreadedTestCase {
final AtomicInteger atomicInteger = new AtomicInteger();
final CachedPreparedStatementCreator preparedStatementCreator;
final CqlSession session;
private final CachedPreparedStatementCreator preparedStatementCreator;
private final CqlSession session;
public CreatePreparedStatementIsThreadSafe(final PreparedStatement preparedStatement,
private CreatePreparedStatementIsThreadSafe(final PreparedStatement preparedStatement,
CachedPreparedStatementCreator preparedStatementCreator) {
this.preparedStatementCreator = preparedStatementCreator;

View File

@@ -17,11 +17,11 @@ package org.springframework.data.cassandra.core.cql;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import com.datastax.oss.driver.api.core.CqlSession;
@@ -32,21 +32,21 @@ import com.datastax.oss.driver.api.core.CqlSession;
* @author John Blum
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class CassandraAccessorUnitTests {
@ExtendWith(MockitoExtension.class)
class CassandraAccessorUnitTests {
private CassandraAccessor cassandraAccessor;
@Mock private CassandraExceptionTranslator mockExceptionTranslator;
@Mock private CqlSession mockSession;
@Before
public void setup() {
@BeforeEach
void setup() {
cassandraAccessor = new CassandraAccessor();
}
@Test // DATACASS-286, DATACASS-330
public void afterPropertiesSetWithUnitializedSessionThrowsIllegalStateException() {
void afterPropertiesSetWithUnitializedSessionThrowsIllegalStateException() {
try {
cassandraAccessor.afterPropertiesSet();
@@ -57,14 +57,14 @@ public class CassandraAccessorUnitTests {
}
@Test // DATACASS-286
public void setAndGetExceptionTranslator() {
void setAndGetExceptionTranslator() {
cassandraAccessor.setExceptionTranslator(mockExceptionTranslator);
assertThat(cassandraAccessor.getExceptionTranslator()).isSameAs(mockExceptionTranslator);
}
@Test // DATACASS-286
public void setExceptionTranslatorToNullThrowsIllegalArgumentException() {
void setExceptionTranslatorToNullThrowsIllegalArgumentException() {
try {
cassandraAccessor.setExceptionTranslator(null);
@@ -75,14 +75,14 @@ public class CassandraAccessorUnitTests {
}
@Test // DATACASS-286
public void setAndGetSession() {
void setAndGetSession() {
cassandraAccessor.setSession(mockSession);
assertThat(cassandraAccessor.getSessionFactory().getSession()).isSameAs(mockSession);
}
@Test // DATACASS-286
public void setSessionToNullThrowsIllegalArgumentException() {
void setSessionToNullThrowsIllegalArgumentException() {
try {
cassandraAccessor.setSession(null);
@@ -93,7 +93,7 @@ public class CassandraAccessorUnitTests {
}
@Test // DATACASS-286, DATACASS-330
public void getUninitializedSessionThrowsIllegalStateException() {
void getUninitializedSessionThrowsIllegalStateException() {
try {
cassandraAccessor.getSession();

View File

@@ -23,7 +23,7 @@ import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataAccessResourceFailureException;
@@ -52,15 +52,15 @@ import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint;
* @author Matthew T. Adams
* @author Mark Paluch
*/
public class CassandraExceptionTranslatorUnitTests {
class CassandraExceptionTranslatorUnitTests {
InetSocketAddress socketAddress = new InetSocketAddress("localhost", 42);
EndPoint endPoint = new DefaultEndPoint(socketAddress);
Node node = mock(Node.class);
CassandraExceptionTranslator sut = new CassandraExceptionTranslator();
private InetSocketAddress socketAddress = new InetSocketAddress("localhost", 42);
private EndPoint endPoint = new DefaultEndPoint(socketAddress);
private Node node = mock(Node.class);
private CassandraExceptionTranslator sut = new CassandraExceptionTranslator();
@Test // DATACASS-402
public void shouldTranslateAuthenticationException() {
void shouldTranslateAuthenticationException() {
DataAccessException result = sut.translateExceptionIfPossible(new AuthenticationException(endPoint, "message"));
@@ -69,7 +69,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateNoHostAvailableException() {
void shouldTranslateNoHostAvailableException() {
DataAccessException result = sut.translateExceptionIfPossible(new NoNodeAvailableException());
@@ -78,7 +78,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateInvalidQueryException() {
void shouldTranslateInvalidQueryException() {
DataAccessException result = sut.translateExceptionIfPossible(new InvalidQueryException(node, "message"));
@@ -87,7 +87,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateInvalidConfigurationInQueryException() {
void shouldTranslateInvalidConfigurationInQueryException() {
DataAccessException result = sut
.translateExceptionIfPossible(new InvalidConfigurationInQueryException(node, "message"));
@@ -97,7 +97,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateUnauthorizedException() {
void shouldTranslateUnauthorizedException() {
DataAccessException result = sut.translateExceptionIfPossible(new UnauthorizedException(node, "message"));
@@ -106,7 +106,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateSyntaxError() {
void shouldTranslateSyntaxError() {
DataAccessException result = sut.translateExceptionIfPossible(new SyntaxError(node, "message"));
@@ -115,7 +115,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateKeyspaceExistsException() {
void shouldTranslateKeyspaceExistsException() {
AlreadyExistsException cx = new AlreadyExistsException(node, "keyspace", "");
DataAccessException result = sut.translateExceptionIfPossible(cx);
@@ -127,7 +127,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateUnavailableException() {
void shouldTranslateUnavailableException() {
DataAccessException result = sut
.translateExceptionIfPossible(new UnavailableException(node, DefaultConsistencyLevel.ALL, 5, 1));
@@ -137,7 +137,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateBootstrappingException() {
void shouldTranslateBootstrappingException() {
DataAccessException result = sut.translateExceptionIfPossible(new BootstrappingException(node));
@@ -146,7 +146,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateOverloadedException() {
void shouldTranslateOverloadedException() {
DataAccessException result = sut.translateExceptionIfPossible(new OverloadedException(node));
@@ -155,7 +155,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateTruncateException() {
void shouldTranslateTruncateException() {
DataAccessException result = sut.translateExceptionIfPossible(new TruncateException(node, "message"));
@@ -164,7 +164,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateWriteFailureException() {
void shouldTranslateWriteFailureException() {
DataAccessException result = sut.translateExceptionIfPossible(
new WriteFailureException(node, DefaultConsistencyLevel.ALL, 1, 5, WriteType.BATCH, 1, Collections.emptyMap()));
@@ -174,7 +174,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateReadFailureException() {
void shouldTranslateReadFailureException() {
DataAccessException result = sut.translateExceptionIfPossible(
new ReadFailureException(node, DefaultConsistencyLevel.ALL, 1, 5, 1, true, Collections.emptyMap()));
@@ -184,7 +184,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateWriteTimeoutException() {
void shouldTranslateWriteTimeoutException() {
DataAccessException result = sut.translateExceptionIfPossible(
new WriteTimeoutException(node, DefaultConsistencyLevel.ALL, 1, 5, WriteType.BATCH));
@@ -194,7 +194,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateReadTimeoutException() {
void shouldTranslateReadTimeoutException() {
DataAccessException result = sut
.translateExceptionIfPossible(new ReadTimeoutException(node, DefaultConsistencyLevel.ALL, 1, 5, true));
@@ -204,7 +204,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateBusyConnectionException() {
void shouldTranslateBusyConnectionException() {
DataAccessException result = sut.translateExceptionIfPossible(new BusyConnectionException(2));
@@ -213,7 +213,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateFrameTooLongException() {
void shouldTranslateFrameTooLongException() {
DataAccessException result = sut.translateExceptionIfPossible(new FrameTooLongException(socketAddress, "foo"));
@@ -222,7 +222,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-402
public void shouldTranslateToUncategorized() {
void shouldTranslateToUncategorized() {
assertThat(
sut.translateExceptionIfPossible(new CodecNotFoundException(DataTypes.ASCII, GenericType.of(String.class))))
@@ -233,7 +233,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@Test // DATACASS-335
public void shouldTranslateWithCqlMessage() {
void shouldTranslateWithCqlMessage() {
InvalidConfigurationInQueryException cx = new InvalidConfigurationInQueryException(node, "err");
DataAccessException dax = sut.translate("Query", "SELECT * FROM person", cx);
@@ -243,7 +243,7 @@ public class CassandraExceptionTranslatorUnitTests {
}
@SuppressWarnings("unchecked")
public <T> T createInstance(String className, Class<?> argTypes[], Object... args)
<T> T createInstance(String className, Class<?> argTypes[], Object... args)
throws ReflectiveOperationException {
Class<T> exceptionClass = (Class) ClassUtils.forName(className, getClass().getClassLoader());

View File

@@ -18,7 +18,7 @@ package org.springframework.data.cassandra.core.cql;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.cassandra.core.cql.CqlIdentifier.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link CqlIdentifier}.
@@ -26,10 +26,10 @@ import org.junit.Test;
* @author John McPeek
* @author Matthew T. Adams
*/
public class CqlIdentifierUnitTests {
class CqlIdentifierUnitTests {
@Test
public void testUnquotedIdentifiers() {
void testUnquotedIdentifiers() {
String[] ids = new String[] { "foo", "Foo", "FOO", "a_", "a1" };
@@ -41,7 +41,7 @@ public class CqlIdentifierUnitTests {
}
@Test
public void testForceQuotedIdentifiers() {
void testForceQuotedIdentifiers() {
String[] ids = new String[] { "foo", "Foo", "FOO", "a_", "a1" };
@@ -53,7 +53,7 @@ public class CqlIdentifierUnitTests {
}
@Test
public void testReservedWordsEndUpQuoted() {
void testReservedWordsEndUpQuoted() {
for (ReservedKeyword id : ReservedKeyword.values()) {
CqlIdentifier cqlId = of(id.name());
@@ -67,7 +67,7 @@ public class CqlIdentifierUnitTests {
}
@Test
public void testIllegals() {
void testIllegals() {
String[] illegals = new String[] { null, "", "a ", "a a", "a\"", "a'", "a''", "\"\"", "''", "-", "a-", "_", "_a" };
for (String illegal : illegals) {
try {

View File

@@ -22,10 +22,10 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
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.test.util.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
@@ -34,13 +34,13 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
*
* @author Mark Paluch
*/
public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
static final AtomicBoolean initialized = new AtomicBoolean();
CqlTemplate template;
private static final AtomicBoolean initialized = new AtomicBoolean();
private CqlTemplate template;
@Before
public void before() {
@BeforeEach
void before() {
if (initialized.compareAndSet(false, true)) {
session.execute("CREATE TABLE IF NOT EXISTS user (id text PRIMARY KEY, username text);");
@@ -54,7 +54,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void executeShouldRemoveRecords() {
void executeShouldRemoveRecords() {
template.execute("DELETE FROM user WHERE id = 'WHITE'");
@@ -62,7 +62,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryShouldInvokeCallback() {
void queryShouldInvokeCallback() {
List<String> result = new ArrayList<>();
template.query("SELECT id FROM user;", row -> {
@@ -73,7 +73,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryForObjectShouldReturnFirstColumn() {
void queryForObjectShouldReturnFirstColumn() {
String id = template.queryForObject("SELECT id FROM user;", String.class);
@@ -81,7 +81,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryForObjectShouldReturnMap() {
void queryForObjectShouldReturnMap() {
Map<String, Object> map = template.queryForMap("SELECT * FROM user;");
@@ -89,7 +89,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void executeStatementShouldRemoveRecords() {
void executeStatementShouldRemoveRecords() {
template.execute(SimpleStatement.newInstance("DELETE FROM user WHERE id = 'WHITE'"));
@@ -97,7 +97,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryStatementShouldInvokeCallback() {
void queryStatementShouldInvokeCallback() {
List<String> result = new ArrayList<>();
template.query(SimpleStatement.newInstance("SELECT id FROM user"), row -> {
@@ -108,7 +108,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnFirstColumn() {
void queryForObjectStatementShouldReturnFirstColumn() {
String id = template.queryForObject(SimpleStatement.newInstance("SELECT id FROM user"), String.class);
@@ -116,7 +116,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnMap() {
void queryForObjectStatementShouldReturnMap() {
Map<String, Object> map = template.queryForMap(SimpleStatement.newInstance("SELECT * FROM user"));
@@ -124,7 +124,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void executeWithArgsShouldRemoveRecords() {
void executeWithArgsShouldRemoveRecords() {
template.execute("DELETE FROM user WHERE id = ?", "WHITE");
@@ -132,7 +132,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryPreparedStatementShouldInvokeCallback() {
void queryPreparedStatementShouldInvokeCallback() {
List<String> result = new ArrayList<>();
template.query("SELECT id FROM user WHERE id = ?;", row -> {
@@ -143,7 +143,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldInvokeCallback() {
void queryPreparedStatementCreatorShouldInvokeCallback() {
List<String> result = new ArrayList<>();
template.query(session -> session.prepare("SELECT id FROM user WHERE id = ?;"), ps -> ps.bind("WHITE"), row -> {
@@ -154,7 +154,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnFirstColumn() {
void queryForObjectWithArgsShouldReturnFirstColumn() {
String id = template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE");
@@ -162,7 +162,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
}
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnMap() {
void queryForObjectWithArgsShouldReturnMap() {
Map<String, Object> map = template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE");

View File

@@ -25,12 +25,14 @@ import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
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.dao.EmptyResultDataAccessException;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
@@ -56,8 +58,9 @@ import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class CqlTemplateUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class CqlTemplateUnitTests {
@Mock CqlSession session;
@Mock ResultSet resultSet;
@@ -66,10 +69,10 @@ public class CqlTemplateUnitTests {
@Mock BoundStatement boundStatement;
@Mock ColumnDefinitions columnDefinitions;
CqlTemplate template;
private CqlTemplate template;
@Before
public void setup() {
@BeforeEach
void setup() {
this.template = new CqlTemplate();
this.template.setSession(session);
@@ -80,7 +83,7 @@ public class CqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void executeCallbackShouldTranslateExceptions() {
void executeCallbackShouldTranslateExceptions() {
try {
template.execute((SessionCallback<String>) session -> {
@@ -94,7 +97,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeCqlShouldTranslateExceptions() {
void executeCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException());
@@ -111,7 +114,7 @@ public class CqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void executeCqlShouldCallExecution() {
void executeCqlShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -122,7 +125,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeCqlWithArgumentsShouldCallExecution() {
void executeCqlWithArgumentsShouldCallExecution() {
doTestStrings(5, DefaultConsistencyLevel.ONE, null, "foo", cqlTemplate -> {
@@ -133,7 +136,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForResultSetShouldCallExecution() {
void queryForResultSetShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -145,7 +148,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetExtractorShouldCallExecution() {
void queryWithResultSetExtractorShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -157,7 +160,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, ConsistencyLevel.EACH_QUORUM, "foo", cqlTemplate -> {
@@ -169,7 +172,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryCqlShouldTranslateExceptions() {
void queryCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException());
@@ -182,7 +185,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldBeEmpty() {
void queryForObjectCqlShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.emptyIterator());
@@ -196,7 +199,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnRecord() {
void queryForObjectCqlShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -206,7 +209,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnNullValue() {
void queryForObjectCqlShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -216,7 +219,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlShouldFailReturningManyRecords() {
void queryForObjectCqlShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Arrays.asList(row, row).iterator());
@@ -230,7 +233,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectCqlWithTypeShouldReturnRecord() {
void queryForObjectCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -244,7 +247,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForListCqlWithTypeShouldReturnRecord() {
void queryForListCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Arrays.asList(row, row).iterator());
@@ -258,7 +261,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeCqlShouldReturnWasApplied() {
void executeCqlShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.wasApplied()).thenReturn(true);
@@ -273,7 +276,7 @@ public class CqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void executeStatementShouldCallExecution() {
void executeStatementShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -284,7 +287,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeStatementWithArgumentsShouldCallExecution() {
void executeStatementWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, null, "foo", cqlTemplate -> {
@@ -295,7 +298,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForResultStatementSetShouldCallExecution() {
void queryForResultStatementSetShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -307,7 +310,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorShouldCallExecution() {
void queryWithResultSetStatementExtractorShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -320,7 +323,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, null, "foo", cqlTemplate -> {
@@ -333,7 +336,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryStatementShouldTranslateExceptions() {
void queryStatementShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException());
@@ -347,7 +350,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldBeEmpty() {
void queryForObjectStatementShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.emptyIterator());
@@ -362,7 +365,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnRecord() {
void queryForObjectStatementShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -372,7 +375,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnNullValue() {
void queryForObjectStatementShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -382,7 +385,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementShouldFailReturningManyRecords() {
void queryForObjectStatementShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Arrays.asList(row, row).iterator());
@@ -397,7 +400,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectStatementWithTypeShouldReturnRecord() {
void queryForObjectStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -411,7 +414,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForListStatementWithTypeShouldReturnRecord() {
void queryForListStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Arrays.asList(row, row).iterator());
@@ -425,7 +428,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executeStatementShouldReturnWasApplied() {
void executeStatementShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
when(resultSet.wasApplied()).thenReturn(true);
@@ -440,7 +443,7 @@ public class CqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-292
public void queryPreparedStatementWithCallbackShouldCallExecution() {
void queryPreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -455,7 +458,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executePreparedStatementWithCallbackShouldCallExecution() {
void executePreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(cqlTemplate -> {
@@ -469,7 +472,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() {
void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() {
try {
template.execute(session -> {
@@ -483,7 +486,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() {
void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() {
try {
template.execute(session -> preparedStatement, (session, ps) -> {
@@ -497,7 +500,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldReturnResult() {
void queryPreparedStatementCreatorShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
when(session.execute(boundStatement)).thenReturn(resultSet);
@@ -510,7 +513,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
when(session.execute(boundStatement)).thenReturn(resultSet);
when(resultSet.iterator()).thenAnswer(it -> Collections.singleton(row).iterator());
@@ -526,7 +529,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslatePrepareStatementExceptions() {
void queryPreparedStatementCreatorAndBinderShouldTranslatePrepareStatementExceptions() {
try {
template.query(session -> {
@@ -543,7 +546,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateBindExceptions() {
void queryPreparedStatementCreatorAndBinderShouldTranslateBindExceptions() {
try {
template.query(session -> preparedStatement, ps -> {
@@ -557,7 +560,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateExecutionExceptions() {
void queryPreparedStatementCreatorAndBinderShouldTranslateExecutionExceptions() {
when(session.execute(boundStatement)).thenThrow(new NoNodeAvailableException());
@@ -574,7 +577,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
when(session.execute(boundStatement)).thenReturn(resultSet);
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -589,7 +592,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldBeEmpty() {
void queryForObjectPreparedStatementShouldBeEmpty() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -606,7 +609,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldReturnRecord() {
void queryForObjectPreparedStatementShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -618,7 +621,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldFailReturningManyRecords() {
void queryForObjectPreparedStatementShouldFailReturningManyRecords() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -635,7 +638,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -651,7 +654,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void queryForListPreparedStatementWithTypeShouldReturnRecord() {
void queryForListPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -667,7 +670,7 @@ public class CqlTemplateUnitTests {
}
@Test // DATACASS-292
public void updatePreparedStatementShouldReturnApplied() {
void updatePreparedStatementShouldReturnApplied() {
when(session.prepare("UPDATE user SET username = ?")).thenReturn(preparedStatement);
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);

View File

@@ -18,15 +18,14 @@ package org.springframework.data.cassandra.core.cql;
import static org.assertj.core.api.Assertions.*;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import reactor.test.StepVerifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.ReactiveResultSet;
import org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
import com.datastax.oss.driver.api.core.servererrors.SyntaxError;
@@ -36,12 +35,12 @@ import com.datastax.oss.driver.api.core.servererrors.SyntaxError;
*
* @author Mark Paluch
*/
public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
DefaultBridgedReactiveSession reactiveSession;
private DefaultBridgedReactiveSession reactiveSession;
@Before
public void before() {
@BeforeEach
void before() {
this.session.execute("DROP TABLE IF EXISTS users;");
@@ -49,7 +48,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
}
@Test // DATACASS-335
public void executeShouldExecuteDeferred() {
void executeShouldExecuteDeferred() {
String query = "CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");";
@@ -64,12 +63,12 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
}
@Test // DATACASS-335
public void executeShouldTransportExceptionsInMono() {
void executeShouldTransportExceptionsInMono() {
reactiveSession.execute("INSERT INTO dummy;").as(StepVerifier::create).expectError(SyntaxError.class).verify();
}
@Test // DATACASS-335
public void executeShouldReturnRows() {
void executeShouldReturnRows() {
session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");");
session.execute("INSERT INTO users (userid, first_name) VALUES ('White', 'Walter');");
@@ -81,7 +80,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
}
@Test // DATACASS-335
public void executeShouldPrepareStatement() {
void executeShouldPrepareStatement() {
session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");");

View File

@@ -27,12 +27,14 @@ import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
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.ArgumentMatchers;
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.core.cql.session.DefaultBridgedReactiveSession;
@@ -50,18 +52,19 @@ import com.datastax.oss.driver.api.core.cql.Statement;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.Silent.class)
public class DefaultBridgedReactiveSessionUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class DefaultBridgedReactiveSessionUnitTests {
@Mock CqlSession sessionMock;
CompletableFuture<AsyncResultSet> future = new CompletableFuture<>();
CompletableFuture<PreparedStatement> preparedStatementFuture = new CompletableFuture<>();
private CompletableFuture<AsyncResultSet> future = new CompletableFuture<>();
private CompletableFuture<PreparedStatement> preparedStatementFuture = new CompletableFuture<>();
private DefaultBridgedReactiveSession reactiveSession;
@Before
public void before() {
@BeforeEach
void before() {
reactiveSession = new DefaultBridgedReactiveSession(sessionMock);
@@ -69,7 +72,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void executeStatementShouldForwardStatementToSession() {
void executeStatementShouldForwardStatementToSession() {
Statement<?> statement = SimpleStatement.newInstance("SELECT *");
@@ -79,7 +82,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void executeShouldForwardStatementToSession() {
void executeShouldForwardStatementToSession() {
reactiveSession.execute("SELECT *").subscribe();
@@ -87,7 +90,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void executeWithValuesShouldForwardStatementToSession() {
void executeWithValuesShouldForwardStatementToSession() {
reactiveSession.execute("SELECT * WHERE a = ? and b = ?", "A", "B").subscribe();
@@ -95,7 +98,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void executeWithValueMapShouldForwardStatementToSession() {
void executeWithValueMapShouldForwardStatementToSession() {
reactiveSession.execute("SELECT * WHERE a = ?", Collections.singletonMap("a", "value")).subscribe();
@@ -104,7 +107,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void testPrepareQuery() {
void testPrepareQuery() {
when(sessionMock.prepareAsync(any(SimpleStatement.class))).thenReturn(preparedStatementFuture);
@@ -114,7 +117,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void testPrepareStatement() {
void testPrepareStatement() {
when(sessionMock.prepareAsync(any(SimpleStatement.class))).thenReturn(preparedStatementFuture);
@@ -125,7 +128,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void testClose() {
void testClose() {
reactiveSession.close();
@@ -133,7 +136,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-335
public void testIsClosed() {
void testIsClosed() {
when(reactiveSession.isClosed()).thenReturn(true);
@@ -144,7 +147,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-509
public void shouldNotReadMoreThanAvailable() {
void shouldNotReadMoreThanAvailable() {
AsyncResultSet resultSet = mock(AsyncResultSet.class);
@@ -162,7 +165,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-529
public void shouldReadAvailableResults() {
void shouldReadAvailableResults() {
AsyncResultSet resultSet = mock(AsyncResultSet.class);
when(resultSet.remaining()).thenReturn(10);
@@ -179,7 +182,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
}
@Test // DATACASS-509
public void shouldFetchMore() {
void shouldFetchMore() {
Iterator<Row> rows = mockIterator();

View File

@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core.cql;
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
import com.datastax.oss.driver.api.core.cql.Statement;
@@ -27,10 +27,10 @@ import com.datastax.oss.driver.api.core.cql.Statement;
*
* @author Mark Paluch
*/
public class ExecutionProfileResolverUnitTests {
class ExecutionProfileResolverUnitTests {
@Test // DATACASS-708
public void shouldSetProfileName() {
void shouldSetProfileName() {
Statement statement = mock(Statement.class);
@@ -40,7 +40,7 @@ public class ExecutionProfileResolverUnitTests {
}
@Test // DATACASS-708
public void shouldSetProfileObject() {
void shouldSetProfileObject() {
Statement statement = mock(Statement.class);
DriverExecutionProfile profile = mock(DriverExecutionProfile.class);

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import java.time.Duration;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
@@ -28,10 +28,10 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
*
* @author Mark Paluch
*/
public class QueryOptionsUnitTests {
class QueryOptionsUnitTests {
@Test // DATACASS-202
public void buildQueryOptions() {
void buildQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().consistencyLevel(DefaultConsistencyLevel.ANY)
.timeout(Duration.ofSeconds(1)).pageSize(10).tracing(true).build();
@@ -44,7 +44,7 @@ public class QueryOptionsUnitTests {
}
@Test // DATACASS-56
public void buildQueryOptionsMutate() {
void buildQueryOptionsMutate() {
QueryOptions queryOptions = QueryOptions.builder().consistencyLevel(DefaultConsistencyLevel.ANY)
.timeout(Duration.ofSeconds(1)).pageSize(10).tracing(true).build();

View File

@@ -20,10 +20,10 @@ import static org.mockito.Mockito.*;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
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 com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
@@ -34,13 +34,13 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
* @author John Blum
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class QueryOptionsUtilUnitTests {
@ExtendWith(MockitoExtension.class)
class QueryOptionsUtilUnitTests {
@Mock SimpleStatement simpleStatement;
@Test // DATACASS-202, DATACASS-708
public void addPreparedStatementOptionsShouldAddDriverQueryOptions() {
void addPreparedStatementOptionsShouldAddDriverQueryOptions() {
when(simpleStatement.setConsistencyLevel(any())).thenReturn(simpleStatement);
when(simpleStatement.setSerialConsistencyLevel(any())).thenReturn(simpleStatement);
@@ -60,7 +60,7 @@ public class QueryOptionsUtilUnitTests {
}
@Test // DATACASS-202
public void addStatementQueryOptionsShouldNotAddOptions() {
void addStatementQueryOptionsShouldNotAddOptions() {
QueryOptions queryOptions = QueryOptions.builder().build();
@@ -70,7 +70,7 @@ public class QueryOptionsUtilUnitTests {
}
@Test // DATACASS-202
public void addStatementQueryOptionsShouldAddGenericQueryOptions() {
void addStatementQueryOptionsShouldAddGenericQueryOptions() {
when(simpleStatement.setPageSize(anyInt())).thenReturn(simpleStatement);
when(simpleStatement.setTimeout(any())).thenReturn(simpleStatement);

View File

@@ -21,13 +21,13 @@ import reactor.test.StepVerifier;
import java.util.concurrent.atomic.AtomicBoolean;
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.ReactiveSession;
import org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession;
import org.springframework.data.cassandra.core.cql.session.DefaultReactiveSessionFactory;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
@@ -36,15 +36,15 @@ import com.datastax.oss.driver.api.core.cql.SimpleStatement;
*
* @author Mark Paluch
*/
public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
private static final AtomicBoolean initialized = new AtomicBoolean();
ReactiveSession reactiveSession;
ReactiveCqlTemplate template;
private ReactiveSession reactiveSession;
private ReactiveCqlTemplate template;
@Before
public void before() {
@BeforeEach
void before() {
reactiveSession = new DefaultBridgedReactiveSession(getSession());
@@ -59,7 +59,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void executeShouldRemoveRecords() {
void executeShouldRemoveRecords() {
template.execute("DELETE FROM user WHERE id = 'WHITE'").as(StepVerifier::create).expectNext(true).verifyComplete();
@@ -67,7 +67,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void queryForObjectShouldReturnFirstColumn() {
void queryForObjectShouldReturnFirstColumn() {
template.queryForObject("SELECT id FROM user;", String.class).as(StepVerifier::create) //
.expectNext("WHITE") //
@@ -75,7 +75,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void queryForObjectShouldReturnMap() {
void queryForObjectShouldReturnMap() {
template.queryForMap("SELECT * FROM user;").as(StepVerifier::create) //
.consumeNextWith(actual -> {
@@ -85,7 +85,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void executeStatementShouldRemoveRecords() {
void executeStatementShouldRemoveRecords() {
template.execute(SimpleStatement.newInstance("DELETE FROM user WHERE id = 'WHITE'")).as(StepVerifier::create) //
.expectNext(true) //
@@ -95,7 +95,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnFirstColumn() {
void queryForObjectStatementShouldReturnFirstColumn() {
template.queryForObject(SimpleStatement.newInstance("SELECT id FROM user"), String.class).as(StepVerifier::create) //
.expectNext("WHITE") //
@@ -103,7 +103,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnMap() {
void queryForObjectStatementShouldReturnMap() {
template.queryForMap(SimpleStatement.newInstance("SELECT * FROM user")).as(StepVerifier::create) //
.consumeNextWith(actual -> {
@@ -113,7 +113,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void executeWithArgsShouldRemoveRecords() {
void executeWithArgsShouldRemoveRecords() {
template.execute("DELETE FROM user WHERE id = ?", "WHITE").as(StepVerifier::create).expectNext(true)
.verifyComplete();
@@ -122,7 +122,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void queryForObjectWithArgsShouldReturnFirstColumn() {
void queryForObjectWithArgsShouldReturnFirstColumn() {
template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE").as(StepVerifier::create) //
.expectNext("WHITE") //
@@ -130,7 +130,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
}
@Test // DATACASS-335
public void queryForObjectWithArgsShouldReturnMap() {
void queryForObjectWithArgsShouldReturnMap() {
template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE").as(StepVerifier::create) //
.consumeNextWith(actual -> {

View File

@@ -25,12 +25,14 @@ import reactor.test.StepVerifier;
import java.util.function.Consumer;
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.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.cassandra.CassandraConnectionFailureException;
@@ -57,8 +59,9 @@ import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class ReactiveCqlTemplateUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class ReactiveCqlTemplateUnitTests {
@Mock ReactiveSession session;
@Mock ReactiveResultSet reactiveResultSet;
@@ -67,11 +70,11 @@ public class ReactiveCqlTemplateUnitTests {
@Mock BoundStatement boundStatement;
@Mock ColumnDefinitions columnDefinitions;
ReactiveCqlTemplate template;
ReactiveSessionFactory sessionFactory;
private ReactiveCqlTemplate template;
private ReactiveSessionFactory sessionFactory;
@Before
public void setup() throws Exception {
@BeforeEach
void setup() throws Exception {
this.sessionFactory = new DefaultReactiveSessionFactory(session);
this.template = new ReactiveCqlTemplate(sessionFactory);
@@ -82,7 +85,7 @@ public class ReactiveCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-335
public void executeCallbackShouldExecuteDeferred() {
void executeCallbackShouldExecuteDeferred() {
Flux<String> flux = template.execute((ReactiveSessionCallback<String>) session -> {
session.close();
@@ -96,7 +99,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeCallbackShouldTranslateExceptions() {
void executeCallbackShouldTranslateExceptions() {
Flux<String> flux = template.execute((ReactiveSessionCallback<String>) session -> {
throw new InvalidQueryException(null, "wrong query");
@@ -106,7 +109,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeCqlShouldExecuteDeferred() {
void executeCqlShouldExecuteDeferred() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -120,7 +123,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeCqlShouldTranslateExceptions() {
void executeCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException());
@@ -134,7 +137,7 @@ public class ReactiveCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-335
public void executeCqlShouldCallExecution() {
void executeCqlShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -145,7 +148,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeCqlWithArgumentsShouldCallExecution() {
void executeCqlWithArgumentsShouldCallExecution() {
doTestStrings(5, DefaultConsistencyLevel.ONE, null, "foo", reactiveCqlTemplate -> {
@@ -158,7 +161,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForResultSetShouldCallExecution() {
void queryForResultSetShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -171,7 +174,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryWithResultSetExtractorShouldCallExecution() {
void queryWithResultSetExtractorShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -184,7 +187,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, null, "foo", reactiveCqlTemplate -> {
@@ -197,7 +200,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryCqlShouldExecuteDeferred() {
void queryCqlShouldExecuteDeferred() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -212,7 +215,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryCqlShouldTranslateExceptions() {
void queryCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException());
@@ -222,7 +225,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectCqlShouldBeEmpty() {
void queryForObjectCqlShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.empty());
@@ -233,7 +236,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectCqlShouldReturnRecord() {
void queryForObjectCqlShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -244,7 +247,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectCqlShouldReturnNullValue() {
void queryForObjectCqlShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -255,7 +258,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectCqlShouldFailReturningManyRecords() {
void queryForObjectCqlShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row, row));
@@ -266,7 +269,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectCqlWithTypeShouldReturnRecord() {
void queryForObjectCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -280,7 +283,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForFluxCqlWithTypeShouldReturnRecord() {
void queryForFluxCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row, row));
@@ -294,7 +297,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForRowsCqlReturnRows() {
void queryForRowsCqlReturnRows() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row, row));
@@ -305,7 +308,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeCqlShouldReturnWasApplied() {
void executeCqlShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -316,7 +319,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeCqlPublisherShouldReturnWasApplied() {
void executeCqlPublisherShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.wasApplied()).thenReturn(true, false);
@@ -335,7 +338,7 @@ public class ReactiveCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-335
public void executeStatementShouldCallExecution() {
void executeStatementShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -348,7 +351,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeStatementWithArgumentsShouldCallExecution() {
void executeStatementWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DefaultConsistencyLevel.EACH_QUORUM, "foo", reactiveCqlTemplate -> {
@@ -361,7 +364,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForResultStatementSetShouldCallExecution() {
void queryForResultStatementSetShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -375,7 +378,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryWithResultSetStatementExtractorShouldCallExecution() {
void queryWithResultSetStatementExtractorShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -389,7 +392,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, null, "foo", reactiveCqlTemplate -> {
@@ -406,7 +409,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryStatementShouldExecuteDeferred() {
void queryStatementShouldExecuteDeferred() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -420,7 +423,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryStatementShouldTranslateExceptions() {
void queryStatementShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoNodeAvailableException());
@@ -431,7 +434,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectStatementShouldBeEmpty() {
void queryForObjectStatementShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.empty());
@@ -443,7 +446,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnRecord() {
void queryForObjectStatementShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -455,7 +458,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnNullValue() {
void queryForObjectStatementShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -467,7 +470,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectStatementShouldFailReturningManyRecords() {
void queryForObjectStatementShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row, row));
@@ -479,7 +482,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectStatementWithTypeShouldReturnRecord() {
void queryForObjectStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -493,7 +496,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForFluxStatementWithTypeShouldReturnRecord() {
void queryForFluxStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row, row));
@@ -507,7 +510,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForRowsStatementReturnRows() {
void queryForRowsStatementReturnRows() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row, row));
@@ -518,7 +521,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executeStatementShouldReturnWasApplied() {
void executeStatementShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -532,7 +535,7 @@ public class ReactiveCqlTemplateUnitTests {
// -------------------------------------------------------------------------
@Test // DATACASS-335
public void queryPreparedStatementWithCallbackShouldCallExecution() {
void queryPreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -546,7 +549,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executePreparedStatementWithCallbackShouldCallExecution() {
void executePreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(reactiveCqlTemplate -> {
@@ -559,7 +562,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executePreparedStatementCallbackShouldExecuteDeferred() {
void executePreparedStatementCallbackShouldExecuteDeferred() {
when(session.prepare(anyString())).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -577,7 +580,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executePreparedStatementCreatorShouldExecuteDeferred() {
void executePreparedStatementCreatorShouldExecuteDeferred() {
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
@@ -592,7 +595,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() {
void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() {
Flux<ReactiveResultSet> flux = template.execute(session -> {
throw new NoNodeAvailableException();
@@ -602,7 +605,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() {
void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() {
Flux<ReactiveResultSet> flux = template.execute(session -> Mono.just(preparedStatement), (session, ps) -> {
throw new NoNodeAvailableException();
@@ -612,7 +615,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryPreparedStatementCreatorShouldReturnResult() {
void queryPreparedStatementCreatorShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
@@ -627,7 +630,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -645,7 +648,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -663,7 +666,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectPreparedStatementShouldBeEmpty() {
void queryForObjectPreparedStatementShouldBeEmpty() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -677,7 +680,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectPreparedStatementShouldReturnRecord() {
void queryForObjectPreparedStatementShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -691,7 +694,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectPreparedStatementShouldFailReturningManyRecords() {
void queryForObjectPreparedStatementShouldFailReturningManyRecords() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -705,7 +708,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -721,7 +724,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForFluxPreparedStatementWithTypeShouldReturnRecord() {
void queryForFluxPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -737,7 +740,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void queryForRowsPreparedStatementReturnRows() {
void queryForRowsPreparedStatementReturnRows() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -750,7 +753,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void updatePreparedStatementShouldReturnApplied() {
void updatePreparedStatementShouldReturnApplied() {
when(session.prepare("UPDATE user SET username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);
@@ -763,7 +766,7 @@ public class ReactiveCqlTemplateUnitTests {
}
@Test // DATACASS-335
public void updatePreparedStatementArgsPublisherShouldReturnApplied() {
void updatePreparedStatementArgsPublisherShouldReturnApplied() {
when(session.prepare("UPDATE user SET username = ?")).thenReturn(Mono.just(preparedStatement));
when(preparedStatement.bind("Walter")).thenReturn(boundStatement);

View File

@@ -18,17 +18,19 @@ package org.springframework.data.cassandra.core.cql;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.dao.TypeMismatchDataAccessException;
import com.datastax.oss.driver.api.core.cql.ColumnDefinition;
import com.datastax.oss.driver.api.core.cql.ColumnDefinitions;
import com.datastax.oss.driver.api.core.cql.Row;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
/**
* Unit tests for {@link SingleColumnRowMapper}.
@@ -36,8 +38,9 @@ import com.datastax.oss.driver.api.core.cql.Row;
* @author Mark Paluch
* @soundtrack Kos Vs Michael Buffer - Go For It All (Rubberboot Mix)
*/
@RunWith(MockitoJUnitRunner.class)
public class SingleColumnRowMapperUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class SingleColumnRowMapperUnitTests {
@Mock Row row;
@Mock ColumnDefinition columnDefinition;
@@ -45,13 +48,13 @@ public class SingleColumnRowMapperUnitTests {
private SingleColumnRowMapper rowMapper;
@Before
public void before() throws Exception {
@BeforeEach
void before() throws Exception {
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
}
@Test // DATACASS-335
public void getColumnValueWithType() {
void getColumnValueWithType() {
when(row.getDouble(2)).thenReturn(42d);
@@ -61,7 +64,7 @@ public class SingleColumnRowMapperUnitTests {
}
@Test // DATACASS-335
public void getColumnValue() {
void getColumnValue() {
when(row.getObject(2)).thenReturn(42d);
@@ -71,7 +74,7 @@ public class SingleColumnRowMapperUnitTests {
}
@Test // DATACASS-335
public void convertValueToRequiredTypeForNumber() {
void convertValueToRequiredTypeForNumber() {
rowMapper = new SingleColumnRowMapper<Number>();
@@ -81,7 +84,7 @@ public class SingleColumnRowMapperUnitTests {
}
@Test // DATACASS-335
public void convertValueToRequiredTypeForString() {
void convertValueToRequiredTypeForString() {
rowMapper = new SingleColumnRowMapper<Number>();
@@ -89,16 +92,16 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.convertValueToRequiredType("1234.2", Double.class)).isEqualTo(1234.2);
}
@Test(expected = IllegalArgumentException.class) // DATACASS-335
public void convertValueToRequiredTypeShouldFail() {
@Test // DATACASS-335
void convertValueToRequiredTypeShouldFail() {
rowMapper = new SingleColumnRowMapper<>();
rowMapper.convertValueToRequiredType("1234", Object.class);
assertThatIllegalArgumentException().isThrownBy(() -> rowMapper.convertValueToRequiredType("1234", Object.class));
}
@Test // DATACASS-335
public void mapRowSingleColumn() {
void mapRowSingleColumn() {
when(columnDefinitions.size()).thenReturn(1);
when(row.getInt(0)).thenReturn(42);
@@ -109,7 +112,7 @@ public class SingleColumnRowMapperUnitTests {
}
@Test // DATACASS-335
public void mapRowSingleColumnNullValue() {
void mapRowSingleColumnNullValue() {
when(columnDefinitions.size()).thenReturn(1);
when(row.getObject(0)).thenReturn(null);
@@ -119,8 +122,8 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.mapRow(row, 2)).isNull();
}
@Test(expected = TypeMismatchDataAccessException.class) // DATACASS-335
public void mapRowSingleColumnWrongType() {
@Test // DATACASS-335
void mapRowSingleColumnWrongType() {
when(columnDefinitions.size()).thenReturn(1);
when(columnDefinitions.get(0)).thenReturn(columnDefinition);
@@ -128,15 +131,17 @@ public class SingleColumnRowMapperUnitTests {
when(row.getObject(0)).thenReturn("hello");
rowMapper = SingleColumnRowMapper.newInstance(ColumnDefinitions.class);
rowMapper.mapRow(row, 2);
assertThatExceptionOfType(TypeMismatchDataAccessException.class).isThrownBy(() -> rowMapper.mapRow(row, 2));
}
@Test(expected = IncorrectResultSetColumnCountException.class) // DATACASS-335
public void tooManyColumns() {
@Test // DATACASS-335
void tooManyColumns() {
when(columnDefinitions.size()).thenReturn(2);
rowMapper = SingleColumnRowMapper.newInstance(ColumnDefinitions.class);
rowMapper.mapRow(row, 1);
assertThatExceptionOfType(IncorrectResultSetColumnCountException.class).isThrownBy(() -> rowMapper.mapRow(row, 1));
}
}

View File

@@ -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;
@@ -31,10 +31,10 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
*
* @author Mark Paluch
*/
public class WriteOptionsUnitTests {
class WriteOptionsUnitTests {
@Test // DATACASS-202
public void buildWriteOptions() {
void buildWriteOptions() {
WriteOptions writeOptions = WriteOptions.builder()
.consistencyLevel(DefaultConsistencyLevel.ANY)
@@ -54,7 +54,7 @@ public class WriteOptionsUnitTests {
}
@Test // DATACASS-202
public void buildReadTimeoutOptionsWriteOptions() {
void buildReadTimeoutOptionsWriteOptions() {
WriteOptions writeOptions = WriteOptions.builder().timeout(Duration.ofMinutes(1)).build();
@@ -65,7 +65,7 @@ public class WriteOptionsUnitTests {
@Test // DATACASS-56
public void buildWriteOptionsMutate() {
void buildWriteOptionsMutate() {
Instant now = LocalDateTime.now().toInstant(ZoneOffset.UTC);
WriteOptions writeOptions = WriteOptions.builder()

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.data.cassandra.core.cql.generator;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.IndexNameSpecification;
/**
@@ -28,24 +28,24 @@ import org.springframework.data.cassandra.core.cql.keyspace.IndexNameSpecificati
* @param <S> The type of the {@link IndexNameSpecification}
* @param <G> The type of the {@link IndexNameCqlGenerator}
*/
public abstract class AbstractIndexOperationCqlGeneratorTest<S extends IndexNameSpecification<?>, G extends IndexNameCqlGenerator<?>> {
abstract class AbstractIndexOperationCqlGeneratorTest<S extends IndexNameSpecification<?>, G extends IndexNameCqlGenerator<?>> {
public abstract S specification();
protected abstract S specification();
public abstract G generator();
protected abstract G generator();
public String indexName;
public S specification;
public G generator;
public String cql;
S specification;
private G generator;
String cql;
public void prepare() {
void prepare() {
this.specification = specification();
this.generator = generator();
this.cql = generateCql();
}
public String generateCql() {
private String generateCql() {
return generator.toCql();
}
}

View File

@@ -18,7 +18,7 @@ package org.springframework.data.cassandra.core.cql.generator;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceActionSpecification;
/**
@@ -30,15 +30,15 @@ import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceActionSpecif
* @param <S> The type of the {@link TableNameSpecification}
* @param <G> The type of the {@link TableNameCqlGenerator}
*/
public abstract class AbstractKeyspaceOperationCqlGeneratorTest<S extends KeyspaceActionSpecification, G extends KeyspaceNameCqlGenerator<?>> {
abstract class AbstractKeyspaceOperationCqlGeneratorTest<S extends KeyspaceActionSpecification, G extends KeyspaceNameCqlGenerator<?>> {
public abstract S specification();
protected abstract S specification();
public abstract G generator();
protected abstract G generator();
public String keyspace;
public S specification;
public G generator;
private G generator;
public String cql;
public void prepare() {
@@ -47,7 +47,7 @@ public abstract class AbstractKeyspaceOperationCqlGeneratorTest<S extends Keyspa
this.cql = generateCql();
}
public String generateCql() {
private String generateCql() {
return generator.toCql();
}

View File

@@ -26,23 +26,23 @@ import org.springframework.data.cassandra.core.cql.keyspace.TableNameSpecificati
* @param <S> The type of the {@link TableNameSpecification}
* @param <G> The type of the {@link TableNameCqlGenerator}
*/
public abstract class AbstractTableOperationCqlGeneratorTest<S extends TableNameSpecification, G extends TableNameCqlGenerator<?>> {
abstract class AbstractTableOperationCqlGeneratorTest<S extends TableNameSpecification, G extends TableNameCqlGenerator<?>> {
public abstract S specification();
protected abstract S specification();
public abstract G generator();
protected abstract G generator();
public S specification;
public G generator;
public String cql;
S specification;
private G generator;
String cql;
public void prepare() {
void prepare() {
this.specification = specification();
this.generator = generator();
this.cql = generateCql();
}
public String generateCql() {
private String generateCql() {
return generator.toCql();
}
}

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
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.DefaultOption;
import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceOption;
@@ -38,34 +38,34 @@ public class AlterKeyspaceCqlGeneratorUnitTests {
/**
* Asserts that the preamble is first & correctly formatted in the given CQL string.
*/
public static void assertPreamble(String tableName, String cql) {
assertThat(cql.startsWith("ALTER KEYSPACE " + tableName + " ")).isTrue();
private static void assertPreamble(String tableName, String cql) {
assertThat(cql).startsWith("ALTER KEYSPACE " + tableName + " ");
}
private static void assertReplicationMap(Map<Option, Object> replicationMap, String cql) {
assertThat(cql.contains(" WITH replication = { ")).isTrue();
assertThat(cql).contains(" WITH replication = { ");
replicationMap.entrySet().stream()
.map(entry -> "'" + entry.getKey().getName() + "' : '" + entry.getValue().toString() + "'")
.forEach(keyValuePair -> assertThat(cql.contains(keyValuePair)).isTrue());
}
public static void assertDurableWrites(Boolean durableWrites, String cql) {
assertThat(cql.contains(" AND durable_writes = " + durableWrites)).isTrue();
private static void assertDurableWrites(Boolean durableWrites, String cql) {
assertThat(cql).contains(" AND durable_writes = " + durableWrites);
}
/**
* Convenient base class that other test classes can use so as not to repeat the generics declarations.
*/
public static abstract class AlterKeyspaceTest
static abstract class AlterKeyspaceTest
extends AbstractKeyspaceOperationCqlGeneratorTest<AlterKeyspaceSpecification, AlterKeyspaceCqlGenerator> {}
public static class CompleteTest extends AlterKeyspaceTest {
static class CompleteTest extends AlterKeyspaceTest {
public String name = RandomKeyspaceName.create();
public Boolean durableWrites = true;
private String name = RandomKeyspaceName.create();
private Boolean durableWrites = true;
public Map<Option, Object> replicationMap = new HashMap<>();
private Map<Option, Object> replicationMap = new HashMap<>();
@Override
public AlterKeyspaceSpecification specification() {
@@ -84,7 +84,7 @@ public class AlterKeyspaceCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertPreamble(name, cql);
@@ -93,12 +93,12 @@ public class AlterKeyspaceCqlGeneratorUnitTests {
}
}
public static class ReplicationMapOnlyTest extends AlterKeyspaceTest {
static class ReplicationMapOnlyTest extends AlterKeyspaceTest {
public String name = "mytable";
private String name = "mytable";
public Boolean durableWrites = true;
public Map<Option, Object> replicationMap = new HashMap<>();
private Map<Option, Object> replicationMap = new HashMap<>();
@Override
public AlterKeyspaceSpecification specification() {
@@ -116,7 +116,7 @@ public class AlterKeyspaceCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertPreamble(name, cql);

View File

@@ -21,15 +21,15 @@ import static org.junit.Assume.*;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.AlterTableSpecification;
import org.springframework.data.cassandra.core.cql.keyspace.TableOption;
import org.springframework.data.cassandra.core.cql.keyspace.TableOption.CachingOption;
import org.springframework.data.cassandra.core.cql.keyspace.TableOption.KeyCachingOption;
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.util.Version;
import com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata;
@@ -42,15 +42,15 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
*
* @author Mark Paluch
*/
public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
static final Version CASSANDRA_3_10 = Version.parse("3.10");
static final Version CASSANDRA_3_0_10 = Version.parse("3.0.10");
private static final Version CASSANDRA_3_10 = Version.parse("3.10");
private static final Version CASSANDRA_3_0_10 = Version.parse("3.0.10");
Version cassandraVersion;
private Version cassandraVersion;
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
cassandraVersion = CassandraVersion.get(session);
@@ -59,7 +59,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192, DATACASS-429
public void alterTableAlterColumnType() {
void alterTableAlterColumnType() {
assumeTrue(cassandraVersion.isLessThan(CASSANDRA_3_10) && cassandraVersion.isLessThan(CASSANDRA_3_0_10));
@@ -77,7 +77,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192, DATACASS-429
public void alterTableAlterListColumnType() {
void alterTableAlterListColumnType() {
assumeTrue(cassandraVersion.isLessThan(CASSANDRA_3_10) && cassandraVersion.isLessThan(CASSANDRA_3_0_10));
@@ -95,7 +95,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192
public void alterTableAddColumn() {
void alterTableAddColumn() {
session.execute(
"CREATE TABLE addamsFamily (name varchar PRIMARY KEY, gender varchar,\n" + " lastknownlocation varchar);");
@@ -110,7 +110,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192
public void alterTableAddListColumn() {
void alterTableAddListColumn() {
session.execute("CREATE TABLE users (user_name varchar PRIMARY KEY);");
@@ -125,7 +125,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192
public void alterTableDropColumn() {
void alterTableDropColumn() {
session.execute("CREATE TABLE addamsFamily (name varchar PRIMARY KEY, gender varchar);");
@@ -137,7 +137,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192
public void alterTableRenameColumn() {
void alterTableRenameColumn() {
session.execute("CREATE TABLE addamsFamily (name varchar PRIMARY KEY, firstname varchar);");
@@ -150,7 +150,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
}
@Test // DATACASS-192, DATACASS-656
public void alterTableAddCaching() {
void alterTableAddCaching() {
session.execute("CREATE TABLE users (user_name varchar PRIMARY KEY);");

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.AlterTableSpecification;
import org.springframework.data.cassandra.core.cql.keyspace.TableOption;
@@ -36,10 +36,10 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
* @author David Webb
* @author Mark Paluch
*/
public class AlterTableCqlGeneratorUnitTests {
class AlterTableCqlGeneratorUnitTests {
@Test // DATACASS-192
public void alterTableAlterColumnType() {
void alterTableAlterColumnType() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").alter("lastKnownLocation",
DataTypes.UUID);
@@ -48,7 +48,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableAlterListColumnType() {
void alterTableAlterListColumnType() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").alter("lastKnownLocation",
DataTypes.listOf(DataTypes.ASCII));
@@ -57,7 +57,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableAddColumn() {
void alterTableAddColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").add("gravesite", DataTypes.TEXT);
@@ -65,7 +65,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableAddListColumn() {
void alterTableAddListColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("users").add("top_places",
DataTypes.listOf(DataTypes.ASCII));
@@ -74,7 +74,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableDropColumn() {
void alterTableDropColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").drop("gender");
@@ -82,7 +82,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableRenameColumn() {
void alterTableRenameColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").rename("firstname", "lastname");
@@ -90,7 +90,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableAddCommentAndTableOption() {
void alterTableAddCommentAndTableOption() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily")
.with(TableOption.READ_REPAIR_CHANCE, 0.2f).with(TableOption.COMMENT, "A most excellent and useful table");
@@ -100,7 +100,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableAddColumnAndComment() {
void alterTableAddColumnAndComment() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily")
.add("top_places", DataTypes.listOf(DataTypes.ASCII)).add("other", DataTypes.listOf(DataTypes.ASCII))
@@ -111,7 +111,7 @@ public class AlterTableCqlGeneratorUnitTests {
}
@Test // DATACASS-192
public void alterTableAddCaching() {
void alterTableAddCaching() {
Map<Object, Object> cachingMap = new LinkedHashMap<>();
cachingMap.put(CachingOption.KEYS, KeyCachingOption.NONE);

View File

@@ -19,12 +19,12 @@ import static org.assertj.core.api.Assertions.*;
import static org.junit.Assume.*;
import static org.springframework.data.cassandra.core.cql.generator.AlterUserTypeCqlGenerator.*;
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.keyspace.AlterUserTypeSpecification;
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.util.Version;
import com.datastax.oss.driver.api.core.type.DataTypes;
@@ -34,15 +34,15 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
*
* @author Mark Paluch
*/
public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
static final Version CASSANDRA_3_10 = Version.parse("3.10");
static final Version CASSANDRA_3_0_10 = Version.parse("3.0.10");
private static final Version CASSANDRA_3_10 = Version.parse("3.10");
private static final Version CASSANDRA_3_0_10 = Version.parse("3.0.10");
Version cassandraVersion;
private Version cassandraVersion;
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
cassandraVersion = CassandraVersion.get(session);
@@ -51,7 +51,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
}
@Test // DATACASS-172
public void alterTypeShouldAddField() {
void alterTypeShouldAddField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
.add("street", DataTypes.TEXT);
@@ -60,7 +60,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
}
@Test // DATACASS-172, DATACASS-429
public void alterTypeShouldAlterField() {
void alterTypeShouldAlterField() {
assumeTrue(cassandraVersion.isLessThan(CASSANDRA_3_10) && cassandraVersion.isLessThan(CASSANDRA_3_0_10));
@@ -71,7 +71,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
}
@Test // DATACASS-172
public void alterTypeShouldRenameField() {
void alterTypeShouldRenameField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
.rename("zip", "zap");
@@ -80,7 +80,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
}
@Test // DATACASS-172
public void alterTypeShouldRenameFields() {
void alterTypeShouldRenameFields() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
.rename("zip", "zap") //
@@ -90,12 +90,12 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
}
@Test // DATACASS-172
public void generationFailsIfNameIsNotSet() {
void generationFailsIfNameIsNotSet() {
assertThatNullPointerException().isThrownBy(() -> toCql(AlterUserTypeSpecification.alterType(null)));
}
@Test // DATACASS-172
public void generationFailsWithoutFields() {
void generationFailsWithoutFields() {
assertThatIllegalArgumentException().isThrownBy(() -> toCql(AlterUserTypeSpecification.alterType("hello")));
}
}

View File

@@ -18,7 +18,7 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.cassandra.core.cql.generator.AlterUserTypeCqlGenerator.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.AlterUserTypeSpecification;
@@ -29,10 +29,10 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
*
* @author Mark Paluch
*/
public class AlterUserTypeCqlGeneratorUnitTests {
class AlterUserTypeCqlGeneratorUnitTests {
@Test // DATACASS-172
public void alterTypeShouldAddField() {
void alterTypeShouldAddField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
.add("zip", DataTypes.TEXT);
@@ -41,7 +41,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
}
@Test // DATACASS-172
public void alterTypeShouldAlterField() {
void alterTypeShouldAlterField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
.alter("zip", DataTypes.TEXT);
@@ -50,7 +50,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
}
@Test // DATACASS-172
public void alterTypeShouldRenameField() {
void alterTypeShouldRenameField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
.rename("zip", "zap");
@@ -59,7 +59,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
}
@Test // DATACASS-172
public void alterTypeShouldRenameFields() {
void alterTypeShouldRenameFields() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
.rename("zip", "zap") //
@@ -70,7 +70,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
@Test // DATACASS-172
public void generationFailsWithoutFields() {
void generationFailsWithoutFields() {
assertThatIllegalArgumentException().isThrownBy(() -> toCql(AlterUserTypeSpecification.alterType("hello")));
}
}

View File

@@ -28,7 +28,7 @@ import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
* @author Matthew T. Adams
* @author Antoine Toulme
*/
public class CqlIndexSpecificationAssertions {
class CqlIndexSpecificationAssertions {
/**
* Assert the existence of an index using the index name.

View File

@@ -29,7 +29,7 @@ import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
/**
* @author John McPeek
*/
public class CqlKeyspaceSpecificationAssertions {
class CqlKeyspaceSpecificationAssertions {
@SuppressWarnings("unchecked")
public static void assertKeyspace(KeyspaceDescriptor expected, String keyspace, CqlSession session) {

View File

@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.CreateIndexSpecification;
/**
@@ -27,10 +27,10 @@ import org.springframework.data.cassandra.core.cql.keyspace.CreateIndexSpecifica
* @author David Webb
* @author Mark Paluch
*/
public class CreateIndexCqlGeneratorUnitTests {
class CreateIndexCqlGeneratorUnitTests {
@Test // DATACASS-213
public void createIndex() {
void createIndex() {
CreateIndexSpecification spec = CreateIndexSpecification.createIndex("myindex").tableName("mytable")
.columnName("column");
@@ -39,7 +39,7 @@ public class CreateIndexCqlGeneratorUnitTests {
}
@Test // DATACASS-213
public void createCustomIndex() {
void createCustomIndex() {
CreateIndexSpecification spec = CreateIndexSpecification.createIndex("myindex").tableName("mytable")
.columnName("column").using("indexclass");
@@ -49,7 +49,7 @@ public class CreateIndexCqlGeneratorUnitTests {
}
@Test // DATACASS-213
public void createIndexOnKeys() {
void createIndexOnKeys() {
CreateIndexSpecification spec = CreateIndexSpecification.createIndex().tableName("mytable").keys()
.columnName("column");
@@ -58,7 +58,7 @@ public class CreateIndexCqlGeneratorUnitTests {
}
@Test // DATACASS-213
public void createIndexIfNotExists() {
void createIndexIfNotExists() {
CreateIndexSpecification spec = CreateIndexSpecification.createIndex().tableName("mytable").columnName("column")
.ifNotExists();
@@ -67,7 +67,7 @@ public class CreateIndexCqlGeneratorUnitTests {
}
@Test // DATACASS-306
public void createIndexWithOptions() {
void createIndexWithOptions() {
CreateIndexSpecification spec = CreateIndexSpecification.createIndex().tableName("mytable").columnName("column")
.withOption("foo", "b'a'r").withOption("type", "PREFIX");

View File

@@ -15,11 +15,11 @@
*/
package org.springframework.data.cassandra.core.cql.generator;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.generator.CreateKeyspaceCqlGeneratorUnitTests.BasicTest;
import org.springframework.data.cassandra.core.cql.generator.CreateKeyspaceCqlGeneratorUnitTests.CreateKeyspaceTest;
import org.springframework.data.cassandra.core.cql.generator.CreateKeyspaceCqlGeneratorUnitTests.NetworkTopologyTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
/**
* Integration tests that reuse unit tests.
@@ -28,20 +28,20 @@ import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingInte
* @author Oliver Gierke
* @author Mark Paluch
*/
public class CreateKeyspaceCqlGeneratorIntegrationTests {
class CreateKeyspaceCqlGeneratorIntegrationTests {
/**
* Integration test base class that knows how to do everything except instantiate the concrete unit test type T.
*
* @param <T> The concrete unit test class to which this integration test corresponds.
*/
public static abstract class Base<T extends CreateKeyspaceTest> extends AbstractKeyspaceCreatingIntegrationTest {
T unit;
static abstract class Base<T extends CreateKeyspaceTest> extends AbstractKeyspaceCreatingIntegrationTests {
private T unit;
public abstract T unit();
protected abstract T unit();
@Test
public void test() {
void test() {
unit = unit();
unit.prepare();
@@ -53,7 +53,7 @@ public class CreateKeyspaceCqlGeneratorIntegrationTests {
}
}
public static class BasicIntegrationTest extends Base<BasicTest> {
static class BasicIntegrationTest extends Base<BasicTest> {
@Override
public BasicTest unit() {
@@ -61,7 +61,7 @@ public class CreateKeyspaceCqlGeneratorIntegrationTests {
}
}
public static class NetworkTopologyIntegrationTest extends Base<NetworkTopologyTest> {
static class NetworkTopologyIntegrationTest extends Base<NetworkTopologyTest> {
@Override
public NetworkTopologyTest unit() {

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.CreateKeyspaceSpecification;
import org.springframework.data.cassandra.core.cql.keyspace.DefaultOption;
import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceAttributes;
@@ -39,22 +39,22 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
/**
* Asserts that the preamble is first & correctly formatted in the given CQL string.
*/
public static void assertPreamble(String keyspaceName, String cql) {
assertThat(cql.startsWith("CREATE KEYSPACE " + keyspaceName + " ")).isTrue();
private static void assertPreamble(String keyspaceName, String cql) {
assertThat(cql).startsWith("CREATE KEYSPACE " + keyspaceName + " ");
}
private static void assertReplicationMap(Map<Option, Object> replicationMap, String cql) {
assertThat(cql.contains(" WITH replication = { ")).isTrue();
assertThat(cql).contains(" WITH replication = { ");
for (Map.Entry<Option, Object> entry : replicationMap.entrySet()) {
String keyValuePair = "'" + entry.getKey().getName() + "' : " + (entry.getKey().quotesValue() ? "'" : "")
+ entry.getValue().toString() + (entry.getKey().quotesValue() ? "'" : "");
assertThat(cql.contains(keyValuePair)).isTrue();
assertThat(cql).contains(keyValuePair);
}
}
public static void assertDurableWrites(Boolean durableWrites, String cql) {
assertThat(cql.contains(" AND durable_writes = " + durableWrites)).isTrue();
private static void assertDurableWrites(Boolean durableWrites, String cql) {
assertThat(cql).contains(" AND durable_writes = " + durableWrites);
}
/**
@@ -70,12 +70,12 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
}
}
public static class BasicTest extends CreateKeyspaceTest {
static class BasicTest extends CreateKeyspaceTest {
public String name = RandomKeyspaceName.create();
public Boolean durableWrites = true;
private String name = RandomKeyspaceName.create();
private Boolean durableWrites = true;
public Map<Option, Object> replicationMap = KeyspaceAttributes.newSimpleReplication();
private Map<Option, Object> replicationMap = KeyspaceAttributes.newSimpleReplication();
@Override
public CreateKeyspaceSpecification specification() {
@@ -86,7 +86,7 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertPreamble(keyspace, cql);
@@ -95,12 +95,12 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
}
}
public static class NoOptionsBasicTest extends CreateKeyspaceTest {
static class NoOptionsBasicTest extends CreateKeyspaceTest {
public String name = RandomKeyspaceName.create();
public Boolean durableWrites = true;
private String name = RandomKeyspaceName.create();
private Boolean durableWrites = true;
public Map<Option, Object> replicationMap = KeyspaceAttributes.newSimpleReplication();
private Map<Option, Object> replicationMap = KeyspaceAttributes.newSimpleReplication();
@Override
public CreateKeyspaceSpecification specification() {
@@ -110,7 +110,7 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertPreamble(keyspace, cql);
@@ -119,12 +119,12 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
}
}
public static class NetworkTopologyTest extends CreateKeyspaceTest {
static class NetworkTopologyTest extends CreateKeyspaceTest {
public String name = RandomKeyspaceName.create();
public Boolean durableWrites = false;
private String name = RandomKeyspaceName.create();
private Boolean durableWrites = false;
public Map<Option, Object> replicationMap = new HashMap<>();
private Map<Option, Object> replicationMap = new HashMap<>();
@Override
public CreateKeyspaceSpecification specification() {
@@ -139,7 +139,7 @@ public class CreateKeyspaceCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertPreamble(keyspace, cql);

View File

@@ -17,13 +17,13 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
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.Ordering;
import org.springframework.data.cassandra.core.cql.keyspace.CreateTableSpecification;
import org.springframework.data.cassandra.core.cql.keyspace.TableOption;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
import com.datastax.oss.driver.api.core.type.DataTypes;
@@ -35,17 +35,17 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
* @author Oliver Gierke
* @author Mark Paluch
*/
public class CreateTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class CreateTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
@Before
public void setUp() {
@BeforeEach
void setUp() {
session.execute("DROP TABLE IF EXISTS person;");
session.execute("DROP TABLE IF EXISTS address;");
}
@Test // DATACASS-518
public void shouldGenerateSimpleTable() {
void shouldGenerateSimpleTable() {
CreateTableSpecification table = CreateTableSpecification.createTable("person") //
.partitionKeyColumn("id", DataTypes.ASCII) //
@@ -56,7 +56,7 @@ public class CreateTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCre
}
@Test // DATACASS-518
public void shouldGenerateTableWithClusterKeyOrdering() {
void shouldGenerateTableWithClusterKeyOrdering() {
CreateTableSpecification table = CreateTableSpecification.createTable("person") //
.partitionKeyColumn("id", DataTypes.ASCII) //
@@ -73,7 +73,7 @@ public class CreateTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCre
}
@Test // DATACASS-518
public void shouldGenerateTableWithClusterKeyAndOptions() {
void shouldGenerateTableWithClusterKeyAndOptions() {
CreateTableSpecification table = CreateTableSpecification.createTable("person") //
.partitionKeyColumn("id", DataTypes.ASCII) //

View File

@@ -21,7 +21,7 @@ import static org.springframework.data.cassandra.core.cql.generator.CreateTableC
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.Ordering;
import org.springframework.data.cassandra.core.cql.keyspace.CreateTableSpecification;
@@ -43,10 +43,10 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
* @author David Webb
* @author Mark Paluch
*/
public class CreateTableCqlGeneratorUnitTests {
class CreateTableCqlGeneratorUnitTests {
@Test
public void shouldGenerateCorrectCQL() {
void shouldGenerateCorrectCQL() {
CqlIdentifier name = CqlIdentifier.fromCql("mytable");
DataType partitionKeyType0 = DataTypes.TEXT;
@@ -64,7 +64,7 @@ public class CreateTableCqlGeneratorUnitTests {
}
@Test
public void shouldGenerateCompositePrimaryKey() {
void shouldGenerateCompositePrimaryKey() {
CqlIdentifier name = CqlIdentifier.fromCql("composite_partition_key_table");
DataType partKeyType0 = DataTypes.TEXT;
@@ -86,7 +86,7 @@ public class CreateTableCqlGeneratorUnitTests {
}
@Test
public void shouldGenerateTableOptions() {
void shouldGenerateTableOptions() {
CqlIdentifier name = CqlIdentifier.fromCql("mytable");
DataType partitionKeyType0 = DataTypes.TEXT;
@@ -110,7 +110,7 @@ public class CreateTableCqlGeneratorUnitTests {
}
@Test
public void shouldGenerateMultipleOptions() {
void shouldGenerateMultipleOptions() {
CqlIdentifier name = CqlIdentifier.fromCql("timeseries_table");
DataType partitionKeyType0 = DataTypes.TIMEUUID;
@@ -163,7 +163,7 @@ public class CreateTableCqlGeneratorUnitTests {
}
@Test // DATACASS-518
public void createTableWithOrderedClustering() {
void createTableWithOrderedClustering() {
CreateTableSpecification table = CreateTableSpecification.createTable("person") //
.partitionKeyColumn("id", DataTypes.ASCII) //
@@ -176,7 +176,7 @@ public class CreateTableCqlGeneratorUnitTests {
}
@Test // DATACASS-518
public void createTableWithOrderedClusteringAndOptions() {
void createTableWithOrderedClusteringAndOptions() {
CreateTableSpecification table = CreateTableSpecification.createTable("person") //
.partitionKeyColumn("id", DataTypes.ASCII) //

View File

@@ -18,11 +18,11 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.cassandra.core.cql.generator.CreateUserTypeCqlGenerator.*;
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.keyspace.CreateUserTypeSpecification;
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.schema.KeyspaceMetadata;
@@ -34,17 +34,17 @@ import com.datastax.oss.driver.api.core.type.UserDefinedType;
*
* @author Mark Paluch
*/
public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTests {
@Before
public void setUp() throws Exception {
@BeforeEach
void setUp() throws Exception {
session.execute("DROP TYPE IF EXISTS person;");
session.execute("DROP TYPE IF EXISTS address;");
}
@Test // DATACASS-172
public void createUserType() {
void createUserType() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
.createType("address") //
@@ -59,7 +59,7 @@ public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspace
}
@Test // DATACASS-172
public void createUserTypeIfNotExists() {
void createUserTypeIfNotExists() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
.createType("address").ifNotExists().field("zip", DataTypes.ASCII) //
@@ -73,7 +73,7 @@ public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspace
}
@Test // DATACASS-172, DATACASS-424
public void createNestedUserType() {
void createNestedUserType() {
CreateUserTypeSpecification addressSpec = CreateUserTypeSpecification //
.createType("address").ifNotExists().field("zip", DataTypes.ASCII) //

View File

@@ -18,7 +18,7 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.cassandra.core.cql.generator.CreateUserTypeCqlGenerator.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.CreateUserTypeSpecification;
@@ -29,10 +29,10 @@ import com.datastax.oss.driver.api.core.type.DataTypes;
*
* @author Mark Paluch
*/
public class CreateUserTypeCqlGeneratorUnitTests {
class CreateUserTypeCqlGeneratorUnitTests {
@Test // DATACASS-172
public void createUserType() {
void createUserType() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
.createType("address") //
@@ -42,7 +42,7 @@ public class CreateUserTypeCqlGeneratorUnitTests {
}
@Test // DATACASS-172
public void createMultiFieldUserType() {
void createMultiFieldUserType() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
.createType("address") //
@@ -53,7 +53,7 @@ public class CreateUserTypeCqlGeneratorUnitTests {
}
@Test // DATACASS-172
public void createUserTypeIfNotExists() {
void createUserTypeIfNotExists() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
.createType("address").ifNotExists().field("zip", DataTypes.ASCII) //
@@ -63,7 +63,7 @@ public class CreateUserTypeCqlGeneratorUnitTests {
}
@Test // DATACASS-172
public void generationFailsWithoutFields() {
void generationFailsWithoutFields() {
assertThatIllegalArgumentException().isThrownBy(() -> toCql(CreateUserTypeSpecification.createType("hello")));
}
}

View File

@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.DropIndexSpecification;
/**
@@ -31,19 +31,19 @@ public class DropIndexCqlGeneratorUnitTests {
/**
* Asserts that the preamble is first & correctly formatted in the given CQL string.
*/
public static void assertStatement(String indexName, boolean ifExists, String cql) {
assertThat(cql.equals("DROP INDEX " + (ifExists ? "IF EXISTS " : "") + indexName + ";")).isTrue();
private static void assertStatement(String indexName, boolean ifExists, String cql) {
assertThat(cql).isEqualTo("DROP INDEX " + (ifExists ? "IF EXISTS " : "") + indexName + ";");
}
/**
* Convenient base class that other test classes can use so as not to repeat the generics declarations.
*/
public static abstract class DropIndexTest
static abstract class DropIndexTest
extends AbstractIndexOperationCqlGeneratorTest<DropIndexSpecification, DropIndexCqlGenerator> {}
public static class BasicTest extends DropIndexTest {
static class BasicTest extends DropIndexTest {
public String name = "myindex";
private String name = "myindex";
public DropIndexSpecification specification() {
return DropIndexSpecification.dropIndex(name);
@@ -54,7 +54,7 @@ public class DropIndexCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertStatement(name, false, cql);
@@ -62,9 +62,9 @@ public class DropIndexCqlGeneratorUnitTests {
}
public static class IfExistsTest extends DropIndexTest {
static class IfExistsTest extends DropIndexTest {
public String name = "myindex";
private String name = "myindex";
public DropIndexSpecification specification() {
return DropIndexSpecification.dropIndex(name)
@@ -77,7 +77,7 @@ public class DropIndexCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
// assertStatement(name, true, cql);

View File

@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.cassandra.core.cql.keyspace.DropKeyspaceSpecification;
import org.springframework.data.cassandra.support.RandomKeyspaceName;
@@ -28,24 +28,24 @@ import org.springframework.data.cassandra.support.RandomKeyspaceName;
* @author Matthew T. Adams
* @author David Webb
*/
public class DropKeyspaceCqlGeneratorUnitTests {
class DropKeyspaceCqlGeneratorUnitTests {
/**
* Asserts that the preamble is first & correctly formatted in the given CQL string.
*/
public static void assertStatement(String tableName, String cql) {
assertThat(cql.equals("DROP KEYSPACE " + tableName + ";")).isTrue();
private static void assertStatement(String tableName, String cql) {
assertThat(cql).isEqualTo("DROP KEYSPACE " + tableName + ";");
}
/**
* Convenient base class that other test classes can use so as not to repeat the generics declarations.
*/
public static abstract class DropTableTest
static abstract class DropTableTest
extends AbstractKeyspaceOperationCqlGeneratorTest<DropKeyspaceSpecification, DropKeyspaceCqlGenerator> {}
public static class BasicTest extends DropTableTest {
static class BasicTest extends DropTableTest {
public String name = RandomKeyspaceName.create();
private String name = RandomKeyspaceName.create();
@Override
public DropKeyspaceSpecification specification() {
@@ -58,7 +58,7 @@ public class DropKeyspaceCqlGeneratorUnitTests {
}
@Test
public void test() {
void test() {
prepare();
assertStatement(name, cql);

Some files were not shown because too many files have changed in this diff Show More