DATACASS-385 - Migrate ticket references in test code to Spring Framework style.

This commit is contained in:
Mark Paluch
2017-01-11 11:47:57 +01:00
parent cc537c995d
commit b247181a34
265 changed files with 1379 additions and 4066 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,15 +38,10 @@ import com.datastax.driver.core.policies.SpeculativeExecutionPolicy;
*
* @author Mark Paluch
* @author John Blum
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
*/
public class CassandraCqlClusterFactoryBeanUnitTests {
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldInitializeWithoutAnyOptions() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -58,11 +53,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getMetricsOptions().isJMXReportingEnabled()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldShutdownClusterInstance() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -72,11 +63,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(bean.getObject().isClosed()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-217">DATACASS-217</a>
* @throws Exception
*/
@Test
@Test // DATACASS-217
public void shouldSetLZ4CompressionType() throws Exception {
CompressionType compressionType = CompressionType.LZ4;
@@ -88,11 +75,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getProtocolOptions(bean).getCompression()).isEqualTo(Compression.LZ4);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetSnappyCompressionType() throws Exception {
CompressionType compressionType = CompressionType.SNAPPY;
@@ -104,11 +87,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getProtocolOptions().getCompression()).isEqualTo(Compression.SNAPPY);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetPoolingOptions() throws Exception {
PoolingOptions poolingOptions = new PoolingOptions();
@@ -120,11 +99,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getPoolingOptions()).isEqualTo(poolingOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetSocketOptions() throws Exception {
SocketOptions socketOptions = new SocketOptions();
@@ -136,11 +111,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getSocketOptions()).isEqualTo(socketOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetQueryOptions() throws Exception {
QueryOptions queryOptions = new QueryOptions();
@@ -152,11 +123,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getQueryOptions()).isEqualTo(queryOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void defaultQueryOptionsShouldHaveOwnObjectIdentity() throws Exception {
QueryOptions queryOptions = new QueryOptions();
@@ -168,11 +135,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getQueryOptions()).isNotEqualTo(queryOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetAuthProvider() throws Exception {
AuthProvider authProvider = new PlainTextAuthProvider("x", "y");
@@ -184,12 +147,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getProtocolOptions().getAuthProvider()).isEqualTo(authProvider);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @see <a href="https://jira.spring.io/browse/DATACASS-263">DATACASS-263</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226, DATACASS-263
public void shouldSetAuthenticationProvider() throws Exception {
AuthProvider authProvider = new PlainTextAuthProvider("x", "y");
@@ -202,12 +160,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(result).isEqualTo(authProvider);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @see <a href="https://jira.spring.io/browse/DATACASS-263">DATACASS-263</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226, DATACASS-263
public void shouldSetAuthentication() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -221,11 +174,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(ReflectionTestUtils.getField(result, "password")).isEqualTo((Object) "password");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetLoadBalancingPolicy() throws Exception {
LoadBalancingPolicy loadBalancingPolicy = new RoundRobinPolicy();
@@ -237,11 +186,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getPolicies().getLoadBalancingPolicy()).isEqualTo(loadBalancingPolicy);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetReconnectionPolicy() throws Exception {
ReconnectionPolicy reconnectionPolicy = new ExponentialReconnectionPolicy(1, 2);
@@ -253,11 +198,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getPolicies().getReconnectionPolicy()).isEqualTo(reconnectionPolicy);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetProtocolVersion() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -268,11 +209,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
.contains(ProtocolVersion.V2);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetSslOptions() throws Exception {
SSLOptions sslOptions = JdkSSLOptions.builder().build();
@@ -285,11 +222,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getProtocolOptions().getSSLOptions()).isEqualTo(sslOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldDisableMetrics() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -299,11 +232,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getConfiguration(bean).getMetricsOptions().isEnabled()).isFalse();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldDisableJmxReporting() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -325,10 +254,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
verify(mockClusterBuilderConfigurer, times(1)).configure(isA(Cluster.Builder.class));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-316">DATACASS-316</a>
*/
@Test
@Test // DATACASS-316
public void shouldSetAddressTranslator() throws Exception {
AddressTranslator mockAddressTranslator = mock(AddressTranslator.class);
@@ -340,10 +266,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getPolicies(bean).getAddressTranslator()).isEqualTo(mockAddressTranslator);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-317">DATACASS-317</a>
*/
@Test
@Test // DATACASS-317
public void shouldSetClusterNameWithBeanNameProperty() throws Exception {
final Cluster.Builder mockClusterBuilder = mock(Cluster.Builder.class);
@@ -364,10 +287,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
verify(mockClusterBuilder, times(1)).withClusterName(eq("ABC"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-317">DATACASS-317</a>
*/
@Test
@Test // DATACASS-317
public void shouldSetClusterNameWithClusterNameProperty() throws Exception {
final Cluster.Builder mockClusterBuilder = mock(Cluster.Builder.class);
@@ -388,10 +308,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
verify(mockClusterBuilder, times(1)).withClusterName(eq("XYZ"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-319">DATACASS-319</a>
*/
@Test
@Test // DATACASS-319
public void shouldSetMaxSchemaAgreementWaitSeconds() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -402,10 +319,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getProtocolOptions(bean).getMaxSchemaAgreementWaitSeconds()).isEqualTo(20);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-320">DATACASS-320</a>
*/
@Test
@Test // DATACASS-320
public void shouldSetSpeculativeExecutionPolicy() throws Exception {
SpeculativeExecutionPolicy mockSpeculativeExecutionPolicy = mock(SpeculativeExecutionPolicy.class);
@@ -417,10 +331,7 @@ public class CassandraCqlClusterFactoryBeanUnitTests {
assertThat(getPolicies(bean).getSpeculativeExecutionPolicy()).isEqualTo(mockSpeculativeExecutionPolicy);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-238">DATACASS-238</a>
*/
@Test
@Test // DATACASS-238
public void shouldSetTimestampGenerator() throws Exception {
TimestampGenerator mockTimestampGenerator = mock(TimestampGenerator.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors
* Copyright 2013-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
@@ -45,8 +46,6 @@ import com.datastax.driver.core.Session;
*
* @author John Blum
* @see org.springframework.cassandra.config.CassandraCqlSessionFactoryBean
* @see <a href="https://jira.spring.io/browse/DATACASS-219>DATACASS-219</a>
* @since 1.5.0
*/
@RunWith(MockitoJUnitRunner.class)
public class CassandraCqlSessionFactoryBeanUnitTests {
@@ -59,35 +58,28 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
private CassandraCqlSessionFactoryBean factoryBean;
protected <T> List<T> asList(T... array) {
return new ArrayList<T>(Arrays.asList(array));
}
protected void assertNonNullEmptyCollection(Collection<?> collection) {
assertThat(collection).isNotNull();
assertThat(collection.isEmpty()).isTrue();
}
@Before
public void setup() {
factoryBean = spy(new CassandraCqlSessionFactoryBean());
}
@Test
@Test // DATACASS-219
public void cassandraCqlSessionFactoryBeanIsSingleton() {
assertThat(factoryBean.isSingleton()).isTrue();
}
@Test
@Test // DATACASS-219
public void objectTypeWhenSessionHasNotBeenInitializedIsSessionClass() {
assertThat(factoryBean.getObject()).isNull();
assertThat(factoryBean.<Session> getObjectType()).isEqualTo(Session.class);
}
@Test
@Test // DATACASS-219
@SuppressWarnings("unchecked")
public void afterPropertiesSetInitializesSessionWithKeyspaceAndExecutesStartupScripts() throws Exception {
List<String> expectedStartupScripts = asList("/path/to/schema.cql", "/path/to/data.cql");
List<String> expectedStartupScripts = Arrays.asList("/path/to/schema.cql", "/path/to/data.cql");
CqlOperations mockCqlOperations = mock(CqlOperations.class);
@@ -115,10 +107,10 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
verify(mockCqlOperations, times(1)).execute(eq(expectedStartupScripts.get(1)));
}
@Test
@Test // DATACASS-219
public void connectToSystemKeyspace() {
when(mockCluster.connect()).thenReturn(mockSession);
when(mockCluster.connect()).thenReturn(mockSession);
factoryBean.setCluster(mockCluster);
assertThat(factoryBean.connect(null)).isEqualTo(mockSession);
@@ -127,10 +119,10 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
verify(mockCluster, never()).connect(anyString());
}
@Test
@Test // DATACASS-219
public void connectToTargetKeyspace() {
when(mockCluster.connect(eq("TestKeyspace"))).thenReturn(mockSession);
when(mockCluster.connect(eq("TestKeyspace"))).thenReturn(mockSession);
factoryBean.setCluster(mockCluster);
assertThat(factoryBean.connect("TestKeyspace")).isEqualTo(mockSession);
@@ -139,10 +131,10 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
verify(mockCluster, times(1)).connect(eq("TestKeyspace"));
}
@Test
@Test // DATACASS-219
@SuppressWarnings("unchecked")
public void destroySessionAndExecutesShutdownScripts() throws Exception {
List<String> expectedShutdownScripts = asList("/path/to/shutdown.cql");
List<String> expectedShutdownScripts = Collections.singletonList("/path/to/shutdown.cql");
CqlOperations mockCqlOperations = mock(CqlOperations.class);
@@ -159,35 +151,42 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
inOrder.verify(mockSession, times(1)).close();
}
@Test
@Test // DATACASS-219
public void isConnectedWithNullSessionIsFalse() {
assertThat(factoryBean.getObject()).isNull();
assertThat(factoryBean.isConnected()).isFalse();
}
@Test
@Test // DATACASS-219
public void isConnectedWithClosedSessionIsFalse() {
doReturn(mockSession).when(factoryBean).getObject();
when(factoryBean.getObject()).thenReturn(mockSession);
when(mockSession.isClosed()).thenReturn(true);
assertThat(factoryBean.isConnected()).isFalse();
verify(mockSession, times(1)).isClosed();
}
@Test
@Test // DATACASS-219
public void isConnectedWithOpenSessionIsTrue() {
doReturn(mockSession).when(factoryBean).getObject();
when(factoryBean.getObject()).thenReturn(mockSession);
when(mockSession.isClosed()).thenReturn(false);
assertThat(factoryBean.isConnected()).isTrue();
verify(mockSession, times(1)).isClosed();
}
@Test
@Test // DATACASS-219
public void setAndGetCluster() {
factoryBean.setCluster(mockCluster);
assertThat(factoryBean.getCluster()).isEqualTo(mockCluster);
}
@Test
@Test // DATACASS-219
public void setClusterToNullThrowsIllegalArgumentException() {
try {
@@ -199,7 +198,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
}
@Test
@Test // DATACASS-219
public void getClusterWhenUninitializedThrowsIllegalStateException() {
try {
@@ -210,20 +209,19 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
}
}
@Test
@Test // DATACASS-219
public void setAndGetKeyspaceName() {
assertThat(factoryBean.getKeyspaceName()).isNull();
factoryBean.setKeyspaceName("TEST");
assertThat(factoryBean.getKeyspaceName()).isEqualTo("TEST");
factoryBean.setKeyspaceName(null);
assertThat(factoryBean.getKeyspaceName()).isNull();
}
@Test
@Test // DATACASS-219
public void getSessionWhenUninitializedThrowsIllegalStateException() {
assertThat(factoryBean.getObject()).isNull();
@@ -237,26 +235,25 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
}
@Test
@Test // DATACASS-219
public void setAndGetStartupScripts() {
assertNonNullEmptyCollection(factoryBean.getStartupScripts());
List<String> expectedStartupScripts = asList("/path/to/schema.cql", "/path/to/data.cql");
List<String> expectedStartupScripts = Arrays.asList("/path/to/schema.cql", "/path/to/data.cql");
factoryBean.setStartupScripts(expectedStartupScripts);
List<String> actualStartupScripts = factoryBean.getStartupScripts();
assertThat(actualStartupScripts).isNotSameAs(expectedStartupScripts).isEqualTo(expectedStartupScripts);
factoryBean.setStartupScripts(null);
assertNonNullEmptyCollection(factoryBean.getStartupScripts());
}
@Test
@Test // DATACASS-219
public void startupScriptsAreImmutable() {
List<String> startupScripts = asList("/path/to/startup.cql");
List<String> startupScripts = new ArrayList<String>(Collections.singletonList("/path/to/startup.cql"));
factoryBean.setStartupScripts(startupScripts);
@@ -282,29 +279,26 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
@Test
public void setAndGetShutdownScripts() {
assertNonNullEmptyCollection(factoryBean.getShutdownScripts());
List<String> expectedShutdownScripts = asList("/path/to/backup.cql", "/path/to/dropTables.cql");
List<String> expectedShutdownScripts = Arrays.asList("/path/to/backup.cql", "/path/to/dropTables.cql");
factoryBean.setShutdownScripts(expectedShutdownScripts);
List<String> actualShutdownScripts = factoryBean.getShutdownScripts();
assertThat(actualShutdownScripts).isEqualTo(expectedShutdownScripts).isNotSameAs(expectedShutdownScripts);
factoryBean.setShutdownScripts(null);
assertNonNullEmptyCollection(factoryBean.getShutdownScripts());
}
@Test
@Test // DATACASS-219
public void shutdownScriptsAreImmutable() {
List<String> shutdownScripts = asList("/path/to/shutdown.cql");
List<String> shutdownScripts = new ArrayList<String>(Collections.singletonList("/path/to/shutdown.cql"));
factoryBean.setShutdownScripts(shutdownScripts);
List<String> actualShutdownScripts = factoryBean.getShutdownScripts();
assertThat(actualShutdownScripts).isEqualTo(shutdownScripts).isNotSameAs(shutdownScripts);
shutdownScripts.add("/path/to/corruptSession.cql");
@@ -321,4 +315,10 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
assertThat(actualShutdownScripts).hasSize(1);
}
}
private void assertNonNullEmptyCollection(Collection<?> collection) {
assertThat(collection).isNotNull();
assertThat(collection.isEmpty()).isTrue();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,8 +47,6 @@ import com.datastax.driver.core.PoolingOptions;
* @author David Webb
* @author John Blum
* @author Mark Paluch
* @see <a href="https://jira.spring.io/browse/DATACASS-176">DATACASS-176</a>
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@RunWith(MockitoJUnitRunner.class)
public class PoolingOptionsFactoryBeanUnitTests {
@@ -63,7 +61,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
poolingOptionsFactoryBean = new PoolingOptionsFactoryBean();
}
@Test
@Test // DATACASS-176, DATACASS-298
public void getObjectReturnsNullWhenNotInitialized() throws Exception {
assertThat(poolingOptionsFactoryBean.getObject()).isNull();
}
@@ -79,11 +77,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
assertThat(poolingOptionsFactoryBean.isSingleton()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
* @see <a href="https://jira.spring.io/browse/DATACASS-344">DATACASS-344</a>
*/
@Test
@Test // DATACASS-298, DATACASS-344
public void setAndGetFactoryBeanProperties() {
poolingOptionsFactoryBean.setHeartbeatIntervalSeconds(15);
@@ -113,10 +107,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
assertThat(poolingOptionsFactoryBean.getRemoteMinSimultaneousRequests()).isEqualTo(50);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void afterPropertiesSetInitializesLocalPoolingOptions() throws Exception {
PoolingOptionsFactoryBean poolingOptionsFactoryBean = new PoolingOptionsFactoryBean() {
@@ -157,10 +148,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
verify(poolingOptionsSpy, never()).setNewConnectionThreshold(eq(HostDistance.REMOTE), anyInt());
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void afterPropertiesSetInitializesRemotePoolingOptions() throws Exception {
PoolingOptionsFactoryBean poolingOptionsFactoryBean = new PoolingOptionsFactoryBean() {
@@ -201,10 +189,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
verify(poolingOptionsSpy, never()).setNewConnectionThreshold(eq(HostDistance.REMOTE), eq(5));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-344">DATACASS-344</a>
*/
@Test
@Test // DATACASS-344
public void afterPropertiesSetInitializesMaxQueueSize() throws Exception {
Method setMaxQueueSize = ReflectionUtils.findMethod(PoolingOptions.class, "setMaxQueueSize", int.class);
@@ -234,11 +219,8 @@ public class PoolingOptionsFactoryBeanUnitTests {
* driver class type... {@link PoolingOptions}! The max values should be set before setting core values. Otherwise the
* core values will be compared with the default max values which is 8. Same for other min-max properties pairs. This
* test checks the same.
*
* @throws Exception Any unhandled scenarios will result in a test failure.
* @see <a href="https://jira.spring.io/browse/DATACASS-176">DATACASS-176</a>
*/
@Test
@Test // DATACASS-176
public void afterPropertiesSetProperlySetsPoolingOptionsMaxBeforeMinProperties() throws Exception {
poolingOptionsFactoryBean = new PoolingOptionsFactoryBean() {
@@ -283,10 +265,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
verify(poolingOptions).setNewConnectionThreshold(eq(HostDistance.REMOTE), eq(111));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-176">DATACASS-176</a>
*/
@Test
@Test // DATACASS-176
public void newLocalHostDistancePoolingOptionsReturnsLocalHostDistancePoolingOptionsFactoryBeanSettings() {
poolingOptionsFactoryBean.setLocalCoreConnections(50);
@@ -308,10 +287,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
assertThat(poolingOptions.getNewConnectionThreshold()).isEqualTo(100);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-176">DATACASS-176</a>
*/
@Test
@Test // DATACASS-176
public void newLocalHostDistancePoolingOptionsReturnsRemoteHostDistancePoolingOptionsFactoryBeanSettings() {
poolingOptionsFactoryBean.setLocalCoreConnections(50);
@@ -333,10 +309,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
assertThat(poolingOptions.getNewConnectionThreshold()).isEqualTo(40);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-176">DATACASS-176</a>
*/
@Test
@Test // DATACASS-176
public void configureLocalHostDistancePoolingOptionsCallsConfigureWithExpectedInstance() {
final PoolingOptionsFactoryBean.HostDistancePoolingOptions mockHostDistancePoolingOptions = mock(
@@ -362,10 +335,7 @@ public class PoolingOptionsFactoryBeanUnitTests {
verify(mockHostDistancePoolingOptions).configure(same(poolingOptionsSpy));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-176">DATACASS-176</a>
*/
@Test
@Test // DATACASS-176
public void configureRemoteHostDistancePoolingOptionsCallsConfigureWithExpectedInstance() {
final PoolingOptionsFactoryBean.HostDistancePoolingOptions mockHostDistancePoolingOptions = mock(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,15 +45,10 @@ import com.datastax.driver.core.policies.SpeculativeExecutionPolicy;
* @author Mark Paluch
* @author John Blum
* @soundtrack Max Graham Feat Neev Kennedy - So Caught Up (Dns Project Remix)
* @see <a href="https://jira.spring.io/browse/DATACASS-226"></a>
*/
public class AbstractClusterConfigurationUnitTests {
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldInitializeWithoutAnyOptions() throws Exception {
CassandraCqlClusterFactoryBean bean = new CassandraCqlClusterFactoryBean();
@@ -68,11 +63,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getMetricsOptions().isJMXReportingEnabled()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetCompressionType() throws Exception {
final CompressionType compressionType = CompressionType.SNAPPY;
@@ -88,11 +79,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getProtocolOptions().getCompression()).isEqualTo(Compression.SNAPPY);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetPoolingOptions() throws Exception {
final PoolingOptions poolingOptions = new PoolingOptions();
@@ -108,11 +95,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getPoolingOptions()).isEqualTo(poolingOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetSocketOptions() throws Exception {
final SocketOptions socketOptions = new SocketOptions();
@@ -128,11 +111,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getSocketOptions()).isEqualTo(socketOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetQueryOptions() throws Exception {
final QueryOptions queryOptions = new QueryOptions();
@@ -148,11 +127,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getQueryOptions()).isEqualTo(queryOptions);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetAuthProvider() throws Exception {
final AuthProvider authProvider = new PlainTextAuthProvider("x", "y");
@@ -168,11 +143,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getProtocolOptions().getAuthProvider()).isEqualTo(authProvider);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetLoadBalancingPolicy() throws Exception {
final LoadBalancingPolicy loadBalancingPolicy = new RoundRobinPolicy();
@@ -188,11 +159,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getPolicies().getLoadBalancingPolicy()).isEqualTo(loadBalancingPolicy);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetReconnectionPolicy() throws Exception {
final ReconnectionPolicy reconnectionPolicy = new ExponentialReconnectionPolicy(1, 2);
@@ -208,11 +175,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getPolicies().getReconnectionPolicy()).isEqualTo(reconnectionPolicy);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldSetProtocolVersion() throws Exception {
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
@@ -227,11 +190,7 @@ public class AbstractClusterConfigurationUnitTests {
.contains(ProtocolVersion.V2);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
* @throws Exception
*/
@Test
@Test // DATACASS-226
public void shouldDisableMetrics() throws Exception {
AbstractClusterConfiguration clusterConfiguration = new AbstractClusterConfiguration() {
@@ -245,10 +204,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(getConfiguration(cluster).getMetricsOptions().isEnabled()).isFalse();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
*/
@Test
@Test // DATACASS-226
public void shouldSetKeyspaceCreations() {
final List<CreateKeyspaceSpecification> specification = Collections
@@ -263,10 +219,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(clusterConfiguration.cluster().getKeyspaceCreations()).isEqualTo(specification);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
*/
@Test
@Test // DATACASS-226
public void shouldSetKeyspaceDrops() {
final List<DropKeyspaceSpecification> specification = Collections
@@ -281,10 +234,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(clusterConfiguration.cluster().getKeyspaceDrops()).isEqualTo(specification);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
*/
@Test
@Test // DATACASS-226
public void shouldSetStartupScripts() {
final List<String> scripts = Collections.singletonList("USE BLUE_METH; CREATE TABLE...");
@@ -298,10 +248,7 @@ public class AbstractClusterConfigurationUnitTests {
assertThat(clusterConfiguration.cluster().getStartupScripts()).isEqualTo(scripts);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-226">DATACASS-226</a>
*/
@Test
@Test // DATACASS-226
public void shouldSetShutdownScripts() {
final List<String> scripts = Collections.singletonList("USE BLUE_METH; DROP TABLE...");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors
* Copyright 2013-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,10 +52,7 @@ public class CassandraCqlClusterParserUnitTests {
private CassandraCqlClusterParser parser = new CassandraCqlClusterParser();
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void resolveIdFromElement() {
when(mockElement.getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE))).thenReturn("test");
@@ -64,10 +61,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void resolveIdUsingDefault() {
when(mockElement.getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE))).thenReturn("");
@@ -76,10 +70,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getAttribute(eq(CassandraCqlClusterParser.ID_ATTRIBUTE));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void parseInternalCallsDoParseAndConstructsBeanDefinition() {
BeanDefinition mockContainingBeanDefinition = mock(BeanDefinition.class);
@@ -171,10 +162,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getAttribute(eq("username"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void parseChildElementsWithLocalPoolingOptions() {
Element localPoolingOptionsElement = mock(Element.class);
@@ -228,10 +216,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(localPoolingOptionsElement).getAttribute(eq("min-simultaneous-requests"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void parseChildElementsWithRemotePoolingOptions() {
Element localPoolingOptionsElement = mock(Element.class);
@@ -285,10 +270,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(localPoolingOptionsElement).getAttribute(eq("min-simultaneous-requests"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-242">DATACASS-242</a>
*/
@Test
@Test // DATACASS-242
public void parseChildElementsWithStartupAndShutdownScripts() {
Element mockStartupCqlOne = mock(Element.class, "MockStartupCqlOne");
@@ -322,10 +304,7 @@ public class CassandraCqlClusterParserUnitTests {
assertThat(shutdownScripts).contains("DROP KEYSPACE test;", "DROP USER jblum;");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void parseLocalPoolingOptionsProperlyConfiguresBeanDefinition() {
when(mockElement.getAttribute(eq("core-connections"))).thenReturn("50");
@@ -362,10 +341,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getAttribute(eq("min-simultaneous-requests"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void parseRemotePoolingOptionsProperlyConfiguresBeanDefinition() {
when(mockElement.getAttribute(eq("core-connections"))).thenReturn("50");
@@ -402,10 +378,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getAttribute(eq("min-simultaneous-requests"));
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void parseScript() {
when(mockElement.getTextContent()).thenReturn("CREATE TABLE schema.table;");
@@ -413,10 +386,7 @@ public class CassandraCqlClusterParserUnitTests {
verify(mockElement).getTextContent();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void newSocketOptionsBeanDefinitionIsProperlyInitialized() {
when(mockElement.getAttribute(eq("connect-timeout-millis"))).thenReturn("15000");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors
* Copyright 2013-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,10 +36,7 @@ public class ParsingUtilsUnitTests {
@Rule public ExpectedException exception = ExpectedException.none();
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addOptionalReferencePropertyUsesDefault() {
BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(),
@@ -51,10 +48,7 @@ public class ParsingUtilsUnitTests {
assertThat(propertyValue.getBeanName()).isEqualTo("defaultBeanReference");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addOptionalReferencePropertyWithNoValueDoesReturnsWithoutAdding() {
BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(),
@@ -66,10 +60,7 @@ public class ParsingUtilsUnitTests {
assertThat(beanDefinition.getPropertyValues().isEmpty()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addOptionalValuePropertyUsesDefault() {
BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(),
@@ -80,10 +71,7 @@ public class ParsingUtilsUnitTests {
assertThat(propertyValue).isEqualTo("defaultValue");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addOptionalValuePropertyWithNoValueDoesReturnsWithoutAdding() {
BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(),
@@ -95,10 +83,7 @@ public class ParsingUtilsUnitTests {
assertThat(beanDefinition.getPropertyValues().isEmpty()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addRequiredReferencePropertyIsSuccessful() {
BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(),
@@ -110,10 +95,7 @@ public class ParsingUtilsUnitTests {
assertThat(propertyValue.getBeanName()).isEqualTo("reference");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addRequiredReferencePropertyWithNoReferenceFails() {
exception.expect(IllegalArgumentException.class);
@@ -123,10 +105,7 @@ public class ParsingUtilsUnitTests {
"defaultReference", true, true);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addRequiredValuePropertyIsSuccessful() {
BeanDefinitionBuilder builder = ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(),
@@ -137,10 +116,7 @@ public class ParsingUtilsUnitTests {
assertThat(propertyValue).isEqualTo("value");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addRequiredValuePropertyWithNoValueFails() {
exception.expect(IllegalArgumentException.class);
@@ -150,10 +126,7 @@ public class ParsingUtilsUnitTests {
false);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addPropertyThrowsIllegalArgumentExceptionForNullBuilder() {
exception.expect(IllegalArgumentException.class);
@@ -162,10 +135,7 @@ public class ParsingUtilsUnitTests {
ParsingUtils.addProperty(null, "propertyName", "value", "defaultValue", false, false);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void addPropertyThrowsIllegalArgumentExceptionForNullPropertyName() {
exception.expect(IllegalArgumentException.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,10 +54,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
template.setSession(getSession());
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeShouldRemoveRecords() throws Exception {
template.execute("DELETE FROM user WHERE id = 'WHITE'").get();
@@ -65,10 +62,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(session.execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -79,10 +73,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject("SELECT id FROM user;", String.class).get();
@@ -90,10 +81,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap("SELECT * FROM user;").get();
@@ -101,10 +89,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(map).containsEntry("id", "WHITE").containsEntry("username", "Walter");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementShouldRemoveRecords() throws Exception {
template.execute(QueryBuilder.delete().from("user").where(QueryBuilder.eq("id", "WHITE"))).get();
@@ -112,10 +97,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(session.execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryStatementShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -126,10 +108,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject(QueryBuilder.select("id").from("user"), String.class).get();
@@ -137,10 +116,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap(QueryBuilder.select().from("user")).get();
@@ -148,10 +124,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(map).containsEntry("id", "WHITE").containsEntry("username", "Walter");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeWithArgsShouldRemoveRecords() throws Exception {
template.execute("DELETE FROM user WHERE id = ?", "WHITE").get();
@@ -159,10 +132,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(session.execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -173,10 +143,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -190,10 +157,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE").get();
@@ -201,10 +165,7 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE").get();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,10 +77,7 @@ public class AsyncCqlTemplateUnitTests {
// Tests dealing with a plain com.datastax.driver.core.Session
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCallbackShouldTranslateExceptions() throws Exception {
try {
@@ -94,10 +91,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlShouldTranslateExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture
@@ -120,10 +114,7 @@ public class AsyncCqlTemplateUnitTests {
// Tests dealing with static CQL
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -134,10 +125,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, asyncCqlTemplate -> {
@@ -148,10 +136,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForResultSetShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -163,10 +148,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetExtractorShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -179,10 +161,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, asyncCqlTemplate -> {
@@ -195,10 +174,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryCqlShouldTranslateExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture
@@ -217,10 +193,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldBeEmpty() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -238,10 +211,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -251,10 +221,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnNullValue() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -264,10 +231,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldFailReturningManyRecords() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -284,10 +248,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -301,10 +262,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForListCqlWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -318,10 +276,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).contains("OK", "NOT OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlShouldReturnWasApplied() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -336,10 +291,7 @@ public class AsyncCqlTemplateUnitTests {
// Tests dealing with com.datastax.driver.core.Statement
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -350,10 +302,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, asyncCqlTemplate -> {
@@ -364,10 +313,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForResultStatementSetShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -380,10 +326,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -396,10 +339,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, asyncCqlTemplate -> {
@@ -412,10 +352,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryStatementShouldTranslateExceptions() throws Exception {
TestResultSetFuture resultSetFuture = TestResultSetFuture
@@ -435,10 +372,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldBeEmpty() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -457,10 +391,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -471,10 +402,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnNullValue() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -485,10 +413,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldFailReturningManyRecords() throws Exception {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -506,10 +431,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -523,10 +445,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForListStatementWithTypeShouldReturnRecord() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -541,10 +460,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).contains("OK", "NOT OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementShouldReturnWasApplied() {
when(session.executeAsync(any(Statement.class))).thenReturn(new TestResultSetFuture(resultSet));
@@ -559,10 +475,7 @@ public class AsyncCqlTemplateUnitTests {
// Methods dealing with prepared statements
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -579,10 +492,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executePreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(null, null, null, asyncCqlTemplate -> {
@@ -596,10 +506,7 @@ public class AsyncCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() throws Exception {
when(session.executeAsync(boundStatement)).thenReturn(new TestResultSetFuture(resultSet));
@@ -628,10 +535,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() throws Exception {
when(session.executeAsync(boundStatement)).thenReturn(new TestResultSetFuture(resultSet));
@@ -652,10 +556,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldReturnResult() {
when(session.prepareAsync(anyString())).thenReturn(new TestPreparedStatementFuture(preparedStatement));
@@ -670,10 +571,7 @@ public class AsyncCqlTemplateUnitTests {
verify(preparedStatement).bind();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -689,10 +587,7 @@ public class AsyncCqlTemplateUnitTests {
verify(preparedStatement).bind("a", "b");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslatePrepareStatementExceptions() throws Exception {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -712,10 +607,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateBindExceptions() throws Exception {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -732,10 +624,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateExecutionExceptions() throws Exception {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -758,10 +647,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -777,10 +663,7 @@ public class AsyncCqlTemplateUnitTests {
verify(preparedStatement).bind("a", "b");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldBeEmpty() throws Exception {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
@@ -802,10 +685,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldReturnRecord() {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
@@ -819,10 +699,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldFailReturningManyRecords() throws Exception {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
@@ -843,10 +720,7 @@ public class AsyncCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
@@ -863,10 +737,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForListPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepareAsync("SELECT * FROM user WHERE username = ?"))
@@ -884,10 +755,7 @@ public class AsyncCqlTemplateUnitTests {
assertThat(getUninterruptibly(future)).contains("OK", "NOT OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updatePreparedStatementShouldReturnApplied() {
when(session.prepareAsync("UPDATE user SET username = ?"))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ import static org.assertj.core.api.Assertions.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import edu.umd.cs.mtc.MultithreadedTestCase;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -34,13 +36,10 @@ import org.mockito.runners.MockitoJUnitRunner;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;
import edu.umd.cs.mtc.MultithreadedTestCase;
/**
* Unit tests for {@link CachedPreparedStatementCreator}.
*
* @author Mark Paluch
* @see <a href="https://jira.spring.io/browse/DATACASS-253">DATACASS-253</a>
*/
@RunWith(MockitoJUnitRunner.class)
public class CachedPreparedStatementCreatorUnitTests {
@@ -55,26 +54,17 @@ public class CachedPreparedStatementCreatorUnitTests {
when(sessionMock.prepare(anyString())).thenReturn(preparedStatement);
}
/**
* @see DATACASS-253
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-253
public void shouldRejectEmptyCql() {
new CachedPreparedStatementCreator("");
}
/**
* @see DATACASS-253
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-253
public void shouldRejectNullCql() {
new CachedPreparedStatementCreator(null);
}
/**
* @see DATACASS-253
*/
@Test
@Test // DATACASS-253
public void shouldCreatePreparedStatement() {
CachedPreparedStatementCreator cachedPreparedStatementCreator = new CachedPreparedStatementCreator("my cql");
@@ -85,10 +75,7 @@ public class CachedPreparedStatementCreatorUnitTests {
verify(sessionMock).prepare("my cql");
}
/**
* @see DATACASS-253
*/
@Test
@Test // DATACASS-253
public void shouldCacheCreatePreparedStatement() {
CachedPreparedStatementCreator cachedPreparedStatementCreator = new CachedPreparedStatementCreator("my cql");
@@ -102,11 +89,7 @@ public class CachedPreparedStatementCreatorUnitTests {
verify(sessionMock, times(1)).prepare("my cql");
}
/**
* @see DATACASS-253
* @throws Throwable
*/
@Test
@Test // DATACASS-253
public void concurrentAccessToCreateStatementShouldBeSynchronized() throws Throwable {
CreatePreparedStatementIsThreadSafe concurrentPrepareStatement = new CreatePreparedStatementIsThreadSafe(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@ import org.junit.runners.Parameterized.Parameters;
* Unit tests for {@link ConsistencyLevelResolver}.
*
* @author Mark Paluch
* @see DATACASS-202
*/
@RunWith(Parameterized.class)
public class ConsistencyLevelResolverUnitTests {
@@ -80,10 +79,7 @@ public class ConsistencyLevelResolverUnitTests {
return parameters;
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void shouldResolveCorrectly() {
assertThat(ConsistencyLevelResolver.resolve(from)).isEqualTo(expected);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,10 +53,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
template.setSession(getSession());
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeShouldRemoveRecords() throws Exception {
template.execute("DELETE FROM user WHERE id = 'WHITE'");
@@ -64,10 +61,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(session.execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -78,10 +72,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject("SELECT id FROM user;", String.class);
@@ -89,10 +80,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap("SELECT * FROM user;");
@@ -100,10 +88,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(map).containsEntry("id", "WHITE").containsEntry("username", "Walter");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementShouldRemoveRecords() throws Exception {
template.execute(QueryBuilder.delete().from("user").where(QueryBuilder.eq("id", "WHITE")));
@@ -111,10 +96,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(session.execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryStatementShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -125,10 +107,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject(QueryBuilder.select("id").from("user"), String.class);
@@ -136,10 +115,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap(QueryBuilder.select().from("user"));
@@ -147,10 +123,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(map).containsEntry("id", "WHITE").containsEntry("username", "Walter");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeWithArgsShouldRemoveRecords() throws Exception {
template.execute("DELETE FROM user WHERE id = ?", "WHITE");
@@ -158,10 +131,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(session.execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -172,10 +142,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldInvokeCallback() throws Exception {
List<String> result = new ArrayList<>();
@@ -186,10 +153,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(result).contains("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE");
@@ -197,10 +161,7 @@ public class CqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegra
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectWithArgsShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,10 +76,7 @@ public class CqlTemplateUnitTests {
// Tests dealing with a plain com.datastax.driver.core.Session
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCallbackShouldTranslateExceptions() {
try {
@@ -93,10 +90,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -113,10 +107,7 @@ public class CqlTemplateUnitTests {
// Tests dealing with static CQL
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -127,10 +118,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, cqlTemplate -> {
@@ -141,10 +129,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForResultSetShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -156,10 +141,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetExtractorShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -171,10 +153,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, cqlTemplate -> {
@@ -186,10 +165,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -202,10 +178,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -219,10 +192,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -232,10 +202,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -245,10 +212,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -262,10 +226,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -279,10 +240,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForListCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -296,10 +254,7 @@ public class CqlTemplateUnitTests {
assertThat(result).contains("OK", "NOT OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeCqlShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -314,10 +269,7 @@ public class CqlTemplateUnitTests {
// Tests dealing with com.datastax.driver.core.Statement
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -328,10 +280,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, cqlTemplate -> {
@@ -342,10 +291,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForResultStatementSetShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -357,10 +303,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -373,10 +316,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, cqlTemplate -> {
@@ -389,10 +329,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryStatementShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -406,10 +343,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -424,10 +358,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -437,10 +368,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -450,10 +378,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -468,10 +393,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -485,10 +407,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForListStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -502,10 +421,7 @@ public class CqlTemplateUnitTests {
assertThat(result).contains("OK", "NOT OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executeStatementShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(resultSet);
@@ -520,10 +436,7 @@ public class CqlTemplateUnitTests {
// Methods dealing with prepared statements
// -------------------------------------------------------------------------
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -539,10 +452,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executePreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(null, null, null, cqlTemplate -> {
@@ -556,10 +466,7 @@ public class CqlTemplateUnitTests {
});
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() {
when(session.execute(boundStatement)).thenReturn(resultSet);
@@ -576,10 +483,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() {
when(session.execute(boundStatement)).thenReturn(resultSet);
@@ -596,10 +500,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorShouldReturnResult() {
when(session.prepare(anyString())).thenReturn(preparedStatement);
@@ -613,10 +514,7 @@ public class CqlTemplateUnitTests {
verify(preparedStatement).bind();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -632,10 +530,7 @@ public class CqlTemplateUnitTests {
verify(preparedStatement).bind("a", "b");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslatePrepareStatementExceptions() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -654,10 +549,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateBindExceptions() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -673,10 +565,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderShouldTranslateExecutionExceptions() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -694,10 +583,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
when(preparedStatement.bind()).thenReturn(boundStatement);
@@ -713,10 +599,7 @@ public class CqlTemplateUnitTests {
verify(preparedStatement).bind("a", "b");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldBeEmpty() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
@@ -733,10 +616,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
@@ -748,10 +628,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementShouldFailReturningManyRecords() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
@@ -768,10 +645,7 @@ public class CqlTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
@@ -787,10 +661,7 @@ public class CqlTemplateUnitTests {
assertThat(result).isEqualTo("OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void queryForListPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(preparedStatement);
@@ -806,10 +677,7 @@ public class CqlTemplateUnitTests {
assertThat(result).contains("OK", "NOT OK");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updatePreparedStatementShouldReturnApplied() {
when(session.prepare("UPDATE user SET username = ?")).thenReturn(preparedStatement);
@@ -822,7 +690,6 @@ public class CqlTemplateUnitTests {
assertThat(applied).isTrue();
}
private <T> void doTestStrings(Integer fetchSize, ConsistencyLevel consistencyLevel,
com.datastax.driver.core.policies.RetryPolicy retryPolicy, Consumer<CqlTemplate> cqlTemplateConsumer) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@ package org.springframework.cassandra.core;
import static org.assertj.core.api.Assertions.*;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
@@ -26,9 +29,6 @@ import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.exceptions.SyntaxError;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
/**
* Integration tests for {@link DefaultBridgedReactiveSession}.
*
@@ -46,10 +46,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
this.reactiveSession = new DefaultBridgedReactiveSession(this.session, Schedulers.elastic());
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeShouldExecuteDeferred() throws Exception {
Mono<ReactiveResultSet> execution = reactiveSession
@@ -64,10 +61,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
assertThat(keyspace.getTable("users")).isNotNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeShouldTransportExceptionsInMono() throws Exception {
Mono<ReactiveResultSet> execution = reactiveSession.execute("INSERT INTO dummy;");
@@ -80,10 +74,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeShouldReturnRows() throws Exception {
session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");");
@@ -97,10 +88,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
assertThat(row.getString("userid")).isEqualTo("White");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeShouldPrepareStatement() throws Exception {
session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package org.springframework.cassandra.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import reactor.core.scheduler.Schedulers;
import java.util.Collections;
import org.hamcrest.core.IsEqual;
@@ -33,8 +35,6 @@ import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Statement;
import reactor.core.scheduler.Schedulers;
/**
* Unit tests for {@link DefaultBridgedReactiveSession}.
*
@@ -52,10 +52,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
reactiveSession = new DefaultBridgedReactiveSession(sessionMock, Schedulers.immediate());
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeStatementShouldForwardStatementToSession() throws Exception {
SimpleStatement statement = new SimpleStatement("SELECT *");
@@ -64,10 +61,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).executeAsync(statement);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeShouldForwardStatementToSession() throws Exception {
reactiveSession.execute("SELECT *").subscribe();
@@ -75,10 +69,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).executeAsync(eq(new SimpleStatement("SELECT *")));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeWithValuesShouldForwardStatementToSession() throws Exception {
reactiveSession.execute("SELECT * WHERE a = ? and b = ?", "A", "B").subscribe();
@@ -86,10 +77,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).executeAsync(eq(new SimpleStatement("SELECT * WHERE a = ? and b = ?", "A", "B")));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeWithValueMapShouldForwardStatementToSession() throws Exception {
reactiveSession.execute("SELECT * WHERE a = ?", Collections.singletonMap("a", "value")).subscribe();
@@ -98,10 +86,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
.executeAsync(eq(new SimpleStatement("SELECT * WHERE a = ?", Collections.singletonMap("a", "value"))));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void testPrepareQuery() throws Exception {
reactiveSession.prepare("SELECT *").subscribe();
@@ -109,10 +94,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).prepareAsync(eq(new SimpleStatement("SELECT *")));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void testPrepareStatement() throws Exception {
SimpleStatement statement = new SimpleStatement("SELECT *");
@@ -121,10 +103,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).prepareAsync(statement);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void testClose() throws Exception {
reactiveSession.close();
@@ -132,10 +111,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).close();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void testIsClosed() throws Exception {
when(reactiveSession.isClosed()).thenReturn(true);
@@ -146,10 +122,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
verify(sessionMock).isClosed();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void testGetCluster() throws Exception {
Cluster clusterMock = mock(Cluster.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,10 +33,7 @@ import com.datastax.driver.core.policies.LoggingRetryPolicy;
*/
public class QueryOptionsUnitTests {
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder() //
@@ -56,10 +53,7 @@ public class QueryOptionsUnitTests {
assertThat(queryOptions.getTracing()).isTrue();
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildQueryOptionsWithDriverRetryPolicy() {
QueryOptions writeOptions = QueryOptions.builder() //
@@ -70,10 +64,7 @@ public class QueryOptionsUnitTests {
assertThat(writeOptions.getDriverRetryPolicy()).isInstanceOf(LoggingRetryPolicy.class);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildQueryOptionsWithRetryPolicy() {
QueryOptions writeOptions = QueryOptions.builder() //
@@ -84,26 +75,17 @@ public class QueryOptionsUnitTests {
assertThat(writeOptions.getDriverRetryPolicy()).isNull();
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void builderShouldRejectSettingOurAndDriverRetryPolicy() {
QueryOptions.builder().retryPolicy(RetryPolicy.DEFAULT).retryPolicy(FallthroughRetryPolicy.INSTANCE);
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void builderShouldRejectSettingDriverAndOurRetryPolicy() {
QueryOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).retryPolicy(RetryPolicy.DEFAULT);
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void shouldRejectSettingOurAndDriverRetryPolicy() {
QueryOptions queryOptions = new QueryOptions();
@@ -111,10 +93,7 @@ public class QueryOptionsUnitTests {
queryOptions.setRetryPolicy(FallthroughRetryPolicy.INSTANCE);
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void shouldRejectSettingDriverAndOurRetryPolicy() {
QueryOptions queryOptions = new QueryOptions();
@@ -122,10 +101,7 @@ public class QueryOptionsUnitTests {
queryOptions.setRetryPolicy(RetryPolicy.DEFAULT);
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void shouldRejectSettingOurAndDriverConsistencyLevel() {
QueryOptions queryOptions = new QueryOptions();
@@ -133,10 +109,7 @@ public class QueryOptionsUnitTests {
queryOptions.setConsistencyLevel(ConsistencyLevel.ANY);
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void shouldRejectSettingDriverAndOurConsistencyLevel() {
QueryOptions queryOptions = new QueryOptions();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors
* Copyright 2016-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,10 +54,7 @@ public class QueryOptionsUtilUnitTests {
@Mock Statement mockStatement;
@Mock Update mockUpdate;
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addPreparedStatementOptionsShouldAddDriverQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder() //
@@ -71,10 +68,7 @@ public class QueryOptionsUtilUnitTests {
verify(mockPreparedStatement).setRetryPolicy(FallthroughRetryPolicy.INSTANCE);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addPreparedStatementOptionsShouldAddOurQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().retryPolicy(RetryPolicy.FALLTHROUGH).build();
@@ -87,10 +81,7 @@ public class QueryOptionsUtilUnitTests {
verify(mockPreparedStatement).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addStatementQueryOptionsShouldAddDriverQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().consistencyLevel(ConsistencyLevel.EACH_QUORUM) //
@@ -103,10 +94,7 @@ public class QueryOptionsUtilUnitTests {
verify(mockStatement).setRetryPolicy(FallthroughRetryPolicy.INSTANCE);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addStatementQueryOptionsShouldAddOurQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().retryPolicy(RetryPolicy.FALLTHROUGH).build();
@@ -119,10 +107,7 @@ public class QueryOptionsUtilUnitTests {
verify(mockStatement).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addStatementQueryOptionsShouldNotAddOptions() {
QueryOptions queryOptions = QueryOptions.builder().build();
@@ -132,10 +117,7 @@ public class QueryOptionsUtilUnitTests {
verifyZeroInteractions(mockStatement);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addStatementQueryOptionsShouldAddGenericQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder() //
@@ -151,10 +133,7 @@ public class QueryOptionsUtilUnitTests {
verify(mockStatement).enableTracing();
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addInsertWriteOptionsShouldAddDriverQueryOptions() {
WriteOptions writeOptions = WriteOptions.builder() //
@@ -172,10 +151,7 @@ public class QueryOptionsUtilUnitTests {
verify(mockInsert).using(Mockito.any(Using.class));
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void addUpdateWriteOptionsShouldAddDriverQueryOptions() {
WriteOptions writeOptions = WriteOptions.builder() //

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@ package org.springframework.cassandra.core;
import static org.assertj.core.api.Assertions.*;
import reactor.core.scheduler.Schedulers;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -26,8 +28,6 @@ import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIn
import com.datastax.driver.core.querybuilder.QueryBuilder;
import reactor.core.scheduler.Schedulers;
/**
* Integration tests for {@link ReactiveCqlTemplate}.
*
@@ -55,10 +55,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
template = new ReactiveCqlTemplate(new DefaultReactiveSessionFactory(reactiveSession));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeShouldRemoveRecords() throws Exception {
template.execute("DELETE FROM user WHERE id = 'WHITE'").block();
@@ -66,10 +63,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(getSession().execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject("SELECT id FROM user;", String.class).block();
@@ -77,10 +71,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap("SELECT * FROM user;").block();
@@ -88,10 +79,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(map).containsEntry("id", "WHITE").containsEntry("username", "Walter");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeStatementShouldRemoveRecords() throws Exception {
template.execute(QueryBuilder.delete().from("user").where(QueryBuilder.eq("id", "WHITE"))).block();
@@ -99,10 +87,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(getSession().execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject(QueryBuilder.select("id").from("user"), String.class).block();
@@ -110,10 +95,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap(QueryBuilder.select().from("user")).block();
@@ -121,10 +103,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(map).containsEntry("id", "WHITE").containsEntry("username", "Walter");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeWithArgsShouldRemoveRecords() throws Exception {
template.execute("DELETE FROM user WHERE id = ?", "WHITE").block();
@@ -132,10 +111,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(getSession().execute("SELECT * FROM user").one()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectWithArgsShouldReturnFirstColumn() throws Exception {
String id = template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE").block();
@@ -143,10 +119,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
assertThat(id).isEqualTo("WHITE");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectWithArgsShouldReturnMap() throws Exception {
Map<String, Object> map = template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE").block();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,9 @@ package org.springframework.cassandra.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
@@ -43,9 +46,6 @@ import com.datastax.driver.core.exceptions.InvalidQueryException;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import com.datastax.driver.core.policies.DowngradingConsistencyRetryPolicy;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* Unit tests for {@link ReactiveCqlTemplate}.
*
@@ -75,10 +75,7 @@ public class ReactiveCqlTemplateUnitTests {
// Tests dealing with a plain org.springframework.cassandra.core.ReactiveSession
// -------------------------------------------------------------------------
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCallbackShouldExecuteDeferred() {
Flux<String> flux = template.execute((ReactiveSessionCallback<String>) session -> {
@@ -91,10 +88,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(session).close();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCallbackShouldTranslateExceptions() {
Flux<String> flux = template.execute((ReactiveSessionCallback<String>) session -> {
@@ -110,10 +104,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCqlShouldExecuteDeferred() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -125,10 +116,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(session).execute(any(Statement.class));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -148,10 +136,7 @@ public class ReactiveCqlTemplateUnitTests {
// Tests dealing with static CQL
// -------------------------------------------------------------------------
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCqlShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -162,10 +147,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCqlWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, reactiveCqlTemplate -> {
@@ -176,10 +158,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForResultSetShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -193,10 +172,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryWithResultSetExtractorShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -210,10 +186,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryWithResultSetExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, reactiveCqlTemplate -> {
@@ -227,10 +200,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryCqlShouldExecuteDeferred() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -243,10 +213,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(session).execute(any(Statement.class));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryCqlShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -262,10 +229,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectCqlShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -275,10 +239,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.hasElement().block()).isFalse();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectCqlShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -288,10 +249,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isEqualTo("OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectCqlShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -301,10 +259,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.hasElement().block()).isFalse();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectCqlShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -321,10 +276,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -338,10 +290,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isEqualTo("OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForFluxCqlWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -355,10 +304,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(flux.collectList().block()).contains("OK", "NOT OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForRowsCqlReturnRows() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -369,10 +315,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(flux.collectList().block()).hasSize(2).contains(row);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCqlShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -383,10 +326,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isTrue();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeCqlPublisherShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -403,10 +343,7 @@ public class ReactiveCqlTemplateUnitTests {
// Tests dealing with com.datastax.driver.core.Statement
// -------------------------------------------------------------------------
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeStatementShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -417,10 +354,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeStatementWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, reactiveCqlTemplate -> {
@@ -431,10 +365,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForResultStatementSetShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -448,10 +379,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryWithResultSetStatementExtractorShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -466,10 +394,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryWithResultSetStatementExtractorWithArgumentsShouldCallExecution() {
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, reactiveCqlTemplate -> {
@@ -484,10 +409,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryStatementShouldExecuteDeferred() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -501,10 +423,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(session).execute(any(Statement.class));
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryStatementShouldTranslateExceptions() {
when(session.execute(any(Statement.class))).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -521,10 +440,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementShouldBeEmpty() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -534,10 +450,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.hasElement().block()).isFalse();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -547,10 +460,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isEqualTo("OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementShouldReturnNullValue() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -560,10 +470,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.hasElement().block()).isFalse();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementShouldFailReturningManyRecords() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -580,10 +487,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -597,10 +501,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isEqualTo("OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForFluxStatementWithTypeShouldReturnRecord() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -614,10 +515,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(flux.collectList().block()).contains("OK", "NOT OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForRowsStatementReturnRows() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -628,10 +526,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(flux.collectList().block()).hasSize(2).contains(row);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executeStatementShouldReturnWasApplied() {
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
@@ -646,10 +541,7 @@ public class ReactiveCqlTemplateUnitTests {
// Methods dealing with prepared statements
// -------------------------------------------------------------------------
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryPreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -665,10 +557,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executePreparedStatementWithCallbackShouldCallExecution() {
doTestStrings(null, null, null, reactiveCqlTemplate -> {
@@ -681,10 +570,7 @@ public class ReactiveCqlTemplateUnitTests {
});
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executePreparedStatementCallbackShouldExecuteDeferred() {
when(session.prepare(anyString())).thenReturn(Mono.just(preparedStatement));
@@ -701,10 +587,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(session).execute(boundStatement);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executePreparedStatementCreatorShouldExecuteDeferred() {
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
@@ -718,10 +601,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(session).execute(boundStatement);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executePreparedStatementCreatorShouldTranslateStatementCreationExceptions() {
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
@@ -740,10 +620,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void executePreparedStatementCreatorShouldTranslateStatementCallbackExceptions() {
when(session.execute(boundStatement)).thenReturn(Mono.just(reactiveResultSet));
@@ -762,10 +639,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryPreparedStatementCreatorShouldReturnResult() {
when(session.prepare(anyString())).thenReturn(Mono.just(preparedStatement));
@@ -780,10 +654,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(preparedStatement).bind();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryPreparedStatementCreatorAndBinderShouldReturnResult() {
when(session.prepare(anyString())).thenReturn(Mono.just(preparedStatement));
@@ -801,10 +672,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(preparedStatement).bind("a", "b");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryPreparedStatementCreatorAndBinderAndMapperShouldReturnResult() {
when(session.prepare(anyString())).thenReturn(Mono.just(preparedStatement));
@@ -822,10 +690,7 @@ public class ReactiveCqlTemplateUnitTests {
verify(preparedStatement).bind("a", "b");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectPreparedStatementShouldBeEmpty() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -838,10 +703,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.hasElement().block()).isFalse();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectPreparedStatementShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -854,10 +716,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isEqualTo("OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectPreparedStatementShouldFailReturningManyRecords() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -876,10 +735,7 @@ public class ReactiveCqlTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForObjectPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -895,10 +751,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isEqualTo("OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForFluxPreparedStatementWithTypeShouldReturnRecord() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -914,10 +767,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(flux.collectList().block()).contains("OK", "NOT OK");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void queryForRowsPreparedStatementReturnRows() {
when(session.prepare("SELECT * FROM user WHERE username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -930,10 +780,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(flux.collectList().block()).hasSize(2).contains(row);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void updatePreparedStatementShouldReturnApplied() {
when(session.prepare("UPDATE user SET username = ?")).thenReturn(Mono.just(preparedStatement));
@@ -946,10 +793,7 @@ public class ReactiveCqlTemplateUnitTests {
assertThat(mono.block()).isTrue();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void updatePreparedStatementArgsPublisherShouldReturnApplied() {
when(session.prepare("UPDATE user SET username = ?")).thenReturn(Mono.just(preparedStatement));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,10 +49,7 @@ public class SingleColumnRowMapperUnitTests {
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void getColumnValueWithType() {
when(row.getDouble(2)).thenReturn(42d);
@@ -62,10 +59,7 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.getColumnValue(row, 2, Number.class)).isEqualTo(42d);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void getColumnValue() {
when(row.getObject(2)).thenReturn(42d);
@@ -75,10 +69,7 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.getColumnValue(row, 2)).isEqualTo(42d);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void convertValueToRequiredTypeForNumber() {
rowMapper = new SingleColumnRowMapper<Number>();
@@ -88,10 +79,7 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.convertValueToRequiredType(1234.2, Double.class)).isEqualTo(1234.2);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void convertValueToRequiredTypeForString() {
rowMapper = new SingleColumnRowMapper<Number>();
@@ -100,10 +88,7 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.convertValueToRequiredType("1234.2", Double.class)).isEqualTo(1234.2);
}
/**
* @see DATACASS-335
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-335
public void convertValueToRequiredTypeShouldFail() {
rowMapper = new SingleColumnRowMapper<>();
@@ -111,10 +96,7 @@ public class SingleColumnRowMapperUnitTests {
rowMapper.convertValueToRequiredType("1234", Object.class);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void mapRowSingleColumn() {
when(columnDefinitions.size()).thenReturn(1);
@@ -125,10 +107,7 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.mapRow(row, 2)).isEqualTo(42);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void mapRowSingleColumnNullValue() {
when(columnDefinitions.size()).thenReturn(1);
@@ -139,10 +118,7 @@ public class SingleColumnRowMapperUnitTests {
assertThat(rowMapper.mapRow(row, 2)).isNull();
}
/**
* @see DATACASS-335
*/
@Test(expected = TypeMismatchDataAccessException.class)
@Test(expected = TypeMismatchDataAccessException.class) // DATACASS-335
public void mapRowSingleColumnWrongType() {
when(columnDefinitions.size()).thenReturn(1);
@@ -153,10 +129,7 @@ public class SingleColumnRowMapperUnitTests {
rowMapper.mapRow(row, 2);
}
/**
* @see DATACASS-335
*/
@Test(expected = IncorrectResultSetColumnCountException.class)
@Test(expected = IncorrectResultSetColumnCountException.class) // DATACASS-335
public void tooManyColumns() {
when(columnDefinitions.size()).thenReturn(2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,10 +30,7 @@ import com.datastax.driver.core.policies.FallthroughRetryPolicy;
*/
public class WriteOptionsUnitTests {
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildWriteOptions() {
WriteOptions writeOptions = WriteOptions.builder() //
@@ -54,10 +51,7 @@ public class WriteOptionsUnitTests {
assertThat(writeOptions.getTracing()).isTrue();
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildReadTimeoutOptionsWriteOptions() {
WriteOptions writeOptions = WriteOptions.builder().readTimeout(1, TimeUnit.MINUTES).build();
@@ -67,10 +61,7 @@ public class WriteOptionsUnitTests {
assertThat(writeOptions.getTracing()).isNull();
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildQueryOptionsWithDriverRetryPolicy() {
QueryOptions writeOptions = QueryOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).build();
@@ -79,10 +70,7 @@ public class WriteOptionsUnitTests {
assertThat(writeOptions.getDriverRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE);
}
/**
* @see DATACASS-202
*/
@Test
@Test // DATACASS-202
public void buildQueryOptionsWithRetryPolicy() {
QueryOptions writeOptions = QueryOptions.builder().retryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY).build();
@@ -91,18 +79,12 @@ public class WriteOptionsUnitTests {
assertThat(writeOptions.getDriverRetryPolicy()).isNull();
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void builderShouldRejectSettingOurAndDriverRetryPolicy() {
WriteOptions.builder().retryPolicy(RetryPolicy.DEFAULT).retryPolicy(FallthroughRetryPolicy.INSTANCE);
}
/**
* @see DATACASS-202
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-202
public void builderShouldRejectSettingDriverAndOurRetryPolicy() {
WriteOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).retryPolicy(RetryPolicy.DEFAULT);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@ import com.datastax.driver.core.TableMetadata;
* Integration tests tests for {@link AlterTableCqlGenerator}.
*
* @author Mark Paluch
* @see DATACASS-192
*/
public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
@@ -48,10 +47,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
session.execute("DROP TABLE IF EXISTS users;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAlterColumnType() {
session.execute(
@@ -67,10 +63,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(column.getType()).isEqualTo(DataType.varint());
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAlterListColumnType() {
session.execute(
@@ -86,10 +79,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(column.getType()).isEqualTo((DataType) DataType.list(DataType.varchar()));
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddColumn() {
session.execute(
@@ -105,10 +95,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(column.getType()).isEqualTo(DataType.varchar());
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddListColumn() {
session.execute("CREATE TABLE users (user_name varchar PRIMARY KEY);");
@@ -123,10 +110,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(column.getType()).isEqualTo((DataType) DataType.list(DataType.ascii()));
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableDropColumn() {
session.execute("CREATE TABLE addamsFamily (name varchar PRIMARY KEY, gender varchar);");
@@ -138,10 +122,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(getTableMetadata("addamsfamily").getColumn("gender")).isNull();
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableRenameColumn() {
session.execute("CREATE TABLE addamsFamily (name varchar PRIMARY KEY, firstname varchar);");
@@ -154,10 +135,7 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(getTableMetadata("addamsfamily").getColumn("newname")).isNotNull();
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddCaching() {
session.execute("CREATE TABLE users (user_name varchar PRIMARY KEY);");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,10 +37,7 @@ import com.datastax.driver.core.DataType;
*/
public class AlterTableCqlGeneratorUnitTests {
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAlterColumnType() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").alter("lastKnownLocation",
@@ -49,10 +46,7 @@ public class AlterTableCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TABLE addamsfamily ALTER lastknownlocation TYPE uuid;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAlterListColumnType() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").alter("lastKnownLocation",
@@ -61,10 +55,7 @@ public class AlterTableCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TABLE addamsfamily ALTER lastknownlocation TYPE list<ascii>;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").add("gravesite",
@@ -73,10 +64,7 @@ public class AlterTableCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TABLE addamsfamily ADD gravesite varchar;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddListColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("users").add("top_places",
@@ -85,10 +73,7 @@ public class AlterTableCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TABLE users ADD top_places list<ascii>;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableDropColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").drop("gender");
@@ -96,10 +81,7 @@ public class AlterTableCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TABLE addamsfamily DROP gender;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableRenameColumn() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily").rename("firstname", "lastname");
@@ -107,10 +89,7 @@ public class AlterTableCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TABLE addamsfamily RENAME firstname TO lastname;");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddCommentAndTableOption() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily")
@@ -120,10 +99,7 @@ public class AlterTableCqlGeneratorUnitTests {
"ALTER TABLE addamsfamily WITH read_repair_chance = 0.2 AND comment = 'A most excellent and useful table';");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddColumnAndComment() {
AlterTableSpecification spec = AlterTableSpecification.alterTable("addamsFamily")
@@ -134,10 +110,7 @@ public class AlterTableCqlGeneratorUnitTests {
"ALTER TABLE addamsfamily ADD top_places list<ascii> ADD other list<ascii> WITH comment = 'A most excellent and useful table';");
}
/**
* @see DATACASS-192
*/
@Test
@Test // DATACASS-192
public void alterTableAddCaching() {
Map<Object, Object> cachingMap = new LinkedHashMap<Object, Object>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +38,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
session.execute("CREATE TYPE address (zip text, state text);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldAddField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
@@ -50,10 +47,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
session.execute(toCql(spec));
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldAlterField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
@@ -62,10 +56,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
session.execute(toCql(spec));
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldRenameField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
@@ -74,10 +65,7 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
session.execute(toCql(spec));
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldRenameFields() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
@@ -87,18 +75,12 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
session.execute(toCql(spec));
}
/**
* @see DATACASS-172
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-172
public void generationFailsIfNameIsNotSet() {
toCql(AlterUserTypeSpecification.alterType());
}
/**
* @see DATACASS-172
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-172
public void generationFailsWithoutFields() {
toCql(AlterUserTypeSpecification.alterType().name("hello"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,10 +30,7 @@ import com.datastax.driver.core.DataType;
*/
public class AlterUserTypeCqlGeneratorUnitTests {
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldAddField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
@@ -42,10 +39,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TYPE address ADD zip varchar;");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldAlterField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
@@ -54,10 +48,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TYPE address ALTER zip TYPE varchar;");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldRenameField() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
@@ -66,10 +57,7 @@ public class AlterUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TYPE address RENAME zip TO zap;");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void alterTypeShouldRenameFields() {
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address") //
@@ -79,18 +67,12 @@ public class AlterUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("ALTER TYPE address RENAME zip TO zap AND city TO county;");
}
/**
* @see DATACASS-172
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-172
public void generationFailsIfNameIsNotSet() {
toCql(AlterUserTypeSpecification.alterType());
}
/**
* @see DATACASS-172
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-172
public void generationFailsWithoutFields() {
toCql(AlterUserTypeSpecification.alterType().name("hello"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.cassandra.core.cql.generator.CreateUserTypeCqlGenerator.*;
import org.junit.Before;
@@ -41,10 +41,7 @@ public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspace
session.execute("DROP TYPE IF EXISTS address;");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void createUserType() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
@@ -59,10 +56,7 @@ public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspace
assertThat(address.getFieldNames()).contains("zip", "city");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void createUserTypeIfNotExists() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
@@ -77,10 +71,7 @@ public class CreateUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspace
assertThat(address.getFieldNames()).contains("zip", "city");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void createNestedUserType() {
CreateUserTypeSpecification addressSpec = CreateUserTypeSpecification //

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,10 +30,7 @@ import com.datastax.driver.core.DataType;
*/
public class CreateUserTypeCqlGeneratorUnitTests {
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void createUserType() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
@@ -43,10 +40,7 @@ public class CreateUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("CREATE TYPE address (city varchar);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void createMultiFieldUserType() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
@@ -57,10 +51,7 @@ public class CreateUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("CREATE TYPE address (zip ascii, city varchar);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void createUserTypeIfNotExists() {
CreateUserTypeSpecification spec = CreateUserTypeSpecification //
@@ -71,18 +62,12 @@ public class CreateUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("CREATE TYPE IF NOT EXISTS address (zip ascii, city varchar);");
}
/**
* @see DATACASS-172
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-172
public void generationFailsIfNameIsNotSet() {
toCql(CreateUserTypeSpecification.createType());
}
/**
* @see DATACASS-172
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-172
public void generationFailsWithoutFields() {
toCql(CreateUserTypeSpecification.createType().name("hello"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.springframework.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.cassandra.core.cql.generator.DropUserTypeCqlGenerator.*;
import org.junit.Test;
@@ -28,10 +28,7 @@ import org.springframework.cassandra.core.keyspace.DropUserTypeSpecification;
*/
public class DropUserTypeCqlGeneratorUnitTests {
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldDropUserType() {
DropUserTypeSpecification spec = DropUserTypeSpecification.dropType("address");
@@ -39,10 +36,7 @@ public class DropUserTypeCqlGeneratorUnitTests {
assertThat(toCql(spec)).isEqualTo("DROP TYPE address;");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldDropUserTypeIfExists() {
DropUserTypeSpecification spec = DropUserTypeSpecification.dropType("address").ifExists();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors
* Copyright 2013-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors
* Copyright 2013-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors
* Copyright 2016-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,10 +49,7 @@ public class CassandraAccessorUnitTests {
cassandraAccessor = new CassandraAccessor();
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void afterPropertiesSetWithUnitializedSessionThrowsIllegalStateException() {
try {
@@ -63,20 +60,14 @@ public class CassandraAccessorUnitTests {
}
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void setAndGetExceptionTranslator() {
cassandraAccessor.setExceptionTranslator(mockExceptionTranslator);
assertThat(cassandraAccessor.getExceptionTranslator()).isSameAs(mockExceptionTranslator);
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void setExceptionTranslatorToNullThrowsIllegalArgumentException() {
try {
@@ -87,28 +78,19 @@ public class CassandraAccessorUnitTests {
}
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void getUninitializedExceptionTranslatorReturnsDefault() {
assertThat(cassandraAccessor.getExceptionTranslator()).isEqualTo(cassandraAccessor.exceptionTranslator);
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void setAndGetSession() {
cassandraAccessor.setSession(mockSession);
assertThat(cassandraAccessor.getSession()).isSameAs(mockSession);
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void setSessionToNullThrowsIllegalArgumentException() {
try {
@@ -119,10 +101,7 @@ public class CassandraAccessorUnitTests {
}
}
/**
* @see DATACASS-286
*/
@Test
@Test // DATACASS-286
public void getUninitializedSessionThrowsIllegalStateException() {
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,7 @@
*/
package org.springframework.cassandra.support;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.springframework.cassandra.support.exception.CassandraInvalidConfigurationInQueryException;
@@ -88,10 +87,7 @@ public class CassandraExceptionTranslatorUnitTests {
assertThat(dax.getCause()).isEqualTo(cx);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void shouldTranslateWithCqlMessage() {
InvalidQueryException cx = new InvalidConfigurationInQueryException(null, "err");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,10 +57,7 @@ public class PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests
assertThat(ops).isNotNull();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void localAndRemotePoolingOptionsWereConfiguredProperly() {
PoolingOptions poolingOptions = cassandraCluster.getConfiguration().getPoolingOptions();
@@ -78,10 +75,7 @@ public class PropertyPlaceholderNamespaceCreatingXmlConfigIntegrationTests
assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.REMOTE)).isEqualTo(5);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void socketOptionsWereConfiguredProperly() {
SocketOptions socketOptions = cassandraCluster.getConfiguration().getSocketOptions();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -108,10 +108,7 @@ public class XmlConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrat
assertThat(((TestClusterBuilderConfigurer) clusterBuilderConfigurer).configureCalled.get()).isTrue();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void localAndRemotePoolingOptionsWereConfiguredProperly() {
PoolingOptions poolingOptions = cluster.getConfiguration().getPoolingOptions();
@@ -130,10 +127,7 @@ public class XmlConfigIntegrationTests extends AbstractEmbeddedCassandraIntegrat
assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.REMOTE)).isEqualTo(25);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-298">DATACASS-298</a>
*/
@Test
@Test // DATACASS-298
public void socketOptionsWereConfiguredProperly() {
SocketOptions socketOptions = cluster.getConfiguration().getSocketOptions();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2015 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2015 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package org.springframework.cassandra.test.integration.support;
import lombok.SneakyThrows;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
@@ -23,8 +25,6 @@ import org.springframework.util.Assert;
import com.google.common.io.Resources;
import lombok.SneakyThrows;
/**
* An executable CQL data set. The data set can be created from class path resources and execution can be bound to a
* particular keyspace.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.springframework.cassandra.test.integration.support;
import io.netty.channel.EventLoopGroup;
import java.util.concurrent.TimeUnit;
import com.datastax.driver.core.NettyOptions;
import io.netty.channel.EventLoopGroup;
/**
* {@link NettyOptions} to shutdown a {@link com.datastax.driver.core.Cluster} instance without wait time.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors
* Copyright 2013-2017 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,15 +18,10 @@ package org.springframework.data.cassandra.config;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.*;
import static org.springframework.data.cassandra.config.CassandraSessionFactoryBean.*;
import java.util.Collections;
import java.util.Map;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -38,15 +33,9 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.springframework.cassandra.core.cql.CqlIdentifier;
import org.springframework.data.cassandra.convert.CassandraConverter;
import org.springframework.data.cassandra.core.CassandraAdminOperations;
import org.springframework.data.cassandra.mapping.CassandraMappingContext;
import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.TableMetadata;
/**
* The CassandraSessionFactoryBeanUnitTests class is a test suite of test cases testing the contract and functionality
@@ -54,8 +43,6 @@ import com.datastax.driver.core.TableMetadata;
*
* @author John Blum
* @see org.springframework.data.cassandra.config.CassandraSessionFactoryBean
* @see <a href="https://jira.spring.io/browse/DATACASS-219>DATACASS-219</a>
* @since 1.5.0
*/
@RunWith(MockitoJUnitRunner.class)
public class CassandraSessionFactoryBeanUnitTests {
@@ -82,7 +69,7 @@ public class CassandraSessionFactoryBeanUnitTests {
return new CqlIdentifier(id, false);
}
@Test
@Test // DATACASS-219
public void afterPropertiesSetPerformsSchemaAction() throws Exception {
doAnswer(new Answer<Void>() {
@@ -107,7 +94,7 @@ public class CassandraSessionFactoryBeanUnitTests {
verify(factoryBean, times(1)).performSchemaAction();
}
@Test
@Test // DATACASS-219
public void afterPropertiesSetThrowsIllegalStateExceptionWhenConverterIsNull() throws Exception {
exception.expect(IllegalStateException.class);
@@ -117,7 +104,7 @@ public class CassandraSessionFactoryBeanUnitTests {
factoryBean.afterPropertiesSet();
}
protected void performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction schemaAction,
private void performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction schemaAction,
final boolean dropTables, final boolean dropUnused, final boolean ifNotExists) {
doAnswer(new Answer<Void>() {
@@ -131,39 +118,37 @@ public class CassandraSessionFactoryBeanUnitTests {
}).when(factoryBean).createTables(anyBoolean(), anyBoolean(), anyBoolean());
factoryBean.setSchemaAction(schemaAction);
assertThat(factoryBean.getSchemaAction()).isEqualTo(schemaAction);
factoryBean.performSchemaAction();
verify(factoryBean, times(1)).createTables(eq(dropTables), eq(dropUnused), eq(ifNotExists));
}
@Test
@Test // DATACASS-219
public void performsSchemaActionCreatesTablesWithDefaults() {
performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction.CREATE, DEFAULT_DROP_TABLES,
DEFAULT_DROP_UNUSED_TABLES, DEFAULT_CREATE_IF_NOT_EXISTS);
}
@Test
@Test // DATACASS-219
public void performsSchemaActionCreatesTablesIfNotExists() {
performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction.CREATE_IF_NOT_EXISTS,
DEFAULT_DROP_TABLES, DEFAULT_DROP_UNUSED_TABLES, true);
}
@Test
@Test // DATACASS-219
public void performsSchemaActionRecreatesTables() {
performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction.RECREATE, true,
DEFAULT_DROP_UNUSED_TABLES, DEFAULT_CREATE_IF_NOT_EXISTS);
}
@Test
@Test // DATACASS-219
public void performsSchemaActionRecreatesAndDropsUnusedTables() {
performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction.RECREATE_DROP_UNUSED, true,
true, DEFAULT_CREATE_IF_NOT_EXISTS);
}
@Test
@Test // DATACASS-219
public void performsSchemaActionDoesNotCallCreateTablesWhenSchemaActionIsNone() {
doAnswer(new Answer<Void>() {
@@ -183,7 +168,7 @@ public class CassandraSessionFactoryBeanUnitTests {
verify(factoryBean, never()).createTables(anyBoolean(), anyBoolean(), anyBoolean());
}
@Test
@Test // DATACASS-219
public void setAndGetConverter() {
assertThat(factoryBean.getConverter()).isNull();
@@ -192,7 +177,7 @@ public class CassandraSessionFactoryBeanUnitTests {
verifyZeroInteractions(mockConverter);
}
@Test
@Test // DATACASS-219
public void setConverterToNull() {
exception.expect(IllegalArgumentException.class);
@@ -201,7 +186,7 @@ public class CassandraSessionFactoryBeanUnitTests {
factoryBean.setConverter(null);
}
@Test
@Test // DATACASS-219
public void setAndGetSchemaAction() {
assertThat(factoryBean.getSchemaAction()).isEqualTo(SchemaAction.NONE);
@@ -211,8 +196,9 @@ public class CassandraSessionFactoryBeanUnitTests {
assertThat(factoryBean.getSchemaAction()).isEqualTo(SchemaAction.NONE);
}
@Test
@Test // DATACASS-219
public void setSchemaActionToNullThrowsIllegalArgumentException() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("SchemaAction must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,6 @@ import com.datastax.driver.core.TableMetadata;
*
* @author John Blum
* @author Mark Paluch
* @see <a href="https://jira.spring.io/browse/DATACASS-219>DATACASS-219</a>
*/
public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraIntegrationTest {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,10 +47,7 @@ public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbedd
@Autowired ApplicationContext applicationContext;
/**
* @see DATACASS-271
*/
@Test
@Test // DATACASS-271
public void clusterShouldHaveCompressionSet() {
Cluster cluster = applicationContext.getBean(Cluster.class);
@@ -58,10 +55,7 @@ public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbedd
assertThat(configuration.getProtocolOptions().getCompression()).isEqualTo(Compression.SNAPPY);
}
/**
* @see DATACASS-271
*/
@Test
@Test // DATACASS-271
public void clusterShouldHavePoolingOptionsConfigured() {
Cluster cluster = applicationContext.getBean(Cluster.class);
@@ -77,10 +71,7 @@ public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbedd
assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.REMOTE)).isEqualTo(2);
}
/**
* @see DATACASS-271
*/
@Test
@Test // DATACASS-271
public void clusterShouldHaveSocketOptionsConfigured() {
Cluster cluster = applicationContext.getBean(Cluster.class);
@@ -95,15 +86,13 @@ public class CassandraNamespaceIntegrationTests extends AbstractSpringDataEmbedd
assertThat(socketOptions.getSendBufferSize()).isEqualTo(65536);
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void mappingContextShouldHaveUserTypeResolverConfigured() {
BasicCassandraMappingContext mappingContext = applicationContext.getBean(BasicCassandraMappingContext.class);
SimpleUserTypeResolver userTypeResolver = (SimpleUserTypeResolver) ReflectionTestUtils.getField(mappingContext, "userTypeResolver");
SimpleUserTypeResolver userTypeResolver = (SimpleUserTypeResolver) ReflectionTestUtils.getField(mappingContext,
"userTypeResolver");
assertThat(userTypeResolver).isNotNull();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,10 +28,7 @@ import org.springframework.data.cassandra.domain.Person;
*/
public class ConverterRegistrationUnitTests {
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersNotExplicitlyReadingDependingOnTypes() {
ConverterRegistration context = new ConverterRegistration(Person.class, String.class, false, false);
@@ -47,10 +44,7 @@ public class ConverterRegistrationUnitTests {
assertThat(context.isReading()).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void forcesReadWriteOnlyIfAnnotated() {
ConverterRegistration context = new ConverterRegistration(String.class, Class.class, false, true);
@@ -62,10 +56,7 @@ public class ConverterRegistrationUnitTests {
assertThat(context.isReading()).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersConverterForReadAndWriteIfBothAnnotated() {
ConverterRegistration context = new ConverterRegistration(String.class, Class.class, true, true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,10 +47,7 @@ import com.datastax.driver.core.Row;
*/
public class CustomConversionsUnitTests {
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void findsBasicReadAndWriteConversions() {
CustomConversions conversions = new CustomConversions(
@@ -63,10 +60,7 @@ public class CustomConversionsUnitTests {
assertThat(conversions.hasCustomReadTarget(String.class, Locale.class)).isFalse();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersSubtypesCorrectly() {
CustomConversions conversions = new CustomConversions(
@@ -76,20 +70,14 @@ public class CustomConversionsUnitTests {
assertThat(conversions.hasCustomReadTarget(String.class, Long.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersTypesWeRegisteredConvertersForAsSimple() {
CustomConversions conversions = new CustomConversions(Arrays.asList(FormatToStringConverter.INSTANCE));
assertThat(conversions.isSimpleType(UUID.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void populatesConversionServiceCorrectly() {
GenericConversionService conversionService = new DefaultConversionService();
@@ -100,20 +88,14 @@ public class CustomConversionsUnitTests {
assertThat(conversionService.canConvert(String.class, Format.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void doesNotConsiderTypeSimpleIfOnlyReadConverterIsRegistered() {
CustomConversions conversions = new CustomConversions(Arrays.asList(StringToFormatConverter.INSTANCE));
assertThat(conversions.isSimpleType(Format.class)).isFalse();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void discoversConvertersForSubtypesOfCassandraTypes() {
CustomConversions conversions = new CustomConversions(Arrays.asList(StringToIntegerConverter.INSTANCE));
@@ -121,40 +103,28 @@ public class CustomConversionsUnitTests {
assertThat(conversions.hasCustomWriteTarget(String.class, Integer.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersUUIDASimpleType() {
CustomConversions conversions = new CustomConversions();
assertThat(conversions.isSimpleType(UUID.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersInetAddressASimpleType() {
CustomConversions conversions = new CustomConversions();
assertThat(conversions.isSimpleType(InetAddress.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void considersRowASimpleType() {
CustomConversions conversions = new CustomConversions();
assertThat(conversions.isSimpleType(Row.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
@SuppressWarnings("rawtypes")
public void favorsCustomConverterForIndeterminedTargetType() {
@@ -162,10 +132,7 @@ public class CustomConversionsUnitTests {
assertThat(conversions.getCustomWriteTarget(DateTime.class, null)).isEqualTo((Class) String.class);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void customConverterOverridesDefault() {
CustomConversions conversions = new CustomConversions(Arrays.asList(CustomDateTimeConverter.INSTANCE));
@@ -175,30 +142,21 @@ public class CustomConversionsUnitTests {
assertThat(conversionService.convert(new DateTime(), Date.class)).isEqualTo(new Date(0));
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldSelectPropertCustomWriteTargetForCglibProxiedType() {
CustomConversions conversions = new CustomConversions(Arrays.asList(FormatToStringConverter.INSTANCE));
assertThat(conversions.getCustomWriteTarget(createProxyTypeFor(Format.class))).isAssignableFrom(String.class);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldSelectPropertyCustomReadTargetForCglibProxiedType() {
CustomConversions conversions = new CustomConversions(Arrays.asList(CustomObjectToStringConverter.INSTANCE));
assertThat(conversions.hasCustomReadTarget(createProxyTypeFor(Object.class), String.class)).isTrue();
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void registersConverterFactoryCorrectly() {
CustomConversions customConversions = new CustomConversions(
@@ -207,10 +165,7 @@ public class CustomConversionsUnitTests {
assertThat(customConversions.getCustomWriteTarget(String.class, SimpleDateFormat.class)).isNotNull();
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void registersConvertersForJsr310() {
CustomConversions customConversions = new CustomConversions();
@@ -218,10 +173,7 @@ public class CustomConversionsUnitTests {
assertThat(customConversions.hasCustomWriteTarget(java.time.LocalDateTime.class)).isTrue();
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void registersConvertersForThreeTenBackPort() {
CustomConversions customConversions = new CustomConversions();
@@ -229,10 +181,7 @@ public class CustomConversionsUnitTests {
assertThat(customConversions.hasCustomWriteTarget(org.threeten.bp.LocalDateTime.class)).isTrue();
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void registersConvertersForJoda() {
CustomConversions customConversions = new CustomConversions();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,9 @@
*/
package org.springframework.data.cassandra.convert;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import lombok.Data;
import java.util.Arrays;
import java.util.Collections;
@@ -53,8 +55,6 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.driver.core.querybuilder.Update;
import lombok.Data;
/**
* Integration tests for UDT types through {@link MappingCassandraConverter}.
*
@@ -122,10 +122,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
}
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldReadMappedUdt() {
session.execute("INSERT INTO addressbook (id, currentaddress) " + "VALUES ('1', "
@@ -142,10 +139,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(address.getStreetLines()).contains("Heckenpfad", "14");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteMappedUdt() {
AddressUserType addressUserType = new AddressUserType();
@@ -164,10 +158,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
+ "VALUES (null,{zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']},'1',null);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldReadMappedUdtCollection() {
session.execute("INSERT INTO addressbook (id, previousaddresses) " + "VALUES ('1', "
@@ -185,10 +176,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(address.getStreetLines()).isEmpty();
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteMappedUdtCollection() {
AddressUserType addressUserType = new AddressUserType();
@@ -207,10 +195,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
+ "VALUES (null,null,'1',[{zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']}]);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldReadUdt() {
session.execute("INSERT INTO addressbook (id, alternate) " + "VALUES ('1', "
@@ -224,10 +209,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(addressBook.getAlternate().getString("zip")).isEqualTo("69469");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdt() {
CassandraPersistentEntity<?> persistentEntity = converter.getMappingContext()
@@ -248,10 +230,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
+ "VALUES ({zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']},null,'1',null);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtPk() {
AddressUserType addressUserType = new AddressUserType();
@@ -269,10 +248,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
"INSERT INTO addressbook (id) " + "VALUES ({zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']});");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteMappedUdtPk() {
CassandraPersistentEntity<?> persistentEntity = converter.getMappingContext()
@@ -292,10 +268,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
"INSERT INTO addressbook (id) " + "VALUES ({zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']});");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldReadUdtWithCustomConversion() {
session.execute("INSERT INTO bank (id, currency) " + "VALUES ('1', {currency:'EUR'});");
@@ -307,10 +280,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(addressBook.getCurrency().getCurrencyCode()).isEqualTo("EUR");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldReadUdtListWithCustomConversion() {
session.execute("INSERT INTO bank (id, othercurrencies) " + "VALUES ('1', [{currency:'EUR'}]);");
@@ -321,10 +291,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(addressBook.getOtherCurrencies()).hasSize(1).contains(Currency.getInstance("EUR"));
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtWithCustomConversion() {
Bank bank = new Bank();
@@ -333,13 +300,11 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
Insert insert = QueryBuilder.insertInto("bank");
converter.write(bank, insert);
assertThat(insert.toString()).isEqualTo("INSERT INTO bank (currency,id,othercurrencies) VALUES ({currency:'EUR'},null,null);");
assertThat(insert.toString())
.isEqualTo("INSERT INTO bank (currency,id,othercurrencies) VALUES ({currency:'EUR'},null,null);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtUpdateWherePrimaryKeyWithCustomConversion() {
Money money = new Money();
@@ -351,10 +316,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(update.toString()).isEqualTo("UPDATE money WHERE currency={currency:'EUR'};");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtUpdateAssignmentsWithCustomConversion() {
MoneyTransfer money = new MoneyTransfer();
@@ -367,10 +329,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(update.toString()).isEqualTo("UPDATE money SET currency={currency:'EUR'} WHERE id='1';");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtSelectWherePrimaryKeyWithCustomConversion() {
Money money = new Money();
@@ -382,10 +341,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(select.toString()).isEqualTo("SELECT * FROM money WHERE currency={currency:'EUR'};");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtDeleteWherePrimaryKeyWithCustomConversion() {
Money money = new Money();
@@ -397,10 +353,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(delete.toString()).isEqualTo("DELETE FROM money WHERE currency={currency:'EUR'};");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteUdtListWithCustomConversion() {
Bank bank = new Bank();
@@ -409,13 +362,11 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
Insert insert = QueryBuilder.insertInto("bank");
converter.write(bank, insert);
assertThat(insert.toString()).isEqualTo("INSERT INTO bank (currency,id,othercurrencies) VALUES (null,null,[{currency:'EUR'}]);");
assertThat(insert.toString())
.isEqualTo("INSERT INTO bank (currency,id,othercurrencies) VALUES (null,null,[{currency:'EUR'}]);");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldReadNestedUdt() {
session.execute("INSERT INTO car (id, engine) VALUES ('1', {manufacturer: {name:'a good one'}});");
@@ -428,10 +379,7 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
assertThat(car.getEngine().getManufacturer().getName()).isEqualTo("a good one");
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldWriteNestedUdt() {
session.execute("INSERT INTO car (id, engine) VALUES ('1', {manufacturer: {name:'a good one'}});");
@@ -449,7 +397,8 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
Insert insert = QueryBuilder.insertInto("car");
converter.write(car, insert);
assertThat(insert.toString()).isEqualTo("INSERT INTO car (engine,id) VALUES ({manufacturer:{name:'a good one'}},'1');");
assertThat(insert.toString())
.isEqualTo("INSERT INTO car (engine,id) VALUES ({manufacturer:{name:'a good one'}},'1');");
}
@Table

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,20 +40,6 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.DataType.Name;
import com.datastax.driver.core.LocalDate;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.querybuilder.Assignment;
import com.datastax.driver.core.querybuilder.BuiltStatement;
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.Delete;
import com.datastax.driver.core.querybuilder.Delete.Where;
import com.datastax.driver.core.querybuilder.Insert;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Update;
import com.datastax.driver.core.querybuilder.Update.Assignments;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -81,6 +67,20 @@ import org.springframework.data.cassandra.mapping.Table;
import org.springframework.data.util.Version;
import org.springframework.test.util.ReflectionTestUtils;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.DataType.Name;
import com.datastax.driver.core.LocalDate;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.querybuilder.Assignment;
import com.datastax.driver.core.querybuilder.BuiltStatement;
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.Delete;
import com.datastax.driver.core.querybuilder.Delete.Where;
import com.datastax.driver.core.querybuilder.Insert;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Update;
import com.datastax.driver.core.querybuilder.Update.Assignments;
/**
* Unit tests for {@link MappingCassandraConverter}.
*
@@ -109,10 +109,7 @@ public class MappingCassandraConverterUnitTests {
mappingCassandraConverter.afterPropertiesSet();
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void insertEnumShouldMapToString() {
WithEnumColumns withEnumColumns = new WithEnumColumns();
@@ -126,10 +123,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert)).contains("MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void insertEnumDoesNotMapToOrdinalBeforeSpring43() {
assumeTrue(Version.parse(SpringVersion.getVersion()).isLessThan(VERSION_4_3));
@@ -144,10 +138,7 @@ public class MappingCassandraConverterUnitTests {
mappingCassandraConverter.write(unsupportedEnumToOrdinalMapping, insert);
}
/**
* @see DATACASS-255
*/
@Test
@Test // DATACASS-255
public void insertEnumMapsToOrdinalWithSpring43AndHiger() {
assumeTrue(Version.parse(SpringVersion.getVersion()).isGreaterThanOrEqualTo(VERSION_4_3));
@@ -162,10 +153,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert)).contains((Object) Integer.valueOf(Condition.USED.ordinal()));
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void insertEnumAsPrimaryKeyShouldMapToString() {
EnumPrimaryKey key = new EnumPrimaryKey();
@@ -178,10 +166,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert)).contains((Object) "MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void insertEnumInCompositePrimaryKeyShouldMapToString() {
EnumCompositePrimaryKey key = new EnumCompositePrimaryKey();
@@ -197,10 +182,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert)).contains((Object) "MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void updateEnumShouldMapToString() {
WithEnumColumns withEnumColumns = new WithEnumColumns();
@@ -213,10 +195,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getAssignmentValues(update)).contains((Object) "MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void updateEnumAsPrimaryKeyShouldMapToString() {
EnumPrimaryKey key = new EnumPrimaryKey();
@@ -229,10 +208,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWhereValues(update)).contains((Object) "MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void updateEnumInCompositePrimaryKeyShouldMapToString() {
EnumCompositePrimaryKey key = new EnumCompositePrimaryKey();
@@ -248,10 +224,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWhereValues(update)).contains((Object) "MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void whereEnumAsPrimaryKeyShouldMapToString() {
EnumPrimaryKey key = new EnumPrimaryKey();
@@ -264,10 +237,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWhereValues(where)).contains((Object) "MINT");
}
/**
* @see DATACASS-260
*/
@Test
@Test // DATACASS-260
public void whereEnumInCompositePrimaryKeyShouldMapToString() {
EnumCompositePrimaryKey key = new EnumCompositePrimaryKey();
@@ -283,10 +253,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWhereValues(where)).contains((Object) "MINT");
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadStringCorrectly() {
when(rowMock.getString(0)).thenReturn("foo");
@@ -296,10 +263,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo("foo");
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadIntegerCorrectly() {
when(rowMock.getObject(0)).thenReturn(2);
@@ -309,10 +273,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(2);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadLongCorrectly() {
when(rowMock.getObject(0)).thenReturn(2);
@@ -322,10 +283,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(2L);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadDoubleCorrectly() {
when(rowMock.getObject(0)).thenReturn(2D);
@@ -335,10 +293,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(2D);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadFloatCorrectly() {
when(rowMock.getObject(0)).thenReturn(2F);
@@ -348,10 +303,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(2F);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadBigIntegerCorrectly() {
when(rowMock.getObject(0)).thenReturn(BigInteger.valueOf(2));
@@ -361,10 +313,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(BigInteger.valueOf(2));
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadBigDecimalCorrectly() {
when(rowMock.getObject(0)).thenReturn(BigDecimal.valueOf(2));
@@ -374,10 +323,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(BigDecimal.valueOf(2));
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadUUIDCorrectly() {
UUID uuid = UUID.randomUUID();
@@ -389,10 +335,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(uuid);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadInetAddressCorrectly() throws UnknownHostException {
InetAddress localHost = InetAddress.getLocalHost();
@@ -404,11 +347,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(localHost);
}
/**
* @see DATACASS-280
* @see DATACASS-271
*/
@Test
@Test // DATACASS-280, DATACASS-271
public void shouldReadTimestampCorrectly() {
Date date = new Date(1);
@@ -420,10 +359,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(date);
}
/**
* @see DATACASS-271
*/
@Test
@Test // DATACASS-271
public void shouldReadDateCorrectly() {
LocalDate date = LocalDate.fromDaysSinceEpoch(1234);
@@ -435,10 +371,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(date);
}
/**
* @see DATACASS-280
*/
@Test
@Test // DATACASS-280
public void shouldReadBooleanCorrectly() {
when(rowMock.getBool(0)).thenReturn(true);
@@ -448,10 +381,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result).isEqualTo(true);
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadLocalDateCorrectly() {
LocalDateTime now = LocalDateTime.now();
@@ -467,10 +397,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.localDate.getMonthValue()).isEqualTo(now.getMonthValue());
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateCorrectly() {
java.time.LocalDate now = java.time.LocalDate.now();
@@ -486,10 +413,7 @@ public class MappingCassandraConverterUnitTests {
.contains(LocalDate.fromYearMonthDay(now.getYear(), now.getMonthValue(), now.getDayOfMonth()));
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateUpdateWithLocalDateCorrectly() {
java.time.LocalDate now = java.time.LocalDate.now();
@@ -505,10 +429,7 @@ public class MappingCassandraConverterUnitTests {
.contains(LocalDate.fromYearMonthDay(now.getYear(), now.getMonthValue(), now.getDayOfMonth()));
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateListUsingCassandraDate() {
java.time.LocalDate now = java.time.LocalDate.now();
@@ -527,10 +448,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(dates).contains(LocalDate.fromYearMonthDay(2010, 7, 4));
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateSetUsingCassandraDate() {
java.time.LocalDate now = java.time.LocalDate.now();
@@ -549,10 +467,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(dates).contains(LocalDate.fromYearMonthDay(2010, 7, 4));
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadLocalDateTimeUsingCassandraDateCorrectly() {
Row rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataType.ascii()),
@@ -567,10 +482,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.localDate.getDayOfMonth()).isEqualTo(4);
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateInsertWithLocalDateUsingCassandraDateCorrectly() {
TypeWithLocalDateMappedToDate typeWithLocalDate = new TypeWithLocalDateMappedToDate();
@@ -583,10 +495,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert).contains(LocalDate.fromYearMonthDay(2010, 7, 4))).isTrue();
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateUpdateWithLocalDateUsingCassandraDateCorrectly() {
TypeWithLocalDateMappedToDate typeWithLocalDate = new TypeWithLocalDateMappedToDate();
@@ -599,10 +508,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getAssignmentValues(update)).contains(LocalDate.fromYearMonthDay(2010, 7, 4));
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadLocalDateTimeCorrectly() {
LocalDateTime now = LocalDateTime.now();
@@ -618,10 +524,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.localDateTime.getMinute()).isEqualTo(now.getMinute());
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadInstantCorrectly() {
LocalDateTime now = LocalDateTime.now();
@@ -636,10 +539,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.instant.getEpochSecond()).isEqualTo(instant.getEpochSecond());
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadZoneIdCorrectly() {
Row rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataType.ascii()),
@@ -651,10 +551,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.zoneId.getId()).isEqualTo("Europe/Paris");
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadJodaLocalDateTimeUsingCassandraDateCorrectly() {
Row rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataType.ascii()),
@@ -669,10 +566,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.localDate.getDayOfMonth()).isEqualTo(4);
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateInsertWithJodaLocalDateUsingCassandraDateCorrectly() {
TypeWithJodaLocalDateMappedToDate typeWithLocalDate = new TypeWithJodaLocalDateMappedToDate();
@@ -685,10 +579,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert).contains(LocalDate.fromYearMonthDay(2010, 7, 4))).isTrue();
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateUpdateWithJodaLocalDateUsingCassandraDateCorrectly() {
TypeWithJodaLocalDateMappedToDate typeWithLocalDate = new TypeWithJodaLocalDateMappedToDate();
@@ -701,10 +592,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getAssignmentValues(update)).contains(LocalDate.fromYearMonthDay(2010, 7, 4));
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldReadThreeTenBpLocalDateTimeUsingCassandraDateCorrectly() {
Row rowMock = RowMockUtil.newRowMock(column("id", "my-id", DataType.ascii()),
@@ -719,10 +607,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(result.localDate.getDayOfMonth()).isEqualTo(4);
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateInsertWithThreeTenBpLocalDateUsingCassandraDateCorrectly() {
TypeWithThreeTenBpLocalDateMappedToDate typeWithLocalDate = new TypeWithThreeTenBpLocalDateMappedToDate();
@@ -735,10 +620,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getValues(insert).contains(LocalDate.fromYearMonthDay(2010, 7, 4))).isTrue();
}
/**
* @see DATACASS-296
*/
@Test
@Test // DATACASS-296
public void shouldCreateUpdateWithThreeTenBpLocalDateUsingCassandraDateCorrectly() {
TypeWithThreeTenBpLocalDateMappedToDate typeWithLocalDate = new TypeWithThreeTenBpLocalDateMappedToDate();
@@ -751,10 +633,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getAssignmentValues(update)).contains(LocalDate.fromYearMonthDay(2010, 7, 4));
}
/**
* @see DATACASS-206
*/
@Test
@Test // DATACASS-206
public void updateShouldUseSpecifiedColumnNames() {
UserToken userToken = new UserToken();
@@ -772,10 +651,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(update)).containsEntry("user_id", userToken.getUserId());
}
/**
* @see DATACASS-206
*/
@Test
@Test // DATACASS-206
public void deleteShouldUseSpecifiedColumnNames() {
UserToken userToken = new UserToken();
@@ -791,10 +667,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("user_id", userToken.getUserId());
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionUsingPlainId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -804,10 +677,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("id", "42");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionUsingEntity() {
Delete delete = QueryBuilder.delete().from("table");
@@ -820,10 +690,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("id", "42");
}
/**
* @see DATACASS-308
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-308
public void shouldFailWriteWhereConditionUsingEntityWithNullId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -831,10 +698,7 @@ public class MappingCassandraConverterUnitTests {
mappingCassandraConverter.write(new Person(), delete.where(), mappingContext.getPersistentEntity(Person.class));
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionUsingMapId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -844,10 +708,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("id", "42");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForCompositeKeyUsingEntity() {
Delete delete = QueryBuilder.delete().from("table");
@@ -863,10 +724,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForCompositeKeyUsingMapId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -878,10 +736,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForMapIdKeyUsingEntity() {
Delete delete = QueryBuilder.delete().from("table");
@@ -896,10 +751,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteEnumWhereCondition() {
Delete delete = QueryBuilder.delete().from("table");
@@ -910,10 +762,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("condition", "MINT");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForMapIdKeyUsingMapId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -925,10 +774,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForTypeWithPkClassKeyUsingEntity() {
Delete delete = QueryBuilder.delete().from("table");
@@ -946,10 +792,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-308
public void shouldFailWritingWhereConditionForTypeWithPkClassKeyUsingEntityWithNullId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -958,10 +801,7 @@ public class MappingCassandraConverterUnitTests {
mappingContext.getPersistentEntity(TypeWithKeyClass.class));
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForTypeWithPkClassKeyUsingKey() {
Delete delete = QueryBuilder.delete().from("table");
@@ -976,10 +816,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test
@Test // DATACASS-308
public void shouldWriteWhereConditionForTypeWithPkClassKeyUsingMapId() {
Delete delete = QueryBuilder.delete().from("table");
@@ -991,10 +828,7 @@ public class MappingCassandraConverterUnitTests {
assertThat(getWherePredicates(delete)).containsEntry("lastname", "White");
}
/**
* @see DATACASS-308
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class) // DATACASS-308
public void shouldFailWhereConditionForTypeWithPkClassKeyUsingMapIdHavingUnknownProperty() {
Delete delete = QueryBuilder.delete().from("table");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,10 +48,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea
SchemaTestUtils.truncate(Person.class, cassandraTemplate);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldInsertEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -64,10 +61,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isEqualTo(person);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void shouldInsertAndCountEntities() throws Exception {
Person person = new Person("heisenberg", "Walter", "White");
@@ -78,10 +72,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(getUninterruptibly(count)).isEqualTo(1L);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldUpdateEntity() throws Exception {
Person person = new Person("heisenberg", "Walter", "White");
@@ -94,10 +85,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isEqualTo(person);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldRemoveEntity() throws Exception {
Person person = new Person("heisenberg", "Walter", "White");
@@ -109,10 +97,7 @@ public class AsyncCassandraTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(getUninterruptibly(template.selectOneById(person.getId(), Person.class))).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteByIdShouldRemoveEntity() throws Exception {
Person person = new Person("heisenberg", "Walter", "White");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.cassandra.support.exception.CassandraConnectionFailureException;
import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.domain.Person;
import org.springframework.util.concurrent.ListenableFuture;
@@ -78,10 +77,7 @@ public class AsyncCassandraTemplateUnitTests {
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectUsingCqlShouldReturnMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -103,10 +99,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectUsingCqlShouldInvokeCallbackWithMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -132,10 +125,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectShouldTranslateException() throws Exception {
when(resultSet.iterator()).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -152,10 +142,7 @@ public class AsyncCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectOneShouldReturnMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -177,10 +164,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectOneByIdShouldReturnMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -202,10 +186,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void existsShouldReturnExistingElement() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -219,10 +200,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void existsShouldReturnNonExistingElement() {
when(resultSet.iterator()).thenReturn(Collections.emptyIterator());
@@ -234,10 +212,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void countShouldExecuteCountQueryElement() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -251,10 +226,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM person;");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldInsertEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -269,10 +241,7 @@ public class AsyncCassandraTemplateUnitTests {
.isEqualTo("INSERT INTO person (firstname,id,lastname) VALUES ('Walter','heisenberg','White');");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldTranslateException() throws Exception {
reset(session);
@@ -291,10 +260,7 @@ public class AsyncCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldNotApplyInsert() {
when(resultSet.wasApplied()).thenReturn(false);
@@ -306,10 +272,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(getUninterruptibly(future)).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldUpdateEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -324,10 +287,7 @@ public class AsyncCassandraTemplateUnitTests {
.isEqualTo("UPDATE person SET firstname='Walter',lastname='White' WHERE id='heisenberg';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldTranslateException() throws Exception {
reset(session);
@@ -346,10 +306,7 @@ public class AsyncCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldNotApplyUpdate() {
when(resultSet.wasApplied()).thenReturn(false);
@@ -361,10 +318,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(getUninterruptibly(future)).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteByIdShouldRemoveEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -378,10 +332,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldRemoveEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -395,10 +346,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldTranslateException() throws Exception {
reset(session);
@@ -417,10 +365,7 @@ public class AsyncCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldNotApplyRemoval() {
when(resultSet.wasApplied()).thenReturn(false);
@@ -432,10 +377,7 @@ public class AsyncCassandraTemplateUnitTests {
assertThat(getUninterruptibly(future)).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void truncateShouldRemoveEntities() {
template.truncate(Person.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import org.springframework.cassandra.core.cql.generator.DropTableCqlGenerator;
import org.springframework.cassandra.core.keyspace.DropTableSpecification;
import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.core.CassandraAdminTemplate;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import com.datastax.driver.core.KeyspaceMetadata;
@@ -60,10 +59,7 @@ public class CassandraAdminTemplateIntegrationTests extends AbstractKeyspaceCrea
return metadata.getKeyspace(getSession().getLoggedKeyspace());
}
/**
* @see DATACASS-173
*/
@Test
@Test // DATACASS-173
public void testCreateTables() throws Exception {
assertThat(getKeyspaceMetadata().getTables()).hasSize(0);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,10 +53,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
SchemaTestUtils.truncate(FlatGroup.class, template);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldInsertEntities() {
Group walter = new Group(new GroupKey("users", "0x1", "walter"));
@@ -70,10 +67,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded.getId().getUsername()).isEqualTo(walter.getId().getUsername());
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldInsertCollectionOfEntities() {
Group walter = new Group(new GroupKey("users", "0x1", "walter"));
@@ -87,10 +81,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded.getId().getUsername()).isEqualTo(walter.getId().getUsername());
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldUpdateEntities() {
Group walter = template.insert(new Group(new GroupKey("users", "0x1", "walter")));
@@ -107,10 +98,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded.getEmail()).isEqualTo(walter.getEmail());
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldUpdateCollectionOfEntities() {
Group walter = template.insert(new Group(new GroupKey("users", "0x1", "walter")));
@@ -127,10 +115,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded.getEmail()).isEqualTo(walter.getEmail());
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldUpdatesCollectionOfEntities() {
FlatGroup walter = template.insert(new FlatGroup("users", "0x1", "walter"));
@@ -147,10 +132,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded.getEmail()).isEqualTo(walter.getEmail());
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldDeleteEntities() {
Group walter = template.insert(new Group(new GroupKey("users", "0x1", "walter")));
@@ -165,10 +147,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded).isNull();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldDeleteCollectionOfEntities() {
Group walter = template.insert(new Group(new GroupKey("users", "0x1", "walter")));
@@ -183,10 +162,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
assertThat(loaded).isNull();
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test
@Test // DATACASS-288
public void shouldApplyTimestampToAllEntities() {
Group walter = new Group(new GroupKey("users", "0x1", "walter"));
@@ -209,10 +185,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
}
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-288
public void shouldNotExecuteTwice() {
CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template);
@@ -223,10 +196,7 @@ public class CassandraBatchTemplateIntegrationTests extends AbstractKeyspaceCrea
fail("Missing IllegalStateException");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-288">DATACASS-288</a>
*/
@Test(expected = IllegalStateException.class)
@Test(expected = IllegalStateException.class) // DATACASS-288
public void shouldNotAllowModificationAfterExecution() {
CassandraBatchOperations batchOperations = new CassandraBatchTemplate(template);

View File

@@ -66,10 +66,7 @@ public class CassandraPersistentEntitySchemaCreatorUnitTests {
when(adminOperations.getCqlOperations()).thenReturn(operations);
}
/**
* @see DATACASS-172
*/
@Test
@Test // DATACASS-172
public void shouldCreateTypesInOrder() {
context.getPersistentEntity(MoonType.class);

View File

@@ -58,9 +58,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests {
BasicCassandraMappingContext context = new BasicCassandraMappingContext();
/**
* @see DATACASS-355
*/
// DATACASS-355
@Before
public void setUp() throws Exception {
@@ -79,10 +77,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests {
when(contact.getName()).thenReturn("contact");
}
/**
* @see DATACASS-355
*/
@Test
@Test // DATACASS-355
public void shouldDropTypes() throws Exception {
context.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(MoonType.class, UniverseType.class)));
@@ -102,10 +97,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests {
verifyNoMoreInteractions(operations);
}
/**
* @see DATACASS-355
*/
@Test
@Test // DATACASS-355
public void dropUserTypesShouldRetainUnusedTypes() {
context.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(MoonType.class, UniverseType.class)));
@@ -124,10 +116,7 @@ public class CassandraPersistentEntitySchemaDropperUnitTests {
verifyNoMoreInteractions(operations);
}
/**
* @see DATACASS-355
*/
@Test
@Test // DATACASS-355
public void shouldDropTables() throws Exception {
context.setInitialEntitySet(Collections.singleton(Person.class));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,10 +60,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
SchemaTestUtils.truncate(BookReference.class, template);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldInsertEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -76,10 +73,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(template.selectOneById(person.getId(), Person.class)).isEqualTo(person);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void shouldInsertAndCountEntities() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -90,10 +84,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(count).isEqualTo(1L);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldUpdateEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -106,10 +97,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(template.selectOneById(person.getId(), Person.class)).isEqualTo(person);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldRemoveEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -121,10 +109,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(template.selectOneById(person.getId(), Person.class)).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteByIdShouldRemoveEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -136,10 +121,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(template.selectOneById(person.getId(), Person.class)).isNull();
}
/**
* @see DATACASS-182
*/
@Test
@Test // DATACASS-182
public void stream() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -150,10 +132,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(stream.collect(Collectors.toList())).hasSize(1).contains(person);
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-182">DATACASS-182</a>
*/
@Test
@Test // DATACASS-182
public void updateShouldRemoveFields() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -169,10 +148,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(loaded.getId()).isEqualTo("heisenberg");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-182">DATACASS-182</a>
*/
@Test
@Test // DATACASS-182
public void insertShouldRemoveFields() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -188,10 +164,7 @@ public class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingI
assertThat(loaded.getId()).isEqualTo("heisenberg");
}
/**
* @see <a href="https://jira.spring.io/browse/DATACASS-182">DATACASS-182</a>
*/
@Test
@Test // DATACASS-182
public void insertAndUpdateToEmptyCollection() {
BookReference bookReference = new BookReference();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.anyInt;
import java.util.Collections;
import java.util.List;
import com.datastax.driver.core.querybuilder.Batch;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -37,6 +36,7 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.cassandra.support.exception.CassandraConnectionFailureException;
import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.domain.Person;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.DataType;
@@ -45,7 +45,7 @@ import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.Statement;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.springframework.data.cassandra.test.integration.simpletons.Book;
import com.datastax.driver.core.querybuilder.Batch;
/**
* Unit tests for {@link CassandraTemplate}.
@@ -73,10 +73,7 @@ public class CassandraTemplateUnitTests {
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectUsingCqlShouldReturnMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -98,10 +95,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectShouldTranslateException() throws Exception {
when(resultSet.iterator()).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -115,10 +109,7 @@ public class CassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectOneShouldReturnMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -140,10 +131,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void selectOneByIdShouldReturnMappedResults() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -165,10 +153,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void existsShouldReturnExistingElement() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -182,10 +167,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void existsShouldReturnNonExistingElement() {
when(resultSet.iterator()).thenReturn(Collections.emptyIterator());
@@ -197,10 +179,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void countShouldExecuteCountQueryElement() {
when(resultSet.iterator()).thenReturn(Collections.singleton(row).iterator());
@@ -214,10 +193,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM person;");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldInsertEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -232,10 +208,7 @@ public class CassandraTemplateUnitTests {
.isEqualTo("INSERT INTO person (firstname,id,lastname) VALUES ('Walter','heisenberg','White');");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldTranslateException() throws Exception {
reset(session);
@@ -250,10 +223,7 @@ public class CassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void insertShouldNotApplyInsert() {
when(resultSet.wasApplied()).thenReturn(false);
@@ -265,10 +235,7 @@ public class CassandraTemplateUnitTests {
assertThat(inserted).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldUpdateEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -283,10 +250,7 @@ public class CassandraTemplateUnitTests {
.isEqualTo("UPDATE person SET firstname='Walter',lastname='White' WHERE id='heisenberg';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldTranslateException() throws Exception {
reset(session);
@@ -301,10 +265,7 @@ public class CassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void updateShouldNotApplyUpdate() {
when(resultSet.wasApplied()).thenReturn(false);
@@ -316,10 +277,7 @@ public class CassandraTemplateUnitTests {
assertThat(updated).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteByIdShouldRemoveEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -333,10 +291,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldRemoveEntity() {
when(resultSet.wasApplied()).thenReturn(true);
@@ -350,10 +305,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldTranslateException() throws Exception {
reset(session);
@@ -368,10 +320,7 @@ public class CassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void deleteShouldNotApplyRemoval() {
when(resultSet.wasApplied()).thenReturn(false);
@@ -383,10 +332,7 @@ public class CassandraTemplateUnitTests {
assertThat(deleted).isNull();
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
public void truncateShouldRemoveEntities() {
template.truncate(Person.class);
@@ -395,10 +341,7 @@ public class CassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE person;");
}
/**
* @see DATACASS-292
*/
@Test
@Test // DATACASS-292
@Ignore
public void batchOperationsShouldCallSession() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@ package org.springframework.data.cassandra.core;
import static org.assertj.core.api.Assertions.*;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cassandra.core.DefaultBridgedReactiveSession;
@@ -26,9 +29,6 @@ import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.domain.Person;
import org.springframework.data.cassandra.test.integration.support.SchemaTestUtils;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
/**
* Integration tests for {@link ReactiveCassandraTemplate}.
*
@@ -51,10 +51,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
SchemaTestUtils.truncate(Person.class, cassandraTemplate);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void insertShouldInsertEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -69,10 +66,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
assertThat(oneById.block()).isNotNull().isEqualTo(saved);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void shouldInsertAndCountEntities() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -83,10 +77,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
assertThat(count.block()).isEqualTo(1L);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void updateShouldUpdateEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -100,10 +91,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
assertThat(oneById.block()).isEqualTo(person);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void deleteShouldRemoveEntity() {
Person person = new Person("heisenberg", "Walter", "White");
@@ -116,10 +104,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
assertThat(oneById.block()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void deleteByIdShouldRemoveEntity() {
Person person = new Person("heisenberg", "Walter", "White");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,9 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.anyInt;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Collections;
import org.junit.Before;
@@ -33,7 +36,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.cassandra.core.ReactiveResultSet;
import org.springframework.cassandra.core.ReactiveSession;
import org.springframework.cassandra.support.exception.CassandraConnectionFailureException;
import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.domain.Person;
import com.datastax.driver.core.ColumnDefinitions;
@@ -42,9 +44,6 @@ import com.datastax.driver.core.Row;
import com.datastax.driver.core.Statement;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* Unit tests for {@link ReactiveCassandraTemplate}.
*
@@ -71,10 +70,7 @@ public class ReactiveCassandraTemplateUnitTests {
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void selectUsingCqlShouldReturnMappedResults() {
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -96,10 +92,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void selectShouldTranslateException() {
when(reactiveResultSet.rows()).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
@@ -115,10 +108,7 @@ public class ReactiveCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void selectOneByIdShouldReturnMappedResults() {
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -140,10 +130,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void existsShouldReturnExistingElement() {
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -157,10 +144,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void existsShouldReturnNonExistingElement() {
when(reactiveResultSet.rows()).thenReturn(Flux.empty());
@@ -172,10 +156,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM person WHERE id='myid';");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void countShouldExecuteCountQueryElement() {
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
@@ -189,10 +170,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM person;");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void insertShouldInsertEntity() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -206,10 +184,7 @@ public class ReactiveCassandraTemplateUnitTests {
.isEqualTo("INSERT INTO person (firstname,id,lastname) VALUES ('Walter','heisenberg','White');");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void insertShouldTranslateException() {
reset(session);
@@ -227,10 +202,7 @@ public class ReactiveCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void insertShouldNotApplyInsert() {
when(reactiveResultSet.wasApplied()).thenReturn(false);
@@ -241,10 +213,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(mono.block()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void updateShouldUpdateEntity() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -258,10 +227,7 @@ public class ReactiveCassandraTemplateUnitTests {
.isEqualTo("UPDATE person SET firstname='Walter',lastname='White' WHERE id='heisenberg';");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void updateShouldTranslateException() {
reset(session);
@@ -279,10 +245,7 @@ public class ReactiveCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void updateShouldNotApplyUpdate() {
when(reactiveResultSet.wasApplied()).thenReturn(false);
@@ -293,10 +256,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(mono.block()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void deleteShouldRemoveEntity() {
when(reactiveResultSet.wasApplied()).thenReturn(true);
@@ -310,10 +270,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM person WHERE id='heisenberg';");
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void deleteShouldTranslateException() {
reset(session);
@@ -331,10 +288,7 @@ public class ReactiveCassandraTemplateUnitTests {
}
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void deleteShouldNotApplyRemoval() {
when(reactiveResultSet.wasApplied()).thenReturn(false);
@@ -345,10 +299,7 @@ public class ReactiveCassandraTemplateUnitTests {
assertThat(mono.block()).isNull();
}
/**
* @see DATACASS-335
*/
@Test
@Test // DATACASS-335
public void truncateShouldRemoveEntities() {
template.truncate(Person.class).block();

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