From 8597589ce3e1ae2e3a118c721aaaa1377c3e3f24 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 24 Mar 2017 09:13:19 +0100 Subject: [PATCH] DATACASS-389 - Reformat and reorganize imports. --- .../CassandraCqlTemplateFactoryBean.java | 4 +- .../config/ClusterBuilderConfigurer.java | 3 +- .../cassandra/config/KeyspaceAttributes.java | 3 +- .../cassandra/config/xml/ParsingUtils.java | 17 +- .../cassandra/core/AsyncCqlOperations.java | 144 ++++--- .../cassandra/core/AsyncCqlTemplate.java | 87 ++-- .../core/AsyncPreparedStatementCreator.java | 4 +- .../cassandra/core/AsyncSessionCallback.java | 10 +- .../core/CachedPreparedStatementCreator.java | 3 +- .../cassandra/core/ConsistencyLevel.java | 9 +- .../cassandra/core/CqlOperations.java | 95 +++-- .../cassandra/core/CqlTemplate.java | 15 +- ...ionTranslatingListenableFutureAdapter.java | 4 +- .../core/GuavaListenableFutureAdapter.java | 10 +- .../cassandra/core/QueryOptions.java | 12 +- .../cassandra/core/QueryOptionsUtil.java | 4 +- .../cassandra/core/ReactiveCqlOperations.java | 6 +- .../cassandra/core/ReactiveCqlTemplate.java | 22 +- .../cassandra/core/RowCallbackHandler.java | 4 +- .../core/RowMapperResultSetExtractor.java | 6 +- .../converter/AbstractResultSetConverter.java | 4 +- .../core/converter/RowToListConverter.java | 1 - .../cassandra/core/cql/CqlConstantType.java | 9 +- .../cassandra/core/cql/CqlStringUtils.java | 8 +- .../cql/generator/DropColumnCqlGenerator.java | 2 +- .../cql/generator/DropIndexCqlGenerator.java | 2 +- .../cql/generator/DropTableCqlGenerator.java | 2 +- .../generator/DropUserTypeCqlGenerator.java | 4 +- .../cql/generator/KeyspaceCqlGenerator.java | 4 +- .../KeyspaceOptionsCqlGenerator.java | 16 +- .../generator/RenameColumnCqlGenerator.java | 2 +- .../core/cql/generator/TableCqlGenerator.java | 12 +- .../generator/TableOptionsCqlGenerator.java | 16 +- .../keyspace/CreateKeyspaceSpecification.java | 6 +- .../keyspace/DropUserTypeSpecification.java | 2 +- .../core/keyspace/FieldSpecification.java | 4 +- .../KeyspaceOptionsSpecification.java | 4 +- .../core/keyspace/KeyspaceSpecification.java | 12 +- .../cassandra/core/keyspace/TableOption.java | 7 +- .../keyspace/TableOptionsSpecification.java | 4 +- .../core/keyspace/UserTypeSpecification.java | 2 +- .../DefaultBridgedReactiveSession.java | 22 +- .../lookup/AbstractRoutingSessionFactory.java | 7 +- .../support/CassandraExceptionTranslator.java | 12 +- ...CassandraSchemaElementExistsException.java | 3 +- ...ssandraCqlClusterFactoryBeanUnitTests.java | 16 +- ...ssandraCqlSessionFactoryBeanUnitTests.java | 3 +- .../PoolingOptionsFactoryBeanUnitTests.java | 11 +- ...AbstractClusterConfigurationUnitTests.java | 13 +- .../CassandraCqlClusterParserUnitTests.java | 2 +- .../AsyncCqlTemplateIntegrationTests.java | 11 +- ...chedPreparedStatementCreatorUnitTests.java | 4 +- .../cassandra/core/CqlTemplateUnitTests.java | 3 +- ...ridgedReactiveSessionIntegrationTests.java | 4 +- ...efaultBridgedReactiveSessionUnitTests.java | 8 +- .../AlterKeyspaceCqlGeneratorUnitTests.java | 4 +- .../CreateTableCqlGeneratorUnitTests.java | 2 +- .../MapSessionFactoryLookupUnitTests.java | 3 +- ...CassandraExceptionTranslatorUnitTests.java | 47 +- ...tractEmbeddedCassandraIntegrationTest.java | 9 +- .../config/BeanDefinitionBuilderArgument.java | 6 +- .../cassandra/config/BeanDefinitionUtils.java | 3 +- .../config/CassandraEntityClassScanner.java | 7 +- .../convert/CassandraConverters.java | 3 +- .../core/AsyncCassandraTemplate.java | 28 +- .../core/CassandraAdminTemplate.java | 9 +- .../cassandra/core/CassandraTemplate.java | 1 - .../data/cassandra/core/QueryUtils.java | 3 +- .../core/ReactiveCassandraOperations.java | 10 +- .../core/ReactiveCassandraTemplate.java | 33 +- .../BasicCassandraPersistentProperty.java | 3 +- .../mapping/CassandraMappingContext.java | 18 +- .../data/cassandra/mapping/EntityMapping.java | 3 +- .../ReactiveCassandraRepository.java | 6 +- .../query/CassandraEntityInformation.java | 12 +- .../repository/query/CassandraParameters.java | 8 +- .../CassandraParametersParameterAccessor.java | 4 +- .../ReactiveCassandraParameterAccessor.java | 8 +- .../repository/query/StringBasedQuery.java | 4 +- .../support/CassandraRepositoryFactory.java | 5 +- .../support/IdInterfaceValidator.java | 4 +- .../support/SimpleCassandraRepository.java | 3 +- .../config/SchemaActionIntegrationTests.java | 6 +- ...ersistentEntitySchemaCreatorUnitTests.java | 2 +- ...sicCassandraPersistentEntityUnitTests.java | 2 +- .../ForceQuotedPropertiesSimpleUnitTests.java | 6 +- ...aParametersParameterAccessorUnitTests.java | 6 +- .../declared/QueryIntegrationTests.java | 2 +- .../java/reactor/test/TestSubscriber.java | 402 ++++++++---------- 89 files changed, 605 insertions(+), 771 deletions(-) diff --git a/spring-cql/src/main/java/org/springframework/cassandra/config/CassandraCqlTemplateFactoryBean.java b/spring-cql/src/main/java/org/springframework/cassandra/config/CassandraCqlTemplateFactoryBean.java index 787339149..775f90956 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/config/CassandraCqlTemplateFactoryBean.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/config/CassandraCqlTemplateFactoryBean.java @@ -70,8 +70,8 @@ public class CassandraCqlTemplateFactoryBean implements FactoryBean /** * Sets the Cassandra {@link Session} to use. The {@link CqlTemplate} will use the logged keyspace of the underlying - * {@link Session}. Don't change the keyspace using CQL but use multiple {@link Session} and - * {@link CqlTemplate} beans. + * {@link Session}. Don't change the keyspace using CQL but use multiple {@link Session} and {@link CqlTemplate} + * beans. * * @param session must not be {@literal null}. */ diff --git a/spring-cql/src/main/java/org/springframework/cassandra/config/ClusterBuilderConfigurer.java b/spring-cql/src/main/java/org/springframework/cassandra/config/ClusterBuilderConfigurer.java index e6d1e94a3..743a4cd2c 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/config/ClusterBuilderConfigurer.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/config/ClusterBuilderConfigurer.java @@ -19,8 +19,7 @@ package org.springframework.cassandra.config; import com.datastax.driver.core.Cluster; /** - * Configuration callback class to allow a user to apply additional configuration logic - * to the {@link Cluster.Builder}. + * Configuration callback class to allow a user to apply additional configuration logic to the {@link Cluster.Builder}. * * @author John Blum * @see com.datastax.driver.core.Cluster diff --git a/spring-cql/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java b/spring-cql/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java index a828bdd37..001031eaa 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/config/KeyspaceAttributes.java @@ -50,8 +50,7 @@ public class KeyspaceAttributes { * replication strategy class "SimpleStrategy" and with a replication factor equal to that given. */ public static Map newSimpleReplication(long replicationFactor) { - return MapBuilder - .map(Option.class, Object.class) + return MapBuilder.map(Option.class, Object.class) .entry(new DefaultOption("class", String.class, true, false, true), ReplicationStrategy.SIMPLE_STRATEGY.getValue()) .entry(new DefaultOption("replication_factor", Long.class, true, false, false), replicationFactor).build(); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java b/spring-cql/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java index a340e94aa..1c73c49fb 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/config/xml/ParsingUtils.java @@ -167,7 +167,7 @@ public abstract class ParsingUtils { * {@link #addProperty(BeanDefinitionBuilder, String, String, String, boolean, boolean)}. */ public static void addRequiredPropertyReference(BeanDefinitionBuilder builder, String propertyName, Element element, - String attributeName) { + String attributeName) { addProperty(builder, propertyName, element.getAttribute(attributeName), null, true, true); } @@ -232,8 +232,8 @@ public abstract class ParsingUtils { * @see BeanDefinitionBuilder#addPropertyReference(String, String) * @see BeanDefinitionBuilder#addPropertyValue(String, Object) */ - public static BeanDefinitionBuilder addProperty(BeanDefinitionBuilder builder, String propertyName, - String value, String defaultValue, boolean required, boolean reference) { + public static BeanDefinitionBuilder addProperty(BeanDefinitionBuilder builder, String propertyName, String value, + String defaultValue, boolean required, boolean reference) { Assert.notNull(builder, "BeanDefinitionBuilder must not be null"); Assert.hasText(propertyName, "Property name must not be null"); @@ -241,9 +241,8 @@ public abstract class ParsingUtils { if (!StringUtils.hasText(value)) { if (required) { throw new IllegalArgumentException(String.format("value required for property %1$s[%2$s] on class [%3$s]", - reference ? "reference " : "", propertyName, builder.getRawBeanDefinition().getBeanClassName())); - } - else { + reference ? "reference " : "", propertyName, builder.getRawBeanDefinition().getBeanClassName())); + } else { value = defaultValue; } } @@ -260,13 +259,13 @@ public abstract class ParsingUtils { } /** - * Returns a {@link BeanDefinition} built from the given {@link BeanDefinitionBuilder} enriched with - * source meta-data derived from the given {@link Element}. + * Returns a {@link BeanDefinition} built from the given {@link BeanDefinitionBuilder} enriched with source meta-data + * derived from the given {@link Element}. * * @param builder {@link BeanDefinitionBuilder} used to build the {@link BeanDefinition}. * @param parserContext {@link ParserContext} used to track state during the parsing operation. * @param element DOM {@link Element} defining the meta-data that is the source of the {@link BeanDefinition}s - * configuration. + * configuration. * @return the {@link BeanDefinition} built by the given {@link BeanDefinitionBuilder}. * @throws IllegalArgumentException if the {@link BeanDefinitionBuilder} or {@link ParserContext} are null. */ diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlOperations.java b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlOperations.java index c9283f081..073cf9265 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlOperations.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlOperations.java @@ -15,24 +15,24 @@ */ package org.springframework.cassandra.core; +import reactor.core.publisher.Mono; + import java.util.List; import java.util.Map; -import com.datastax.driver.core.PreparedStatement; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Statement; - import org.springframework.dao.DataAccessException; import org.springframework.dao.IncorrectResultSizeDataAccessException; import org.springframework.util.concurrent.ListenableFuture; -import reactor.core.publisher.Mono; +import com.datastax.driver.core.PreparedStatement; +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.Statement; /** - * Interface specifying a basic set of CQL asynchronously executed operations. Exposes similar methods - * as {@link CqlTemplate}, but returns result handles or accepts callbacks as opposed to concrete results. - * Implemented by {@link AsyncCqlTemplate}. Not often used directly, but a useful option to enhance testability, - * as it can easily be mocked or stubbed. + * Interface specifying a basic set of CQL asynchronously executed operations. Exposes similar methods as + * {@link CqlTemplate}, but returns result handles or accepts callbacks as opposed to concrete results. Implemented by + * {@link AsyncCqlTemplate}. Not often used directly, but a useful option to enhance testability, as it can easily be + * mocked or stubbed. * * @author Mark Paluch * @author John Blum @@ -42,7 +42,8 @@ import reactor.core.publisher.Mono; */ public interface AsyncCqlOperations { - // TODO many of these data access operations could be implemented as default methods, in terms of other data access operations + // TODO many of these data access operations could be implemented as default methods, in terms of other data access + // operations // ------------------------------------------------------------------------- // Methods dealing with a plain com.datastax.driver.core.Session @@ -93,13 +94,14 @@ public interface AsyncCqlOperations { * {@link PreparedStatementBinder} just needs to set parameters. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @return boolean value whether the statement was applied. * @throws DataAccessException if there is any problem issuing the execution. */ - ListenableFuture execute(String cql, PreparedStatementBinder preparedStatementBinder) throws DataAccessException; + ListenableFuture execute(String cql, PreparedStatementBinder preparedStatementBinder) + throws DataAccessException; /** * Execute a CQL data access operation, implemented as callback action working on a CQL {@link PreparedStatement}. @@ -170,7 +172,8 @@ public interface AsyncCqlOperations { * @return an arbitrary result object, as returned by the {@link ResultSetExtractor} * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture query(String cql, ResultSetExtractor resultSetExtractor, Object... args) throws DataAccessException; + ListenableFuture query(String cql, ResultSetExtractor resultSetExtractor, Object... args) + throws DataAccessException; /** * Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, reading the @@ -182,7 +185,8 @@ public interface AsyncCqlOperations { * CQL type) * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture query(String cql, RowCallbackHandler rowCallbackHandler, Object... args) throws DataAccessException; + ListenableFuture query(String cql, RowCallbackHandler rowCallbackHandler, Object... args) + throws DataAccessException; /** * Query given CQL to create a prepared statement from CQL and a list of arguments to bind to the query, mapping each @@ -201,15 +205,15 @@ public interface AsyncCqlOperations { * Query using a prepared statement, reading the {@link ResultSet} with a {@link ResultSetExtractor}. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param resultSetExtractor object that will extract results, must not be {@literal null}. * @return an arbitrary result object, as returned by the {@link ResultSetExtractor}. * @throws DataAccessException if there is any problem */ - ListenableFuture query(String cql, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor resultSetExtractor) - throws DataAccessException; + ListenableFuture query(String cql, PreparedStatementBinder preparedStatementBinder, + ResultSetExtractor resultSetExtractor) throws DataAccessException; /** * Query given CQL to create a prepared statement from CQL and a {@link PreparedStatementBinder} implementation that @@ -217,29 +221,29 @@ public interface AsyncCqlOperations { * {@link RowCallbackHandler}. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowCallbackHandler object that will extract results, one row at a time, must not be {@literal null}. * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture query(String cql, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler) - throws DataAccessException; + ListenableFuture query(String cql, PreparedStatementBinder preparedStatementBinder, + RowCallbackHandler rowCallbackHandler) throws DataAccessException; /** * Query given CQL to create a prepared statement from CQL and a {@link PreparedStatementBinder} implementation that * knows how to bind values to the query, mapping each row to a Java object via a {@link RowMapper}. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowMapper object that will map one object per row, must not be {@literal null}. * @return the result {@link List}, containing mapped objects. * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture> query(String cql, PreparedStatementBinder preparedStatementBinder, RowMapper rowMapper) - throws DataAccessException; + ListenableFuture> query(String cql, PreparedStatementBinder preparedStatementBinder, + RowMapper rowMapper) throws DataAccessException; /** * Execute a query for a result {@link List}, given static CQL. @@ -311,7 +315,8 @@ public interface AsyncCqlOperations { * @see #queryForList(String, Class) * @see SingleColumnRowMapper */ - ListenableFuture> queryForList(String cql, Class elementType, Object... args) throws DataAccessException; + ListenableFuture> queryForList(String cql, Class elementType, Object... args) + throws DataAccessException; /** * Execute a query for a result Map, given static CQL. @@ -476,7 +481,8 @@ public interface AsyncCqlOperations { * @throws DataAccessException if there is any problem executing the query. * @see #query(String, ResultSetExtractor, Object...) */ - ListenableFuture query(Statement statement, ResultSetExtractor resultSetExtractor) throws DataAccessException; + ListenableFuture query(Statement statement, ResultSetExtractor resultSetExtractor) + throws DataAccessException; /** * Execute a query given static CQL, reading the {@link ResultSet} on a per-row basis with a @@ -636,44 +642,44 @@ public interface AsyncCqlOperations { *

* The callback action can return a result object, for example a domain object or a collection of domain objects. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param action callback object that specifies the action, must not be {@literal null}. * @return a result object returned by the action, or {@literal null}. * @throws DataAccessException if there is any problem */ - ListenableFuture execute(AsyncPreparedStatementCreator preparedStatementCreator, PreparedStatementCallback action) - throws DataAccessException; + ListenableFuture execute(AsyncPreparedStatementCreator preparedStatementCreator, + PreparedStatementCallback action) throws DataAccessException; /** * Query using a prepared statement, reading the {@link ResultSet} with a {@link ResultSetExtractor}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param resultSetExtractor object that will extract results, must not be {@literal null}. * @return an arbitrary result object, as returned by the {@link ResultSetExtractor} * @throws DataAccessException if there is any problem */ - ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, ResultSetExtractor resultSetExtractor) - throws DataAccessException; + ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, + ResultSetExtractor resultSetExtractor) throws DataAccessException; /** * Query using a prepared statement, reading the {@link ResultSet} on a per-row basis with a * {@link RowCallbackHandler}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param rowCallbackHandler object that will extract results, one row at a time, must not be {@literal null}. * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, RowCallbackHandler rowCallbackHandler) - throws DataAccessException; + ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, + RowCallbackHandler rowCallbackHandler) throws DataAccessException; /** * Query using a prepared statement, mapping each row to a Java object via a {@link RowMapper}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param rowMapper object that will map one object per row, must not be {@literal null}. * @return the result {@link List}, containing mapped objects. * @throws DataAccessException if there is any problem executing the query. @@ -685,47 +691,49 @@ public interface AsyncCqlOperations { * Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values * to the query, reading the {@link ResultSet} with a {@link ResultSetExtractor}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param resultSetExtractor object that will extract results, must not be {@literal null}. * @return an arbitrary result object, as returned by the {@link ResultSetExtractor}. * @throws DataAccessException if there is any problem */ - ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, - ResultSetExtractor resultSetExtractor) throws DataAccessException; + ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, + PreparedStatementBinder preparedStatementBinder, ResultSetExtractor resultSetExtractor) + throws DataAccessException; /** * Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values * to the query, reading the {@link ResultSet} on a per-row basis with a {@link RowCallbackHandler}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowCallbackHandler object that will extract results, one row at a time, must not be {@literal null}. * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, - RowCallbackHandler rowCallbackHandler) throws DataAccessException; + ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, + PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler) + throws DataAccessException; /** * Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values * to the query, mapping each row to a Java object via a {@link RowMapper}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowMapper object that will map one object per row, must not be {@literal null}. * @return the result {@link List}, containing mapped objects. * @throws DataAccessException if there is any problem executing the query. */ - ListenableFuture> query(AsyncPreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, - RowMapper rowMapper) throws DataAccessException; + ListenableFuture> query(AsyncPreparedStatementCreator preparedStatementCreator, + PreparedStatementBinder preparedStatementBinder, RowMapper rowMapper) throws DataAccessException; } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java index 68d6cf3bd..c2d9884e3 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncCqlTemplate.java @@ -80,8 +80,8 @@ import com.google.common.util.concurrent.Futures; public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOperations { /** - * Create a new, uninitialized {@link AsyncCqlTemplate}. Note: The {@link SessionFactory} has to be set before - * using the instance. + * Create a new, uninitialized {@link AsyncCqlTemplate}. Note: The {@link SessionFactory} has to be set before using + * the instance. * * @see #setSessionFactory(SessionFactory) */ @@ -172,8 +172,7 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ResultSetFuture results = getCurrentSession().executeAsync(simpleStatement); return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>( - new GuavaListenableFutureAdapter<>(results, - ex -> translateExceptionIfPossible("Query", cql, ex)), + new GuavaListenableFutureAdapter<>(results, ex -> translateExceptionIfPossible("Query", cql, ex)), resultSetExtractor::extractData), getExceptionTranslator()); } catch (DriverException e) { throw translateException("Query", cql, e); @@ -189,8 +188,8 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture results = query(cql, newResultSetExtractor(rowCallbackHandler)); - return new ExceptionTranslatingListenableFutureAdapter<>( - new MappingListenableFutureAdapter<>(results, o -> null), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>(results, o -> null), + getExceptionTranslator()); } /* @@ -248,8 +247,7 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture> results = query(cql, newResultSetExtractor(rowMapper)); return new ExceptionTranslatingListenableFutureAdapter<>( - new MappingListenableFutureAdapter<>(results, DataAccessUtils::requiredSingleResult), - getExceptionTranslator()); + new MappingListenableFutureAdapter<>(results, DataAccessUtils::requiredSingleResult), getExceptionTranslator()); } /* @@ -316,8 +314,8 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture result = query(statement, newResultSetExtractor(rowCallbackHandler)); - return new ExceptionTranslatingListenableFutureAdapter<>( - new MappingListenableFutureAdapter<>(result, o -> null), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>(result, o -> null), + getExceptionTranslator()); } /* @@ -377,8 +375,7 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture> results = query(statement, newResultSetExtractor(rowMapper)); return new ExceptionTranslatingListenableFutureAdapter<>( - new MappingListenableFutureAdapter<>(results, DataAccessUtils::requiredSingleResult), - getExceptionTranslator()); + new MappingListenableFutureAdapter<>(results, DataAccessUtils::requiredSingleResult), getExceptionTranslator()); } /* @@ -450,15 +447,15 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera logger.debug("Preparing statement [{}] using {}", toCql(preparedStatementCreator), preparedStatementCreator); } - Session currentSession = getCurrentSession();return new ExceptionTranslatingListenableFutureAdapter<>( - new MappingListenableFutureAdapter<>(preparedStatementCreator.createPreparedStatement(currentSession), - preparedStatement -> { - try { - return action.doInPreparedStatement(currentSession,applyStatementSettings(preparedStatement)); - } catch (DriverException e) { - throw translateException("PreparedStatementCallback", preparedStatement.toString(), e); - } - }), getExceptionTranslator()); + Session currentSession = getCurrentSession(); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>( + preparedStatementCreator.createPreparedStatement(currentSession), preparedStatement -> { + try { + return action.doInPreparedStatement(currentSession, applyStatementSettings(preparedStatement)); + } catch (DriverException e) { + throw translateException("PreparedStatementCallback", preparedStatement.toString(), e); + } + }), getExceptionTranslator()); } catch (DriverException e) { throw translateException("PreparedStatementCallback", toCql(preparedStatementCreator), e); @@ -484,11 +481,10 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera public ListenableFuture query(AsyncPreparedStatementCreator preparedStatementCreator, RowCallbackHandler rowCallbackHandler) throws DataAccessException { - ListenableFuture results = query(preparedStatementCreator, null, - newResultSetExtractor(rowCallbackHandler)); + ListenableFuture results = query(preparedStatementCreator, null, newResultSetExtractor(rowCallbackHandler)); - return new ExceptionTranslatingListenableFutureAdapter<>( - new MappingListenableFutureAdapter<>(results, o -> null), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>(results, o -> null), + getExceptionTranslator()); } /* @@ -516,14 +512,13 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera try { if (logger.isDebugEnabled()) { - logger.debug("Preparing statement [{}] using {}", toCql(preparedStatementCreator), - preparedStatementCreator); + logger.debug("Preparing statement [{}] using {}", toCql(preparedStatementCreator), preparedStatementCreator); } Session session = getCurrentSession(); - PersistenceExceptionTranslator exceptionTranslator = ex -> - translateExceptionIfPossible("Query", toCql(preparedStatementCreator), ex); + PersistenceExceptionTranslator exceptionTranslator = ex -> translateExceptionIfPossible("Query", + toCql(preparedStatementCreator), ex); ListenableFuture statementFuture = new MappingListenableFutureAdapter<>( preparedStatementCreator.createPreparedStatement(session), preparedStatement -> { @@ -537,31 +532,30 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera SettableListenableFuture settableListenableFuture = new SettableListenableFuture<>(); - statementFuture.addCallback(boundStatement -> - Futures.addCallback(session.executeAsync(boundStatement), new FutureCallback() { + statementFuture.addCallback( + boundStatement -> Futures.addCallback(session.executeAsync(boundStatement), new FutureCallback() { @Override public void onSuccess(ResultSet result) { try { settableListenableFuture.set(resultSetExtractor.extractData(result)); } catch (DriverException e) { - settableListenableFuture.setException( - exceptionTranslator.translateExceptionIfPossible(e)); + settableListenableFuture.setException(exceptionTranslator.translateExceptionIfPossible(e)); } } @Override public void onFailure(Throwable ex) { if (ex instanceof DriverException) { - settableListenableFuture.setException( - exceptionTranslator.translateExceptionIfPossible((DriverException) ex)); + settableListenableFuture + .setException(exceptionTranslator.translateExceptionIfPossible((DriverException) ex)); } else { settableListenableFuture.setException(ex); } } }), ex -> { if (ex instanceof DriverException) { - settableListenableFuture.setException( - exceptionTranslator.translateExceptionIfPossible((DriverException) ex)); + settableListenableFuture + .setException(exceptionTranslator.translateExceptionIfPossible((DriverException) ex)); } else { settableListenableFuture.setException(ex); } @@ -586,8 +580,8 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture results = query(preparedStatementCreator, preparedStatementBinder, newResultSetExtractor(rowCallbackHandler)); - return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>( - results, o -> null), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>(results, o -> null), + getExceptionTranslator()); } /* @@ -623,8 +617,8 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture results = query(newAsyncPreparedStatementCreator(cql), newPreparedStatementBinder(args), newResultSetExtractor(rowCallbackHandler)); - return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>( - results, o -> null), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>(results, o -> null), + getExceptionTranslator()); } /* @@ -661,8 +655,8 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture results = query(newAsyncPreparedStatementCreator(cql), preparedStatementBinder, newResultSetExtractor(rowCallbackHandler)); - return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>( - results, o -> null), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>(results, o -> null), + getExceptionTranslator()); } /* @@ -731,8 +725,8 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera ListenableFuture> results = query(newAsyncPreparedStatementCreator(cql), newPreparedStatementBinder(args), newResultSetExtractor(rowMapper, 1)); - return new ExceptionTranslatingListenableFutureAdapter<>(new MappingListenableFutureAdapter<>( - results, DataAccessUtils::requiredSingleResult), getExceptionTranslator()); + return new ExceptionTranslatingListenableFutureAdapter<>( + new MappingListenableFutureAdapter<>(results, DataAccessUtils::requiredSingleResult), getExceptionTranslator()); } /* @@ -815,8 +809,7 @@ public class AsyncCqlTemplate extends CassandraAccessor implements AsyncCqlOpera @Override public ListenableFuture createPreparedStatement(Session session) throws DriverException { - return new GuavaListenableFutureAdapter<>(session.prepareAsync(getCql()), - this.persistenceExceptionTranslator); + return new GuavaListenableFutureAdapter<>(session.prepareAsync(getCql()), this.persistenceExceptionTranslator); } } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncPreparedStatementCreator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncPreparedStatementCreator.java index ac4f9157e..e8f655020 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncPreparedStatementCreator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncPreparedStatementCreator.java @@ -15,12 +15,12 @@ */ package org.springframework.cassandra.core; +import org.springframework.util.concurrent.ListenableFuture; + import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.Session; import com.datastax.driver.core.exceptions.DriverException; -import org.springframework.util.concurrent.ListenableFuture; - /** * One of the two central callback interfaces used by the {@link AsyncCqlTemplate} class. This interface prepares a CQL * statement returning a {@link org.springframework.util.concurrent.ListenableFuture} given a {@link Session}, provided diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncSessionCallback.java b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncSessionCallback.java index 09a99504b..f05d72f26 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncSessionCallback.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/AsyncSessionCallback.java @@ -15,15 +15,15 @@ */ package org.springframework.cassandra.core; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.exceptions.DriverException; - import org.springframework.dao.DataAccessException; import org.springframework.util.concurrent.ListenableFuture; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.exceptions.DriverException; + /** - * Generic callback interface for code that operates asynchronously on a Cassandra {@link Session}. Allows to execute any number of - * operations on a single session, using any type and number of statements. + * Generic callback interface for code that operates asynchronously on a Cassandra {@link Session}. Allows to execute + * any number of operations on a single session, using any type and number of statements. *

* This is particularly useful for delegating to existing data access code that expects a {@link Session} to work on and * throws {@link DriverException}. For newly written code, it is strongly recommended to use {@link CqlTemplate}'s more diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/CachedPreparedStatementCreator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/CachedPreparedStatementCreator.java index a874ef62e..48aa310c6 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/CachedPreparedStatementCreator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/CachedPreparedStatementCreator.java @@ -115,8 +115,7 @@ public class CachedPreparedStatementCreator implements PreparedStatementCreator if (sessionCache.containsKey(cacheKey)) { log.debug("Found cached PreparedStatement"); preparedStatement = sessionCache.get(cacheKey); - } - else { + } else { log.debug("No cached PreparedStatement found... creating and caching"); preparedStatement = session.prepare(this.cql); sessionCache.put(cacheKey, preparedStatement); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ConsistencyLevel.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ConsistencyLevel.java index f98b062f3..3668bf418 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ConsistencyLevel.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ConsistencyLevel.java @@ -30,17 +30,20 @@ public enum ConsistencyLevel { /** * @deprecated as of 1.5, use {@link #QUORUM} */ - @Deprecated QUOROM, + @Deprecated + QUOROM, /** * @deprecated as of 1.5, use {@link #LOCAL_QUORUM} */ - @Deprecated LOCAL_QUOROM, + @Deprecated + LOCAL_QUOROM, /** * @deprecated as of 1.5, use {@link #EACH_QUORUM} */ - @Deprecated EACH_QUOROM, + @Deprecated + EACH_QUOROM, ALL, LOCAL_ONE, SERIAL, LOCAL_SERIAL, diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/CqlOperations.java b/spring-cql/src/main/java/org/springframework/cassandra/core/CqlOperations.java index d2dae55a7..2d9852e43 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/CqlOperations.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/CqlOperations.java @@ -15,20 +15,20 @@ */ package org.springframework.cassandra.core; +import reactor.core.publisher.Mono; + import java.util.Collection; import java.util.List; import java.util.Map; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.IncorrectResultSizeDataAccessException; + import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; import com.datastax.driver.core.Statement; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.IncorrectResultSizeDataAccessException; - -import reactor.core.publisher.Mono; - /** * Interface specifying a basic set of CQL operations. Implemented by {@link CqlTemplate}. Not often used directly, but * a useful option to enhance testability, as it can easily be mocked or stubbed. @@ -196,14 +196,15 @@ public interface CqlOperations { * Query using a prepared statement, reading the {@link ResultSet} with a {@link ResultSetExtractor}. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param resultSetExtractor object that will extract results, must not be {@literal null}. * @return an arbitrary result object, as returned by the {@link ResultSetExtractor}. * @throws DataAccessException if there is any problem */ - T query(String cql, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor resultSetExtractor) throws DataAccessException; + T query(String cql, PreparedStatementBinder preparedStatementBinder, ResultSetExtractor resultSetExtractor) + throws DataAccessException; /** * Query given CQL to create a prepared statement from CQL and a {@link PreparedStatementBinder} implementation that @@ -211,27 +212,29 @@ public interface CqlOperations { * {@link RowCallbackHandler}. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowCallbackHandler object that will extract results, one row at a time, must not be {@literal null}. * @throws DataAccessException if there is any problem executing the query. */ - void query(String cql, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler) throws DataAccessException; + void query(String cql, PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler) + throws DataAccessException; /** * Query given CQL to create a prepared statement from CQL and a {@link PreparedStatementBinder} implementation that * knows how to bind values to the query, mapping each row to a Java object via a {@link RowMapper}. * * @param cql static CQL to execute, must not be empty or {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowMapper object that will map one object per row, must not be {@literal null}. * @return the result {@link List}, containing mapped objects. * @throws DataAccessException if there is any problem executing the query. */ - List query(String cql, PreparedStatementBinder preparedStatementBinder, RowMapper rowMapper) throws DataAccessException; + List query(String cql, PreparedStatementBinder preparedStatementBinder, RowMapper rowMapper) + throws DataAccessException; /** * Execute a query for a result {@link List}, given static CQL. @@ -675,56 +678,60 @@ public interface CqlOperations { *

* The callback action can return a result object, for example a domain object or a collection of domain objects. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param action callback object that specifies the action, must not be {@literal null}. * @return a result object returned by the action, or {@literal null}. * @throws DataAccessException if there is any problem */ - T execute(PreparedStatementCreator preparedStatementCreator, PreparedStatementCallback action) throws DataAccessException; + T execute(PreparedStatementCreator preparedStatementCreator, PreparedStatementCallback action) + throws DataAccessException; /** * Query using a prepared statement, reading the {@link ResultSet} with a {@link ResultSetExtractor}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param resultSetExtractor object that will extract results, must not be {@literal null}. * @return an arbitrary result object, as returned by the {@link ResultSetExtractor} * @throws DataAccessException if there is any problem */ - T query(PreparedStatementCreator preparedStatementCreator, ResultSetExtractor resultSetExtractor) throws DataAccessException; + T query(PreparedStatementCreator preparedStatementCreator, ResultSetExtractor resultSetExtractor) + throws DataAccessException; /** * Query using a prepared statement, reading the {@link ResultSet} on a per-row basis with a * {@link RowCallbackHandler}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param rowCallbackHandler object that will extract results, one row at a time, must not be {@literal null}. * @throws DataAccessException if there is any problem executing the query. */ - void query(PreparedStatementCreator preparedStatementCreator, RowCallbackHandler rowCallbackHandler) throws DataAccessException; + void query(PreparedStatementCreator preparedStatementCreator, RowCallbackHandler rowCallbackHandler) + throws DataAccessException; /** * Query using a prepared statement, mapping each row to a Java object via a {@link RowMapper}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. * @param rowMapper object that will map one object per row, must not be {@literal null}. * @return the result {@link List}, containing mapped objects. * @throws DataAccessException if there is any problem executing the query. */ - List query(PreparedStatementCreator preparedStatementCreator, RowMapper rowMapper) throws DataAccessException; + List query(PreparedStatementCreator preparedStatementCreator, RowMapper rowMapper) + throws DataAccessException; /** * Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values * to the query, reading the {@link ResultSet} with a {@link ResultSetExtractor}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param resultSetExtractor object that will extract results, must not be {@literal null}. * @return an arbitrary result object, as returned by the {@link ResultSetExtractor}. * @throws DataAccessException if there is any problem @@ -736,11 +743,11 @@ public interface CqlOperations { * Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values * to the query, reading the {@link ResultSet} on a per-row basis with a {@link RowCallbackHandler}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowCallbackHandler object that will extract results, one row at a time, must not be {@literal null}. * @throws DataAccessException if there is any problem executing the query. */ @@ -751,11 +758,11 @@ public interface CqlOperations { * Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values * to the query, mapping each row to a Java object via a {@link RowMapper}. * - * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a {@link com.datastax.driver.core.Session}, - * must not be {@literal null}. - * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is {@literal null}, the CQL will - * be assumed to contain no bind parameters. Even if there are no bind parameters, this object may be used to - * set fetch size and other performance options. + * @param preparedStatementCreator object that can create a {@link PreparedStatement} given a + * {@link com.datastax.driver.core.Session}, must not be {@literal null}. + * @param preparedStatementBinder object that knows how to set values on the prepared statement. If this is + * {@literal null}, the CQL will be assumed to contain no bind parameters. Even if there are no bind + * parameters, this object may be used to set fetch size and other performance options. * @param rowMapper object that will map one object per row, must not be {@literal null}. * @return the result {@link List}, containing mapped objects. * @throws DataAccessException if there is any problem executing the query. diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java b/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java index f7225317a..280d24301 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/CqlTemplate.java @@ -80,8 +80,8 @@ import com.datastax.driver.core.exceptions.DriverException; public class CqlTemplate extends CassandraAccessor implements CqlOperations { /** - * Create a new, uninitialized {@link CqlTemplate}. Note: The {@link SessionFactory} has to be set before using - * the instance. + * Create a new, uninitialized {@link CqlTemplate}. Note: The {@link SessionFactory} has to be set before using the + * instance. * * @see #setSessionFactory(SessionFactory) */ @@ -486,8 +486,7 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations { try { if (logger.isDebugEnabled()) { - logger.debug("Preparing statement [{}] using {}", toCql(preparedStatementCreator), - preparedStatementCreator); + logger.debug("Preparing statement [{}] using {}", toCql(preparedStatementCreator), preparedStatementCreator); } Session session = getCurrentSession(); @@ -515,9 +514,8 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations { * @see org.springframework.cassandra.core.CqlOperationsNG#query(org.springframework.cassandra.core.PreparedStatementCreator, org.springframework.cassandra.core.PreparedStatementBinder, org.springframework.cassandra.core.RowCallbackHandler) */ @Override - public void query(PreparedStatementCreator preparedStatementCreator, - PreparedStatementBinder preparedStatementBinder, RowCallbackHandler rowCallbackHandler) - throws DataAccessException { + public void query(PreparedStatementCreator preparedStatementCreator, PreparedStatementBinder preparedStatementBinder, + RowCallbackHandler rowCallbackHandler) throws DataAccessException { query(preparedStatementCreator, preparedStatementBinder, newResultSetExtractor(rowCallbackHandler)); } @@ -538,8 +536,7 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations { * @see org.springframework.cassandra.core.CqlOperationsNG#query(java.lang.String, org.springframework.cassandra.core.ResultSetExtractor, java.lang.Object[]) */ @Override - public T query(String cql, ResultSetExtractor resultSetExtractor, Object... args) - throws DataAccessException { + public T query(String cql, ResultSetExtractor resultSetExtractor, Object... args) throws DataAccessException { return query(newPreparedStatementCreator(cql), newPreparedStatementBinder(args), resultSetExtractor); } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ExceptionTranslatingListenableFutureAdapter.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ExceptionTranslatingListenableFutureAdapter.java index 5f72f633a..8275454d2 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ExceptionTranslatingListenableFutureAdapter.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ExceptionTranslatingListenableFutureAdapter.java @@ -72,8 +72,8 @@ class ExceptionTranslatingListenableFutureAdapter implements ListenableFuture @Override public void onFailure(Throwable ex) { if (ex instanceof RuntimeException) { - DataAccessException dataAccessException = - exceptionTranslator.translateExceptionIfPossible((RuntimeException) ex); + DataAccessException dataAccessException = exceptionTranslator + .translateExceptionIfPossible((RuntimeException) ex); if (dataAccessException != null) { settableFuture.setException(dataAccessException); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/GuavaListenableFutureAdapter.java b/spring-cql/src/main/java/org/springframework/cassandra/core/GuavaListenableFutureAdapter.java index e9b43c56d..3a678a010 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/GuavaListenableFutureAdapter.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/GuavaListenableFutureAdapter.java @@ -19,9 +19,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; - import org.springframework.dao.DataAccessException; import org.springframework.dao.support.PersistenceExceptionTranslator; import org.springframework.util.Assert; @@ -31,6 +28,9 @@ import org.springframework.util.concurrent.ListenableFutureCallback; import org.springframework.util.concurrent.SettableListenableFuture; import org.springframework.util.concurrent.SuccessCallback; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; + /** * Adapter class to adapt Guava's {@link com.google.common.util.concurrent.ListenableFuture} into a Spring * {@link ListenableFuture}. @@ -75,8 +75,8 @@ public class GuavaListenableFutureAdapter implements ListenableFuture { @Override public void onFailure(Throwable t) { if (t instanceof RuntimeException) { - DataAccessException dataAccessException = - exceptionTranslator.translateExceptionIfPossible((RuntimeException) t); + DataAccessException dataAccessException = exceptionTranslator + .translateExceptionIfPossible((RuntimeException) t); if (dataAccessException != null) { settableFuture.setException(dataAccessException); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptions.java b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptions.java index a7148190b..822add4c6 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptions.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptions.java @@ -205,8 +205,8 @@ public class QueryOptions { * Sets the read timeout in milliseconds. Overrides the default per-host read timeout ( * {@link SocketOptions#getReadTimeoutMillis()}). * - * @param readTimeout the read timeout in milliseconds. Negative values are not allowed. If it is {@code 0}, the read timeout - * will be disabled for this statement. + * @param readTimeout the read timeout in milliseconds. Negative values are not allowed. If it is {@code 0}, the read + * timeout will be disabled for this statement. * @since 1.5 * @see SocketOptions#getReadTimeoutMillis() * @see com.datastax.driver.core.Cluster.Builder#withSocketOptions(SocketOptions) @@ -338,8 +338,8 @@ public class QueryOptions { /** * Sets the read timeout in milliseconds. Overrides the default per-host read timeout. * - * @param readTimeout the read timeout in milliseconds. Negative values are not allowed. If it is {@code 0}, the read - * timeout will be disabled for this statement. + * @param readTimeout the read timeout in milliseconds. Negative values are not allowed. If it is {@code 0}, the + * read timeout will be disabled for this statement. * @return {@code this} {@link QueryOptionsBuilder} * @see SocketOptions#getReadTimeoutMillis() * @see com.datastax.driver.core.Cluster.Builder#withSocketOptions(SocketOptions) @@ -356,8 +356,8 @@ public class QueryOptions { /** * Sets the read timeout. Overrides the default per-host read timeout. * - * @param readTimeout the read timeout value. Negative values are not allowed. If it is {@code 0}, the read timeout will be - * disabled for this statement. + * @param readTimeout the read timeout value. Negative values are not allowed. If it is {@code 0}, the read timeout + * will be disabled for this statement. * @param timeUnit the {@link TimeUnit} for the supplied timeout; must not be {@literal null}. * @return {@code this} {@link QueryOptionsBuilder} * @see SocketOptions#getReadTimeoutMillis() diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptionsUtil.java b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptionsUtil.java index bc7479c0a..ffe775465 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptionsUtil.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryOptionsUtil.java @@ -15,14 +15,14 @@ */ package org.springframework.cassandra.core; +import org.springframework.util.Assert; + import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.Statement; import com.datastax.driver.core.querybuilder.Insert; import com.datastax.driver.core.querybuilder.QueryBuilder; import com.datastax.driver.core.querybuilder.Update; -import org.springframework.util.Assert; - /** * Utility class to associate {@link QueryOptions} and {@link WriteOptions} with QueryBuilder {@link Statement}s. * diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java index 132dc664e..47a9f4300 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlOperations.java @@ -15,6 +15,9 @@ */ package org.springframework.cassandra.core; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.util.Map; import org.reactivestreams.Publisher; @@ -26,9 +29,6 @@ import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.Row; import com.datastax.driver.core.Statement; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Interface specifying a basic set of CQL operations executed in a reactive fashion. Implemented by * {@link ReactiveCqlTemplate}. Not often used directly, but a useful option to enhance testability, as it can easily be diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java index b807cafc9..24ce07d87 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/ReactiveCqlTemplate.java @@ -32,9 +32,6 @@ import org.springframework.dao.DataAccessException; import org.springframework.dao.support.DataAccessUtils; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - import com.datastax.driver.core.BoundStatement; import com.datastax.driver.core.ConsistencyLevel; import com.datastax.driver.core.PreparedStatement; @@ -260,8 +257,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re */ @Override public Mono queryForObject(String cql, RowMapper rowMapper) throws DataAccessException { - return query(cql, rowMapper).buffer(2).flatMap(list -> - Mono.just(DataAccessUtils.requiredSingleResult(list))) + return query(cql, rowMapper).buffer(2).flatMap(list -> Mono.just(DataAccessUtils.requiredSingleResult(list))) .next(); } @@ -382,8 +378,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re */ @Override public Mono queryForObject(Statement statement, RowMapper rowMapper) throws DataAccessException { - return query(statement, rowMapper).buffer(2).flatMap(list -> - Mono.just(DataAccessUtils.requiredSingleResult(list))) + return query(statement, rowMapper).buffer(2).flatMap(list -> Mono.just(DataAccessUtils.requiredSingleResult(list))) .next(); } @@ -573,8 +568,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re */ @Override public Mono queryForObject(String cql, RowMapper rowMapper, Object... args) throws DataAccessException { - return query(cql, rowMapper, args).buffer(2).flatMap(list -> - Mono.just(DataAccessUtils.requiredSingleResult(list))) + return query(cql, rowMapper, args).buffer(2).flatMap(list -> Mono.just(DataAccessUtils.requiredSingleResult(list))) .next(); } @@ -618,8 +612,8 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re Assert.hasText(cql, "CQL must not be empty"); - return query(new SimpleReactivePreparedStatementCreator(cql), - newArgPreparedStatementBinder(args), Mono::just).next(); + return query(new SimpleReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), Mono::just) + .next(); } /* (non-Javadoc) @@ -644,8 +638,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re */ @Override public Mono execute(String cql, PreparedStatementBinder psb) throws DataAccessException { - return query(new SimpleReactivePreparedStatementCreator(cql), psb, resultSet -> - Mono.just(resultSet.wasApplied())) + return query(new SimpleReactivePreparedStatementCreator(cql), psb, resultSet -> Mono.just(resultSet.wasApplied())) .next(); } @@ -757,8 +750,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re protected Function> translateException(String task, String cql) { return throwable -> Mono - .error( - throwable instanceof DriverException ? translate(task, cql, (DriverException) throwable) : throwable); + .error(throwable instanceof DriverException ? translate(task, cql, (DriverException) throwable) : throwable); } /** diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallbackHandler.java b/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallbackHandler.java index 3f852ab25..1bfbd0c47 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallbackHandler.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallbackHandler.java @@ -39,8 +39,8 @@ import com.datastax.driver.core.exceptions.DriverException; public interface RowCallbackHandler { /** - * Implementations must implement this method to process each row of data in the {@link ResultSet}. This method is only - * supposed to extract values of the current row. + * Implementations must implement this method to process each row of data in the {@link ResultSet}. This method is + * only supposed to extract values of the current row. *

* Exactly what the implementation chooses to do is up to it: A trivial implementation might simply count rows, while * another implementation might build an XML document. diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/RowMapperResultSetExtractor.java b/spring-cql/src/main/java/org/springframework/cassandra/core/RowMapperResultSetExtractor.java index 2834607e6..8fb10462b 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/RowMapperResultSetExtractor.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/RowMapperResultSetExtractor.java @@ -18,13 +18,13 @@ package org.springframework.cassandra.core; import java.util.ArrayList; import java.util.List; +import org.springframework.dao.DataAccessException; +import org.springframework.util.Assert; + import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; import com.datastax.driver.core.exceptions.DriverException; -import org.springframework.dao.DataAccessException; -import org.springframework.util.Assert; - /** * Adapter implementation of the {@link ResultSetExtractor} interface that delegates to a {@link RowMapper} which is * supposed to create an object for each row. Each object is added to the results List of this diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java index 0efc7f047..bc71ee132 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/converter/AbstractResultSetConverter.java @@ -101,7 +101,7 @@ public abstract class AbstractResultSetConverter implements Converter subtype of this class for which this is a CQL generator. */ -public abstract class KeyspaceCqlGenerator> extends - KeyspaceOptionsCqlGenerator> { +public abstract class KeyspaceCqlGenerator> + extends KeyspaceOptionsCqlGenerator> { public KeyspaceCqlGenerator(KeyspaceSpecification specification) { super(specification); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/KeyspaceOptionsCqlGenerator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/KeyspaceOptionsCqlGenerator.java index ce261c038..6b543de5a 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/KeyspaceOptionsCqlGenerator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/KeyspaceOptionsCqlGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2013-2014 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,9 +15,7 @@ */ package org.springframework.cassandra.core.cql.generator; -import static org.springframework.cassandra.core.cql.CqlStringUtils.escapeSingle; -import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull; -import static org.springframework.cassandra.core.cql.CqlStringUtils.singleQuote; +import static org.springframework.cassandra.core.cql.CqlStringUtils.*; import java.util.Map; @@ -26,12 +24,12 @@ import org.springframework.cassandra.core.keyspace.Option; /** * Base class that contains behavior common to CQL generation for table operations. - * + * * @author Matthew T. Adams * @param T The subtype of this class for which this is a CQL generator. */ -public abstract class KeyspaceOptionsCqlGenerator> extends - KeyspaceNameCqlGenerator> { +public abstract class KeyspaceOptionsCqlGenerator> + extends KeyspaceNameCqlGenerator> { public KeyspaceOptionsCqlGenerator(KeyspaceOptionsSpecification specification) { super(specification); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/RenameColumnCqlGenerator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/RenameColumnCqlGenerator.java index 6429e1e74..7389c0dd1 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/RenameColumnCqlGenerator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/RenameColumnCqlGenerator.java @@ -15,7 +15,7 @@ */ package org.springframework.cassandra.core.cql.generator; -import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull; +import static org.springframework.cassandra.core.cql.CqlStringUtils.*; import org.springframework.cassandra.core.keyspace.ColumnChangeSpecification; import org.springframework.cassandra.core.keyspace.RenameColumnSpecification; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableCqlGenerator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableCqlGenerator.java index 6ba8bc97b..deb71070d 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableCqlGenerator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableCqlGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2013-2014 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,12 +19,12 @@ import org.springframework.cassandra.core.keyspace.TableSpecification; /** * Base class that contains behavior common to CQL generation for table operations. - * + * * @author Matthew T. Adams * @param T The subtype of this class for which this is a CQL generator. */ -public abstract class TableCqlGenerator> extends - TableOptionsCqlGenerator> { +public abstract class TableCqlGenerator> + extends TableOptionsCqlGenerator> { public TableCqlGenerator(TableSpecification specification) { super(specification); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableOptionsCqlGenerator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableOptionsCqlGenerator.java index 0d0f777f9..7161785ad 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableOptionsCqlGenerator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/cql/generator/TableOptionsCqlGenerator.java @@ -1,12 +1,12 @@ /* * Copyright 2013-2014 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,9 +15,7 @@ */ package org.springframework.cassandra.core.cql.generator; -import static org.springframework.cassandra.core.cql.CqlStringUtils.escapeSingle; -import static org.springframework.cassandra.core.cql.CqlStringUtils.noNull; -import static org.springframework.cassandra.core.cql.CqlStringUtils.singleQuote; +import static org.springframework.cassandra.core.cql.CqlStringUtils.*; import java.util.Map; @@ -26,12 +24,12 @@ import org.springframework.cassandra.core.keyspace.TableOptionsSpecification; /** * Base class that contains behavior common to CQL generation for table operations. - * + * * @author Matthew T. Adams * @param T The subtype of this class for which this is a CQL generator. */ -public abstract class TableOptionsCqlGenerator> extends - TableNameCqlGenerator> { +public abstract class TableOptionsCqlGenerator> + extends TableNameCqlGenerator> { public TableOptionsCqlGenerator(TableOptionsSpecification specification) { super(specification); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/CreateKeyspaceSpecification.java b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/CreateKeyspaceSpecification.java index 9329e9cf2..49e57aa43 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/CreateKeyspaceSpecification.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/CreateKeyspaceSpecification.java @@ -86,10 +86,8 @@ public class CreateKeyspaceSpecification extends KeyspaceSpecification The subtype of the {@link KeyspaceOptionsSpecification}. */ -public abstract class KeyspaceOptionsSpecification> extends - KeyspaceActionSpecification> { +public abstract class KeyspaceOptionsSpecification> + extends KeyspaceActionSpecification> { protected Map options = new LinkedHashMap<>(); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/KeyspaceSpecification.java b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/KeyspaceSpecification.java index eaef1ea6c..2d82b560a 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/KeyspaceSpecification.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/KeyspaceSpecification.java @@ -1,12 +1,12 @@ /* * Copyright 2013-2014 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,9 +18,9 @@ package org.springframework.cassandra.core.keyspace; /** * Builder class to support the construction of keyspace specifications that have columns. This class can also be used * as a standalone {@link KeyspaceDescriptor}, independent of {@link CreateKeyspaceSpecification}. - * + * * @author John McPeek * @author Matthew T. Adams */ -public class KeyspaceSpecification extends KeyspaceOptionsSpecification> implements - KeyspaceDescriptor {} +public class KeyspaceSpecification extends KeyspaceOptionsSpecification> + implements KeyspaceDescriptor {} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOption.java b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOption.java index 6a41e2b12..5b4cc0bf4 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOption.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOption.java @@ -132,7 +132,6 @@ public enum TableOption implements Option { * * @author David Webb * @since 1.2.0 - * */ public enum KeyCachingOption { @@ -270,8 +269,7 @@ public enum TableOption implements Option { private Option delegate; - CompactionOption(String name, Class type, boolean requiresValue, boolean escapesValue, - boolean quotesValue) { + CompactionOption(String name, Class type, boolean requiresValue, boolean escapesValue, boolean quotesValue) { this.delegate = new DefaultOption(name, type, requiresValue, escapesValue, quotesValue); } @@ -347,8 +345,7 @@ public enum TableOption implements Option { private Option delegate; - CompressionOption(String name, Class type, boolean requiresValue, boolean escapesValue, - boolean quotesValue) { + CompressionOption(String name, Class type, boolean requiresValue, boolean escapesValue, boolean quotesValue) { this.delegate = new DefaultOption(name, type, requiresValue, escapesValue, quotesValue); } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOptionsSpecification.java b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOptionsSpecification.java index 81ce61d8e..be788349b 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOptionsSpecification.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/TableOptionsSpecification.java @@ -37,8 +37,8 @@ import org.springframework.cassandra.core.cql.CqlStringUtils; * @author Matthew T. Adams * @param The subtype of the {@link TableOptionsSpecification}. */ -public abstract class TableOptionsSpecification> extends - TableNameSpecification> { +public abstract class TableOptionsSpecification> + extends TableNameSpecification> { protected Map options = new LinkedHashMap<>(); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/UserTypeSpecification.java b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/UserTypeSpecification.java index 4b45ba477..cd53006d1 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/UserTypeSpecification.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/keyspace/UserTypeSpecification.java @@ -15,7 +15,7 @@ */ package org.springframework.cassandra.core.keyspace; -import static org.springframework.cassandra.core.cql.CqlIdentifier.cqlId; +import static org.springframework.cassandra.core.cql.CqlIdentifier.*; import java.util.ArrayList; import java.util.Collections; diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java index 518f4cadf..52a56ad92 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/DefaultBridgedReactiveSession.java @@ -15,6 +15,11 @@ */ package org.springframework.cassandra.core.session; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Scheduler; +import reactor.core.scheduler.Schedulers; + import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -23,22 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Scheduler; -import reactor.core.scheduler.Schedulers; - -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.ColumnDefinitions; -import com.datastax.driver.core.ExecutionInfo; -import com.datastax.driver.core.PreparedStatement; -import com.datastax.driver.core.RegularStatement; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.ResultSetFuture; -import com.datastax.driver.core.Row; -import com.datastax.driver.core.Session; -import com.datastax.driver.core.SimpleStatement; -import com.datastax.driver.core.Statement; +import com.datastax.driver.core.*; import com.google.common.util.concurrent.ListenableFuture; /** diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/session/lookup/AbstractRoutingSessionFactory.java b/spring-cql/src/main/java/org/springframework/cassandra/core/session/lookup/AbstractRoutingSessionFactory.java index 9a48f51df..04d54095f 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/session/lookup/AbstractRoutingSessionFactory.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/core/session/lookup/AbstractRoutingSessionFactory.java @@ -108,8 +108,7 @@ public abstract class AbstractRoutingSessionFactory implements SessionFactory, I * {@literal null}. */ public void setSessionFactoryLookup(SessionFactoryLookup sessionFactoryLookup) { - this.sessionFactoryLookup = (sessionFactoryLookup != null ? sessionFactoryLookup - : new MapSessionFactoryLookup()); + this.sessionFactoryLookup = (sessionFactoryLookup != null ? sessionFactoryLookup : new MapSessionFactoryLookup()); } /* (non-Javadoc) @@ -175,8 +174,8 @@ public abstract class AbstractRoutingSessionFactory implements SessionFactory, I } else if (sessionFactory instanceof String) { return this.sessionFactoryLookup.getSessionFactory((String) sessionFactory); } else { - throw new IllegalArgumentException(String.format( - "Illegal session factory value. Only [org.springframework.cassandra.core.session.SessionFactory]" + throw new IllegalArgumentException(String + .format("Illegal session factory value. Only [org.springframework.cassandra.core.session.SessionFactory]" + " and String supported: %s", sessionFactory)); } } diff --git a/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraExceptionTranslator.java b/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraExceptionTranslator.java index 1c7e86707..29154745b 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraExceptionTranslator.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/support/CassandraExceptionTranslator.java @@ -28,8 +28,8 @@ import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.dao.TransientDataAccessResourceException; import org.springframework.dao.support.PersistenceExceptionTranslator; -import org.springframework.util.StringUtils; import org.springframework.util.ClassUtils; +import org.springframework.util.StringUtils; import com.datastax.driver.core.WriteType; import com.datastax.driver.core.exceptions.*; @@ -150,12 +150,10 @@ public class CassandraExceptionTranslator implements CQLExceptionTranslator { return new CassandraTraceRetrievalException(message, exception); } - - - if (exception instanceof NoHostAvailableException) { - return new CassandraConnectionFailureException(((NoHostAvailableException) exception).getErrors(),message, - exception); - } + if (exception instanceof NoHostAvailableException) { + return new CassandraConnectionFailureException(((NoHostAvailableException) exception).getErrors(), message, + exception); + } String exceptionType = ClassUtils.getShortName(ClassUtils.getUserClass(exception.getClass())); diff --git a/spring-cql/src/main/java/org/springframework/cassandra/support/exception/CassandraSchemaElementExistsException.java b/spring-cql/src/main/java/org/springframework/cassandra/support/exception/CassandraSchemaElementExistsException.java index a43d9b113..44e733937 100644 --- a/spring-cql/src/main/java/org/springframework/cassandra/support/exception/CassandraSchemaElementExistsException.java +++ b/spring-cql/src/main/java/org/springframework/cassandra/support/exception/CassandraSchemaElementExistsException.java @@ -33,7 +33,8 @@ public class CassandraSchemaElementExistsException extends NonTransientDataAcces private String elementName; private ElementType elementType; - public CassandraSchemaElementExistsException(String elementName, ElementType elementType, String msg, Throwable cause) { + public CassandraSchemaElementExistsException(String elementName, ElementType elementType, String msg, + Throwable cause) { super(msg, cause); this.elementName = elementName; this.elementType = elementType; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java index dad6df280..78d4078f7 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlClusterFactoryBeanUnitTests.java @@ -16,26 +16,16 @@ package org.springframework.cassandra.config; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.*; import org.junit.Test; import org.mockito.Matchers; import org.springframework.test.util.ReflectionTestUtils; -import com.datastax.driver.core.AuthProvider; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Configuration; -import com.datastax.driver.core.JdkSSLOptions; -import com.datastax.driver.core.PlainTextAuthProvider; -import com.datastax.driver.core.PoolingOptions; -import com.datastax.driver.core.ProtocolOptions; +import com.datastax.driver.core.*; import com.datastax.driver.core.ProtocolOptions.Compression; -import com.datastax.driver.core.ProtocolVersion; -import com.datastax.driver.core.QueryOptions; -import com.datastax.driver.core.SSLOptions; -import com.datastax.driver.core.SocketOptions; -import com.datastax.driver.core.TimestampGenerator; import com.datastax.driver.core.policies.AddressTranslator; import com.datastax.driver.core.policies.ExponentialReconnectionPolicy; import com.datastax.driver.core.policies.LoadBalancingPolicy; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java index 2a1a35581..0fe5e4a73 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/config/CassandraCqlSessionFactoryBeanUnitTests.java @@ -17,7 +17,8 @@ package org.springframework.cassandra.config; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; import java.util.ArrayList; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java index e17c72876..59c7f4758 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/config/PoolingOptionsFactoryBeanUnitTests.java @@ -17,7 +17,10 @@ package org.springframework.cassandra.config; import static org.assertj.core.api.Assertions.*; import static org.junit.Assume.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.same; import static org.mockito.Mockito.*; import static org.springframework.util.ReflectionUtils.*; @@ -310,7 +313,8 @@ public class PoolingOptionsFactoryBeanUnitTests { final PoolingOptionsFactoryBean.HostDistancePoolingOptions mockHostDistancePoolingOptions = mock( PoolingOptionsFactoryBean.HostDistancePoolingOptions.class); - when(mockHostDistancePoolingOptions.configure(any(PoolingOptions.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); + when(mockHostDistancePoolingOptions.configure(any(PoolingOptions.class))) + .thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); poolingOptionsFactoryBean = new PoolingOptionsFactoryBean() { @Override @@ -331,7 +335,8 @@ public class PoolingOptionsFactoryBeanUnitTests { final PoolingOptionsFactoryBean.HostDistancePoolingOptions mockHostDistancePoolingOptions = mock( PoolingOptionsFactoryBean.HostDistancePoolingOptions.class); - when(mockHostDistancePoolingOptions.configure(any(PoolingOptions.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); + when(mockHostDistancePoolingOptions.configure(any(PoolingOptions.class))) + .thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); poolingOptionsFactoryBean = new PoolingOptionsFactoryBean() { @Override diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java index d2976ff14..9c560a4f0 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/config/java/AbstractClusterConfigurationUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.cassandra.config.java; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.*; import java.util.Collections; @@ -30,17 +30,8 @@ import org.springframework.cassandra.config.CompressionType; import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification; import org.springframework.cassandra.core.keyspace.DropKeyspaceSpecification; -import com.datastax.driver.core.AuthProvider; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Configuration; -import com.datastax.driver.core.PlainTextAuthProvider; -import com.datastax.driver.core.PoolingOptions; -import com.datastax.driver.core.ProtocolOptions; +import com.datastax.driver.core.*; import com.datastax.driver.core.ProtocolOptions.Compression; -import com.datastax.driver.core.ProtocolVersion; -import com.datastax.driver.core.QueryOptions; -import com.datastax.driver.core.SocketOptions; -import com.datastax.driver.core.TimestampGenerator; import com.datastax.driver.core.policies.AddressTranslator; import com.datastax.driver.core.policies.ExponentialReconnectionPolicy; import com.datastax.driver.core.policies.LoadBalancingPolicy; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java index 99944c361..cf777e386 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/config/xml/CassandraCqlClusterParserUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.cassandra.config.xml; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; import static org.springframework.cassandra.support.BeanDefinitionTestUtils.*; diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java index cb0189b57..d515579ae 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/AsyncCqlTemplateIntegrationTests.java @@ -147,12 +147,11 @@ public class AsyncCqlTemplateIntegrationTests extends AbstractKeyspaceCreatingIn public void queryPreparedStatementCreatorShouldInvokeCallback() throws Exception { List result = new ArrayList<>(); - getUninterruptibly(template.query( - session -> new GuavaListenableFutureAdapter<>( - session.prepareAsync("SELECT id FROM user WHERE id = ?;"), template.getExceptionTranslator()), - ps -> ps.bind("WHITE"), row -> { - result.add(row.getString(0)); - })); + getUninterruptibly(template + .query(session -> new GuavaListenableFutureAdapter<>(session.prepareAsync("SELECT id FROM user WHERE id = ?;"), + template.getExceptionTranslator()), ps -> ps.bind("WHITE"), row -> { + result.add(row.getString(0)); + })); assertThat(result).contains("WHITE"); } diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java index be868aa25..09811b8e9 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/CachedPreparedStatementCreatorUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.cassandra.core; import static edu.umd.cs.mtc.TestFramework.*; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; import edu.umd.cs.mtc.MultithreadedTestCase; @@ -38,7 +38,7 @@ import com.datastax.driver.core.Session; /** * Unit tests for {@link CachedPreparedStatementCreator}. - * + * * @author Mark Paluch */ @RunWith(MockitoJUnitRunner.class) diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java index 4ae8e4304..fb81c656b 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/CqlTemplateUnitTests.java @@ -443,8 +443,7 @@ public class CqlTemplateUnitTests { doTestStrings(null, null, null, cqlTemplate -> { - ResultSet resultSet = cqlTemplate.execute("SELECT * from USERS", - (session, ps) -> session.execute(ps.bind("A"))); + ResultSet resultSet = cqlTemplate.execute("SELECT * from USERS", (session, ps) -> session.execute(ps.bind("A"))); try { assertThat(resultSet).hasSize(3); diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java index 3acf392f4..1e1b39a35 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionIntegrationTests.java @@ -92,8 +92,8 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");"); - Mono execution = reactiveSession.prepare( - "INSERT INTO users (userid, first_name) VALUES (?, ?);"); + Mono execution = reactiveSession + .prepare("INSERT INTO users (userid, first_name) VALUES (?, ?);"); PreparedStatement preparedStatement = execution.block(); assertThat(preparedStatement).isNotNull(); diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java index d2eb4b251..467b1eaf3 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/DefaultBridgedReactiveSessionUnitTests.java @@ -83,8 +83,8 @@ public class DefaultBridgedReactiveSessionUnitTests { reactiveSession.execute("SELECT * WHERE a = ?", Collections.singletonMap("a", "value")).subscribe(); - verify(sessionMock).executeAsync(eq(new SimpleStatement("SELECT * WHERE a = ?", - Collections.singletonMap("a", "value")))); + verify(sessionMock) + .executeAsync(eq(new SimpleStatement("SELECT * WHERE a = ?", Collections.singletonMap("a", "value")))); } @Test // DATACASS-335 @@ -137,7 +137,7 @@ public class DefaultBridgedReactiveSessionUnitTests { private static T eq(T value) { return ArgumentMatchers.argThat(argument -> argument instanceof Statement // - ? value.toString().equals(argument.toString()) // - : value.equals(argument)); + ? value.toString().equals(argument.toString()) // + : value.equals(argument)); } } diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java index 0c6b00605..99ad9f443 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/AlterKeyspaceCqlGeneratorUnitTests.java @@ -45,7 +45,9 @@ public class AlterKeyspaceCqlGeneratorUnitTests { private static void assertReplicationMap(Map replicationMap, String cql) { assertThat(cql.contains(" WITH replication = { ")).isTrue(); - replicationMap.entrySet().stream().map(entry -> "'" + entry.getKey().getName() + "' : '" + entry.getValue().toString() + "'").forEach(keyValuePair -> assertThat(cql.contains(keyValuePair)).isTrue()); + replicationMap.entrySet().stream() + .map(entry -> "'" + entry.getKey().getName() + "' : '" + entry.getValue().toString() + "'") + .forEach(keyValuePair -> assertThat(cql.contains(keyValuePair)).isTrue()); } public static void assertDurableWrites(Boolean durableWrites, String cql) { diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorUnitTests.java index 4da6abb2c..77ccd7e0f 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/cql/generator/CreateTableCqlGeneratorUnitTests.java @@ -278,7 +278,7 @@ public class CreateTableCqlGeneratorUnitTests { public static final List FUNKY_LEGAL_NAMES; static { - List funkies = new ArrayList<>(Arrays.asList(new String[]{ /* TODO */})); + List funkies = new ArrayList<>(Arrays.asList(new String[] { /* TODO */ })); // TODO: should these work? "a \"\" x", "a\"\"\"\"x", "a b" FUNKY_LEGAL_NAMES = Collections.unmodifiableList(Arrays.stream(ReservedKeyword.values()) // .map(Enum::name) // diff --git a/spring-cql/src/test/java/org/springframework/cassandra/core/session/lookup/MapSessionFactoryLookupUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/core/session/lookup/MapSessionFactoryLookupUnitTests.java index b7926d748..17ec551ac 100644 --- a/spring-cql/src/test/java/org/springframework/cassandra/core/session/lookup/MapSessionFactoryLookupUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/core/session/lookup/MapSessionFactoryLookupUnitTests.java @@ -51,8 +51,7 @@ public class MapSessionFactoryLookupUnitTests { @Test // DATACASS-330 public void shouldResolveSessionFactoryCorrectly() { - MapSessionFactoryLookup sessionFactoryLookup = - new MapSessionFactoryLookup("factory", sessionFactory); + MapSessionFactoryLookup sessionFactoryLookup = new MapSessionFactoryLookup("factory", sessionFactory); assertThat(sessionFactoryLookup.getSessionFactory("factory")).isSameAs(sessionFactory); } diff --git a/spring-cql/src/test/java/org/springframework/cassandra/support/CassandraExceptionTranslatorUnitTests.java b/spring-cql/src/test/java/org/springframework/cassandra/support/CassandraExceptionTranslatorUnitTests.java index c6a427d18..164823ec6 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/support/CassandraExceptionTranslatorUnitTests.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/support/CassandraExceptionTranslatorUnitTests.java @@ -23,24 +23,8 @@ import java.net.InetSocketAddress; import java.util.Collections; import org.junit.Test; -import org.springframework.cassandra.support.exception.CassandraAuthenticationException; -import org.springframework.cassandra.support.exception.CassandraConnectionFailureException; -import org.springframework.cassandra.support.exception.CassandraInsufficientReplicasAvailableException; -import org.springframework.cassandra.support.exception.CassandraInternalException; -import org.springframework.cassandra.support.exception.CassandraInvalidConfigurationInQueryException; -import org.springframework.cassandra.support.exception.CassandraInvalidQueryException; -import org.springframework.cassandra.support.exception.CassandraKeyspaceExistsException; -import org.springframework.cassandra.support.exception.CassandraQuerySyntaxException; -import org.springframework.cassandra.support.exception.CassandraReadTimeoutException; -import org.springframework.cassandra.support.exception.CassandraSchemaElementExistsException; +import org.springframework.cassandra.support.exception.*; import org.springframework.cassandra.support.exception.CassandraSchemaElementExistsException.ElementType; -import org.springframework.cassandra.support.exception.CassandraTableExistsException; -import org.springframework.cassandra.support.exception.CassandraTraceRetrievalException; -import org.springframework.cassandra.support.exception.CassandraTruncateException; -import org.springframework.cassandra.support.exception.CassandraTypeMismatchException; -import org.springframework.cassandra.support.exception.CassandraUnauthorizedException; -import org.springframework.cassandra.support.exception.CassandraUncategorizedException; -import org.springframework.cassandra.support.exception.CassandraWriteTimeoutException; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.dao.TransientDataAccessResourceException; @@ -50,34 +34,7 @@ import com.datastax.driver.core.ConsistencyLevel; import com.datastax.driver.core.DataType; import com.datastax.driver.core.ProtocolVersion; import com.datastax.driver.core.WriteType; -import com.datastax.driver.core.exceptions.AlreadyExistsException; -import com.datastax.driver.core.exceptions.AuthenticationException; -import com.datastax.driver.core.exceptions.BootstrappingException; -import com.datastax.driver.core.exceptions.BusyConnectionException; -import com.datastax.driver.core.exceptions.CodecNotFoundException; -import com.datastax.driver.core.exceptions.ConnectionException; -import com.datastax.driver.core.exceptions.DriverException; -import com.datastax.driver.core.exceptions.DriverInternalError; -import com.datastax.driver.core.exceptions.FunctionExecutionException; -import com.datastax.driver.core.exceptions.InvalidConfigurationInQueryException; -import com.datastax.driver.core.exceptions.InvalidQueryException; -import com.datastax.driver.core.exceptions.InvalidTypeException; -import com.datastax.driver.core.exceptions.NoHostAvailableException; -import com.datastax.driver.core.exceptions.OverloadedException; -import com.datastax.driver.core.exceptions.PagingStateException; -import com.datastax.driver.core.exceptions.ReadFailureException; -import com.datastax.driver.core.exceptions.ReadTimeoutException; -import com.datastax.driver.core.exceptions.SyntaxError; -import com.datastax.driver.core.exceptions.TraceRetrievalException; -import com.datastax.driver.core.exceptions.TruncateException; -import com.datastax.driver.core.exceptions.UnauthorizedException; -import com.datastax.driver.core.exceptions.UnavailableException; -import com.datastax.driver.core.exceptions.UnpreparedException; -import com.datastax.driver.core.exceptions.UnresolvedUserTypeException; -import com.datastax.driver.core.exceptions.UnsupportedFeatureException; -import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; -import com.datastax.driver.core.exceptions.WriteFailureException; -import com.datastax.driver.core.exceptions.WriteTimeoutException; +import com.datastax.driver.core.exceptions.*; import com.google.common.reflect.TypeToken; /** diff --git a/spring-cql/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java b/spring-cql/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java index 3942a222e..964d6c9d9 100755 --- a/spring-cql/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java +++ b/spring-cql/src/test/java/org/springframework/cassandra/test/integration/AbstractEmbeddedCassandraIntegrationTest.java @@ -43,11 +43,10 @@ public abstract class AbstractEmbeddedCassandraIntegrationTest { /** * Initiate a Cassandra environment in test scope. */ - @Rule public final CassandraRule cassandraRule = cassandraEnvironment.testInstance() - .before(session -> { - AbstractEmbeddedCassandraIntegrationTest.this.cluster = session.getCluster(); - return null; - }); + @Rule public final CassandraRule cassandraRule = cassandraEnvironment.testInstance().before(session -> { + AbstractEmbeddedCassandraIntegrationTest.this.cluster = session.getCluster(); + return null; + }); /** * The {@link Cluster} that's connected to Cassandra. diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionBuilderArgument.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionBuilderArgument.java index 041c44c84..8387a308b 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionBuilderArgument.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionBuilderArgument.java @@ -60,9 +60,9 @@ public class BeanDefinitionBuilderArgument { protected BeanDefinitionBuilderArgument(boolean reference, Object value) { this.reference = reference; if (this.reference && (value == null || !(value instanceof CharSequence))) { - throw new IllegalArgumentException(String.format( - "reference argument must have value of type CharSequence, not [%s]", value == null ? "null" : value - .getClass().getName())); + throw new IllegalArgumentException( + String.format("reference argument must have value of type CharSequence, not [%s]", + value == null ? "null" : value.getClass().getName())); } if (!StringUtils.hasText((CharSequence) value)) { throw new IllegalArgumentException("given CharSequence has no text"); diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java index f562f6794..1a60ccbcf 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java @@ -93,7 +93,8 @@ public class BeanDefinitionUtils { * @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean) */ public static BeanDefinitionHolder getSingleBeanDefinitionOfType(BeanDefinitionRegistry registry, - ListableBeanFactory factory, Class type, boolean includeNonSingletons, boolean allowEagerInit, boolean required) { + ListableBeanFactory factory, Class type, boolean includeNonSingletons, boolean allowEagerInit, + boolean required) { BeanDefinitionHolder[] definitions = getBeanDefinitionsOfType(registry, factory, type, includeNonSingletons, allowEagerInit); diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraEntityClassScanner.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraEntityClassScanner.java index 817ddc1a5..71497fe66 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraEntityClassScanner.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/CassandraEntityClassScanner.java @@ -85,8 +85,7 @@ public class CassandraEntityClassScanner { } public void setEntityBasePackages(Collection entityBasePackages) { - this.entityBasePackages = entityBasePackages == null ? new HashSet<>() : new HashSet<>( - entityBasePackages); + this.entityBasePackages = entityBasePackages == null ? new HashSet<>() : new HashSet<>(entityBasePackages); } public Set> getEntityBasePackageClasses() { @@ -94,8 +93,8 @@ public class CassandraEntityClassScanner { } public void setEntityBasePackageClasses(Collection> entityBasePackageClasses) { - this.entityBasePackageClasses = entityBasePackageClasses == null ? new HashSet<>() : new HashSet<>( - entityBasePackageClasses); + this.entityBasePackageClasses = entityBasePackageClasses == null ? new HashSet<>() + : new HashSet<>(entityBasePackageClasses); } public void setBeanClassLoader(ClassLoader beanClassLoader) { diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/CassandraConverters.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/CassandraConverters.java index c72f571ec..01736b6e7 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/CassandraConverters.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/CassandraConverters.java @@ -146,8 +146,7 @@ abstract class CassandraConverters { Object object = source.getObject(0); - return (object != null ? NumberUtils.convertNumberToTargetClass((Number) object, this.targetType) - : null); + return (object != null ? NumberUtils.convertNumberToTargetClass((Number) object, this.targetType) : null); } } } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraTemplate.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraTemplate.java index 553a313ba..1dae1097d 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraTemplate.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraTemplate.java @@ -79,8 +79,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations { private final CQLExceptionTranslator exceptionTranslator; /** - * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link Session} - * and a default {@link MappingCassandraConverter}. + * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link Session} and a default + * {@link MappingCassandraConverter}. * * @param session {@link Session} used to interact with Cassandra; must not be {@literal null}. * @see CassandraConverter @@ -91,12 +91,12 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations { } /** - * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link Session} - * and {@link CassandraConverter}. + * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link Session} and + * {@link CassandraConverter}. * * @param session {@link Session} used to interact with Cassandra; must not be {@literal null}. - * @param converter {@link CassandraConverter} used to convert between Java and Cassandra types; - * must not be {@literal null}. + * @param converter {@link CassandraConverter} used to convert between Java and Cassandra types; must not be + * {@literal null}. * @see CassandraConverter * @see Session */ @@ -105,12 +105,12 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations { } /** - * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link SessionFactory} - * and {@link CassandraConverter}. + * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link SessionFactory} and + * {@link CassandraConverter}. * * @param sessionFactory {@link SessionFactory} used to interact with Cassandra; must not be {@literal null}. - * @param converter {@link CassandraConverter} used to convert between Java and Cassandra types; - * must not be {@literal null}. + * @param converter {@link CassandraConverter} used to convert between Java and Cassandra types; must not be + * {@literal null}. * @see CassandraConverter * @see Session */ @@ -119,12 +119,12 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations { } /** - * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link AsyncCqlTemplate} - * and {@link CassandraConverter}. + * Creates an instance of {@link AsyncCassandraTemplate} initialized with the given {@link AsyncCqlTemplate} and + * {@link CassandraConverter}. * * @param asyncCqlTemplate {@link AsyncCqlTemplate} used to interact with Cassandra; must not be {@literal null}. - * @param converter {@link CassandraConverter} used to convert between Java and Cassandra types; - * must not be {@literal null}. + * @param converter {@link CassandraConverter} used to convert between Java and Cassandra types; must not be + * {@literal null}. * @see CassandraConverter * @see Session */ diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraAdminTemplate.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraAdminTemplate.java index ed04ae9ab..91378a0b3 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraAdminTemplate.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraAdminTemplate.java @@ -18,8 +18,6 @@ package org.springframework.data.cassandra.core; import java.util.Map; import java.util.Optional; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.cassandra.core.SessionCallback; import org.springframework.cassandra.core.cql.CqlIdentifier; import org.springframework.cassandra.core.cql.generator.CreateTableCqlGenerator; @@ -29,7 +27,6 @@ import org.springframework.cassandra.core.keyspace.CreateTableSpecification; import org.springframework.cassandra.core.keyspace.DropTableSpecification; import org.springframework.cassandra.core.keyspace.DropUserTypeSpecification; import org.springframework.cassandra.core.session.SessionFactory; -import org.springframework.dao.DataAccessException; import org.springframework.data.cassandra.convert.CassandraConverter; import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; import org.springframework.util.Assert; @@ -133,10 +130,8 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand KeyspaceMetadata keyspaceMetadata = session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace()); - - - Assert.state(keyspaceMetadata != null, String.format("Metadata for keyspace [%s] not available", - session.getLoggedKeyspace())); + Assert.state(keyspaceMetadata != null, + String.format("Metadata for keyspace [%s] not available", session.getLoggedKeyspace())); return keyspaceMetadata; }); diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java index 3c4e24e36..ebc0ea1ac 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java @@ -18,7 +18,6 @@ package org.springframework.data.cassandra.core; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/QueryUtils.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/QueryUtils.java index c11a12448..013857986 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/QueryUtils.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/QueryUtils.java @@ -15,7 +15,6 @@ */ package org.springframework.data.cassandra.core; -import org.springframework.cassandra.core.CqlTemplate; import org.springframework.cassandra.core.QueryOptions; import org.springframework.cassandra.core.QueryOptionsUtil; import org.springframework.cassandra.core.WriteOptions; @@ -32,7 +31,7 @@ import com.datastax.driver.core.querybuilder.Update; * Simple utility class for working with the QueryBuilder API. *

* Only intended for internal use. - * + * * @author Mark Paluch * @since 2.0 */ diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraOperations.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraOperations.java index 8aa502b83..cdae7afe9 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraOperations.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraOperations.java @@ -15,6 +15,9 @@ */ package org.springframework.data.cassandra.core; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import org.reactivestreams.Publisher; import org.springframework.cassandra.core.QueryOptions; import org.springframework.cassandra.core.ReactiveCqlOperations; @@ -24,9 +27,6 @@ import org.springframework.data.cassandra.convert.CassandraConverter; import com.datastax.driver.core.Statement; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Interface specifying a basic set of reactive Cassandra operations. Implemented by {@link ReactiveCassandraTemplate}. * Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed. @@ -246,7 +246,7 @@ public interface ReactiveCassandraOperations { /** * Execute a {@code TRUNCATE} query to remove all entities of a given class. - * + * * @param entityClass The entity type must not be {@literal null}. * @throws DataAccessException if there is any problem issuing the execution. */ @@ -261,7 +261,7 @@ public interface ReactiveCassandraOperations { /** * Expose the underlying {@link ReactiveCqlOperations} to allow CQL operations. - * + * * @return the underlying {@link ReactiveCqlOperations}. * @see ReactiveCqlOperations */ diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java index ffa98ee04..5a502bb99 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/ReactiveCassandraTemplate.java @@ -18,20 +18,6 @@ package org.springframework.data.cassandra.core; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import org.reactivestreams.Publisher; -import org.springframework.cassandra.core.*; -import org.springframework.cassandra.core.cql.CqlIdentifier; -import org.springframework.dao.DataAccessException; -import org.springframework.data.cassandra.convert.CassandraConverter; -import org.springframework.data.cassandra.convert.MappingCassandraConverter; -import org.springframework.data.cassandra.mapping.CassandraMappingContext; -import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - import org.reactivestreams.Publisher; import org.springframework.cassandra.core.CqlProvider; import org.springframework.cassandra.core.QueryOptions; @@ -45,7 +31,6 @@ import org.springframework.cassandra.core.session.ReactiveResultSet; import org.springframework.cassandra.core.session.ReactiveSession; import org.springframework.cassandra.core.session.ReactiveSessionFactory; import org.springframework.dao.DataAccessException; -import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.cassandra.convert.CassandraConverter; import org.springframework.data.cassandra.convert.MappingCassandraConverter; import org.springframework.data.cassandra.mapping.CassandraMappingContext; @@ -265,7 +250,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations { Assert.notNull(entityClass, "Entity type must not be null"); - Select select = QueryBuilder.select().countAll().from(mappingContext.getRequiredPersistentEntity(entityClass).getTableName().toCql()); + Select select = QueryBuilder.select().countAll() + .from(mappingContext.getRequiredPersistentEntity(entityClass).getTableName().toCql()); return cqlOperations.queryForObject(select, Long.class); } @@ -294,8 +280,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations { @Override public Publisher doInSession(ReactiveSession session) throws DriverException, DataAccessException { - return session.execute(insert).flatMap( - reactiveResultSet -> reactiveResultSet.wasApplied() ? Mono.just(entity) : Mono.empty()); + return session.execute(insert) + .flatMap(reactiveResultSet -> reactiveResultSet.wasApplied() ? Mono.just(entity) : Mono.empty()); } @Override @@ -352,8 +338,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations { @Override public Publisher doInSession(ReactiveSession session) throws DriverException, DataAccessException { - return session.execute(update).flatMap( - reactiveResultSet -> reactiveResultSet.wasApplied() ? Mono.just(entity) : Mono.empty()); + return session.execute(update) + .flatMap(reactiveResultSet -> reactiveResultSet.wasApplied() ? Mono.just(entity) : Mono.empty()); } @Override @@ -429,8 +415,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations { @Override public Publisher doInSession(ReactiveSession session) throws DriverException, DataAccessException { - return session.execute(delete).flatMap( - reactiveResultSet -> reactiveResultSet.wasApplied() ? Mono.just(entity) : Mono.empty()); + return session.execute(delete) + .flatMap(reactiveResultSet -> reactiveResultSet.wasApplied() ? Mono.just(entity) : Mono.empty()); } @Override @@ -472,7 +458,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations { Assert.notNull(entityClass, "Entity type must not be null"); - Truncate truncate = QueryBuilder.truncate(mappingContext.getRequiredPersistentEntity(entityClass).getTableName().toCql()); + Truncate truncate = QueryBuilder + .truncate(mappingContext.getRequiredPersistentEntity(entityClass).getTableName().toCql()); return cqlOperations.execute(truncate).then(); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentProperty.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentProperty.java index 0fff9ac6f..f57b56d0f 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentProperty.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentProperty.java @@ -458,8 +458,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP getName(), getOwner().getType().getName(), this.columnNames.size(), this.columnNames.size() == 1 ? "" : "s", columnNames.size())); - this.columnNames = this.explicitColumnNames = Collections - .unmodifiableList(new ArrayList<>(columnNames)); + this.columnNames = this.explicitColumnNames = Collections.unmodifiableList(new ArrayList<>(columnNames)); } /* (non-Javadoc) diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CassandraMappingContext.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CassandraMappingContext.java index 5c3e87369..24605077d 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CassandraMappingContext.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/CassandraMappingContext.java @@ -17,15 +17,15 @@ package org.springframework.data.cassandra.mapping; import java.util.Collection; -import com.datastax.driver.core.DataType; -import com.datastax.driver.core.TableMetadata; -import com.datastax.driver.core.UserType; - import org.springframework.cassandra.core.keyspace.CreateTableSpecification; import org.springframework.cassandra.core.keyspace.CreateUserTypeSpecification; import org.springframework.data.cassandra.convert.CustomConversions; import org.springframework.data.mapping.context.MappingContext; +import com.datastax.driver.core.DataType; +import com.datastax.driver.core.TableMetadata; +import com.datastax.driver.core.UserType; + /** * A {@link MappingContext} for Cassandra. * @@ -46,8 +46,9 @@ public interface CassandraMappingContext /** * Returns all persistent entities or only non-primary-key entities. * - * @param includePrimaryKeyTypesAndUdts If {@literal true}, returns all entities, including entities that represent primary - * key types and user-defined types. If {@literal false}, returns only entities that don't represent primary key types and no user-defined types. + * @param includePrimaryKeyTypesAndUdts If {@literal true}, returns all entities, including entities that represent + * primary key types and user-defined types. If {@literal false}, returns only entities that don't represent + * primary key types and no user-defined types. */ Collection> getPersistentEntities(boolean includePrimaryKeyTypesAndUdts); @@ -62,6 +63,7 @@ public interface CassandraMappingContext /** * Returns only those entities representing primary key types. + * * @deprecated as of 1.5 */ @Deprecated @@ -146,8 +148,8 @@ public interface CassandraMappingContext DataType getDataType(CassandraPersistentProperty property); /** - * Retrieve the data type based on the given {@code type}. Cassandra {@link DataType types} are determined using simple types and - * configured {@link CustomConversions}. + * Retrieve the data type based on the given {@code type}. Cassandra {@link DataType types} are determined using + * simple types and configured {@link CustomConversions}. * * @param type must not be {@literal null}. * @return the Cassandra {@link DataType type}. diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/EntityMapping.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/EntityMapping.java index d881ad3db..b6cf4405b 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/EntityMapping.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/mapping/EntityMapping.java @@ -85,8 +85,7 @@ public class EntityMapping { } public void setPropertyMappings(Map propertyMappings) { - this.propertyMappings = (propertyMappings != null ? new HashMap<>(propertyMappings) - : Collections.emptyMap()); + this.propertyMappings = (propertyMappings != null ? new HashMap<>(propertyMappings) : Collections.emptyMap()); } public String getTableName() { diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepository.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepository.java index 91b1e692b..90b4385cf 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepository.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/ReactiveCassandraRepository.java @@ -15,15 +15,15 @@ */ package org.springframework.data.cassandra.repository; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.io.Serializable; import org.reactivestreams.Publisher; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.reactive.ReactiveCrudRepository; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Cassandra specific {@link org.springframework.data.repository.Repository} interface with reactive support. * diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraEntityInformation.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraEntityInformation.java index 9cc0f3069..3f776a745 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraEntityInformation.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraEntityInformation.java @@ -1,12 +1,12 @@ /* * Copyright 2013-2014 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,10 +21,10 @@ import org.springframework.data.repository.core.EntityInformation; /** * Cassandra specific {@link EntityInformation}. - * + * * @author Alex Shvid */ -public interface CassandraEntityInformation extends EntityInformation, - CassandraEntityMetadata { +public interface CassandraEntityInformation + extends EntityInformation, CassandraEntityMetadata { } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraParameters.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraParameters.java index 513d9ecfd..787cd7629 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraParameters.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraParameters.java @@ -85,11 +85,11 @@ public class CassandraParameters extends Parameters entity = mappingContext.getRequiredPersistentEntity(domainClass); - - - return new MappingCassandraEntityInformation<>((CassandraPersistentEntity) entity, - operations.getConverter()); + return new MappingCassandraEntityInformation<>((CassandraPersistentEntity) entity, operations.getConverter()); } /* diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/IdInterfaceValidator.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/IdInterfaceValidator.java index a256e321e..74ffef744 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/IdInterfaceValidator.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/IdInterfaceValidator.java @@ -67,8 +67,8 @@ public class IdInterfaceValidator { } Class[] interfaces = id.getInterfaces(); - if (interfaces.length > 2 - || ((interfaces.length == 1 && !(interfaces[0].equals(Serializable.class) || interfaces[0].equals(MapId.class))))) { + if (interfaces.length > 2 || ((interfaces.length == 1 + && !(interfaces[0].equals(Serializable.class) || interfaces[0].equals(MapId.class))))) { x.add(new IdInterfaceException(id, null, "id type may only extend Serializable and/or MapId")); } diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepository.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepository.java index 484393757..19a28629a 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepository.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/support/SimpleCassandraRepository.java @@ -75,7 +75,8 @@ public class SimpleCassandraRepository implements Ty @Override public List save(Iterable entities) { - Assert.notNull(entities, "The given Iterable of entities must not be null");List result = new ArrayList<>(); + Assert.notNull(entities, "The given Iterable of entities must not be null"); + List result = new ArrayList<>(); for (S entity : entities) { S saved; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java index 90aca39cb..4139e3b43 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/config/SchemaActionIntegrationTests.java @@ -130,7 +130,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg assertHasTableWithColumns(session, "person", "firstName", "lastName", "nickname", "birthDate", "numberOfChildren", "cool", "createdDate", "zoneId", "mainAddress", "alternativeAddresses"); return null; - }); + }); } @Test @@ -139,7 +139,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg (SessionCallback) session -> { assertHasTableWithColumns(session, "person", "id", "firstName", "lastName"); return null; - }); + }); } @Test @@ -149,7 +149,7 @@ public class SchemaActionIntegrationTests extends AbstractEmbeddedCassandraInteg assertHasTableWithColumns(session, "person", "firstName", "lastName", "nickname", "birthDate", "numberOfChildren", "cool", "createdDate", "zoneId", "mainAddress", "alternativeAddresses"); return null; - }); + }); } @Configuration diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java index f10bf21af..5ac9159e0 100644 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/CassandraPersistentEntitySchemaCreatorUnitTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.cassandra.core; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.matches; import static org.mockito.Mockito.*; import java.util.List; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java index 190c87552..6fbd72526 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/BasicCassandraPersistentEntityUnitTests.java @@ -16,7 +16,7 @@ package org.springframework.data.cassandra.mapping; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.*; import java.lang.annotation.ElementType; diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java index 78ebfd685..33099d5be 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/mapping/ForceQuotedPropertiesSimpleUnitTests.java @@ -112,8 +112,7 @@ public class ForceQuotedPropertiesSimpleUnitTests { assertThat(stringZero.getColumnName().toCql()).isEqualTo("\"stringZero\""); assertThat(stringOne.getColumnName().toCql()).isEqualTo("\"stringOne\""); - List names = Arrays - .asList(quotedCqlId("stringZero"), quotedCqlId("stringOne")); + List names = Arrays.asList(quotedCqlId("stringZero"), quotedCqlId("stringOne")); CassandraPersistentEntity entity = context.getRequiredPersistentEntity(ImplicitComposite.class); assertThat(entity.getRequiredPersistentProperty("primaryKey").getColumnNames()).isEqualTo(names); @@ -189,8 +188,7 @@ public class ForceQuotedPropertiesSimpleUnitTests { assertThat(stringZero.getColumnName().toCql()).isEqualTo("\"" + EXPLICIT_KEY_0 + "\""); assertThat(stringOne.getColumnName().toCql()).isEqualTo("\"" + EXPLICIT_KEY_1 + "\""); - List names = Arrays - .asList(quotedCqlId(EXPLICIT_KEY_0), quotedCqlId(EXPLICIT_KEY_1)); + List names = Arrays.asList(quotedCqlId(EXPLICIT_KEY_0), quotedCqlId(EXPLICIT_KEY_1)); CassandraPersistentEntity entity = context.getRequiredPersistentEntity(ExplicitComposite.class); assertThat(entity.getRequiredPersistentProperty("primaryKey").getColumnNames()).isEqualTo(names); diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraParametersParameterAccessorUnitTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraParametersParameterAccessorUnitTests.java index 76292be44..01ffcff1c 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraParametersParameterAccessorUnitTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/query/CassandraParametersParameterAccessorUnitTests.java @@ -84,8 +84,7 @@ public class CassandraParametersParameterAccessorUnitTests { public void returnTypeForAnnotatedParameterWhenUsingStringValue() throws Exception { Method method = PossibleRepository.class.getMethod("findByAnnotatedObject", Object.class); - CassandraParameterAccessor accessor = new CassandraParametersParameterAccessor(getCassandraQueryMethod(method), - ""); + CassandraParameterAccessor accessor = new CassandraParametersParameterAccessor(getCassandraQueryMethod(method), ""); assertThat(accessor.getDataType(0)).isEqualTo(DataType.date()); } @@ -94,8 +93,7 @@ public class CassandraParametersParameterAccessorUnitTests { public void returnTypeForAnnotatedParameterWhenUsingNullValue() throws Exception { Method method = PossibleRepository.class.getMethod("findByAnnotatedObject", Object.class); - CassandraParameterAccessor accessor = new CassandraParametersParameterAccessor(getCassandraQueryMethod(method), - ""); + CassandraParameterAccessor accessor = new CassandraParametersParameterAccessor(getCassandraQueryMethod(method), ""); assertThat(accessor.getDataType(0)).isEqualTo(DataType.date()); } diff --git a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java index 92ed6cc56..4a8425bc1 100755 --- a/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java +++ b/spring-data-cassandra/src/test/java/org/springframework/data/cassandra/test/integration/repository/querymethods/declared/QueryIntegrationTests.java @@ -306,7 +306,7 @@ public abstract class QueryIntegrationTests extends AbstractSpringDataEmbeddedCa @Test // DATACASS-297 public void streamShouldReturnEntities() { - + long before = personRepository.count(); for (int i = 0; i < 100; i++) { diff --git a/spring-data-cassandra/src/test/java/reactor/test/TestSubscriber.java b/spring-data-cassandra/src/test/java/reactor/test/TestSubscriber.java index 9f7884492..d7ba663dd 100644 --- a/spring-data-cassandra/src/test/java/reactor/test/TestSubscriber.java +++ b/spring-data-cassandra/src/test/java/reactor/test/TestSubscriber.java @@ -41,8 +41,6 @@ import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; - - /** *

  *  ###############################################################
@@ -57,33 +55,30 @@ import org.reactivestreams.Subscription;
  *  ###############################################################
  * 
* - * - * A Subscriber implementation that hosts assertion tests for its state and allows - * asynchronous cancellation and requesting. - * - *

To create a new instance of {@link TestSubscriber}, you have the choice between - * these static methods: + * A Subscriber implementation that hosts assertion tests for its state and allows asynchronous cancellation and + * requesting. + *

+ * To create a new instance of {@link TestSubscriber}, you have the choice between these static methods: *

    - *
  • {@link TestSubscriber#subscribe(Publisher)}: create a new {@link TestSubscriber}, - * subscribe to it with the specified {@link Publisher} and requests an unbounded - * number of elements.
  • - *
  • {@link TestSubscriber#subscribe(Publisher, long)}: create a new {@link TestSubscriber}, - * subscribe to it with the specified {@link Publisher} and requests {@code n} elements - * (can be 0 if you want no initial demand). - *
  • {@link TestSubscriber#create()}: create a new {@link TestSubscriber} and requests - * an unbounded number of elements.
  • - *
  • {@link TestSubscriber#create(long)}: create a new {@link TestSubscriber} and - * requests {@code n} elements (can be 0 if you want no initial demand). + *
  • {@link TestSubscriber#subscribe(Publisher)}: create a new {@link TestSubscriber}, subscribe to it with the + * specified {@link Publisher} and requests an unbounded number of elements.
  • + *
  • {@link TestSubscriber#subscribe(Publisher, long)}: create a new {@link TestSubscriber}, subscribe to it with the + * specified {@link Publisher} and requests {@code n} elements (can be 0 if you want no initial demand). + *
  • {@link TestSubscriber#create()}: create a new {@link TestSubscriber} and requests an unbounded number of + * elements.
  • + *
  • {@link TestSubscriber#create(long)}: create a new {@link TestSubscriber} and requests {@code n} elements (can be + * 0 if you want no initial demand). *
+ *

+ * If you are testing asynchronous publishers, don't forget to use one of the {@code await*()} methods to wait for the + * data to assert. + *

+ * You can extend this class but only the onNext, onError and onComplete can be overridden. You can call + * {@link #request(long)} and {@link #cancel()} from any thread or from within the overridable methods but you should + * avoid calling the assertXXX methods asynchronously. + *

+ * Usage: * - *

If you are testing asynchronous publishers, don't forget to use one of the - * {@code await*()} methods to wait for the data to assert. - * - *

You can extend this class but only the onNext, onError and onComplete can be overridden. - * You can call {@link #request(long)} and {@link #cancel()} from any thread or from within - * the overridable methods but you should avoid calling the assertXXX methods asynchronously. - * - *

Usage: *

  * {@code
  * TestSubscriber
@@ -94,34 +89,27 @@ import org.reactivestreams.Subscription;
  * 
* * @param the value type. - * * @author Sebastien Deleuze * @author David Karnok * @author Anatoly Kadyshev * @author Stephane Maldini * @author Brian Clozel */ -public class TestSubscriber - implements Subscriber, Subscription, Trackable, Receiver { +public class TestSubscriber implements Subscriber, Subscription, Trackable, Receiver { /** * Default timeout for waiting next values to be received */ public static final Duration DEFAULT_VALUES_TIMEOUT = Duration.ofSeconds(3); - @SuppressWarnings("rawtypes") - private static final AtomicLongFieldUpdater REQUESTED = - AtomicLongFieldUpdater.newUpdater(TestSubscriber.class, "requested"); + @SuppressWarnings("rawtypes") private static final AtomicLongFieldUpdater REQUESTED = AtomicLongFieldUpdater + .newUpdater(TestSubscriber.class, "requested"); - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater NEXT_VALUES = - AtomicReferenceFieldUpdater.newUpdater(TestSubscriber.class, List.class, - "values"); - - @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater S = - AtomicReferenceFieldUpdater.newUpdater(TestSubscriber.class, Subscription.class, "s"); + @SuppressWarnings("rawtypes") private static final AtomicReferenceFieldUpdater NEXT_VALUES = AtomicReferenceFieldUpdater + .newUpdater(TestSubscriber.class, List.class, "values"); + @SuppressWarnings("rawtypes") private static final AtomicReferenceFieldUpdater S = AtomicReferenceFieldUpdater + .newUpdater(TestSubscriber.class, Subscription.class, "s"); private final List errors = new LinkedList<>(); @@ -160,23 +148,20 @@ public class TestSubscriber private boolean valuesStorage = true; -// ============================================================================================================== -// Static methods -// ============================================================================================================== + // ============================================================================================================== + // Static methods + // ============================================================================================================== /** - * Blocking method that waits until {@code conditionSupplier} returns true, or if it - * does not before the specified timeout, throws an {@link AssertionError} with the - * specified error message supplier. + * Blocking method that waits until {@code conditionSupplier} returns true, or if it does not before the specified + * timeout, throws an {@link AssertionError} with the specified error message supplier. * * @param timeout the timeout duration * @param errorMessageSupplier the error message supplier * @param conditionSupplier condition to break out of the wait loop - * * @throws AssertionError */ - public static void await(Duration timeout, Supplier errorMessageSupplier, - BooleanSupplier conditionSupplier) { + public static void await(Duration timeout, Supplier errorMessageSupplier, BooleanSupplier conditionSupplier) { Objects.requireNonNull(errorMessageSupplier); Objects.requireNonNull(conditionSupplier); @@ -190,30 +175,24 @@ public class TestSubscriber } try { Thread.sleep(100); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } - } - while (System.nanoTime() - startTime < timeoutNs); + } while (System.nanoTime() - startTime < timeoutNs); throw new AssertionError(errorMessageSupplier.get()); } /** - * Blocking method that waits until {@code conditionSupplier} returns true, or if it - * does not before the specified timeout, throw an {@link AssertionError} with the - * specified error message. + * Blocking method that waits until {@code conditionSupplier} returns true, or if it does not before the specified + * timeout, throw an {@link AssertionError} with the specified error message. * * @param timeout the timeout duration * @param errorMessage the error message * @param conditionSupplier condition to break out of the wait loop - * * @throws AssertionError */ - public static void await(Duration timeout, - final String errorMessage, - BooleanSupplier conditionSupplier) { + public static void await(Duration timeout, final String errorMessage, BooleanSupplier conditionSupplier) { await(timeout, new Supplier() { @Override public String get() { @@ -224,8 +203,10 @@ public class TestSubscriber /** * Create a new {@link TestSubscriber} that requests an unbounded number of elements. - *

Be sure at least a publisher has subscribed to it via {@link Publisher#subscribe(Subscriber)} - * before use assert methods. + *

+ * Be sure at least a publisher has subscribed to it via {@link Publisher#subscribe(Subscriber)} before use assert + * methods. + * * @see #subscribe(Publisher) * @param the observed value type * @return a fresh TestSubscriber instance @@ -235,25 +216,28 @@ public class TestSubscriber } /** - * Create a new {@link TestSubscriber} that requests initially {@code n} elements. You - * can then manage the demand with {@link Subscription#request(long)}. - *

Be sure at least a publisher has subscribed to it via {@link Publisher#subscribe(Subscriber)} - * before use assert methods. + * Create a new {@link TestSubscriber} that requests initially {@code n} elements. You can then manage the demand with + * {@link Subscription#request(long)}. + *

+ * Be sure at least a publisher has subscribed to it via {@link Publisher#subscribe(Subscriber)} before use assert + * methods. + * * @param n Number of elements to request (can be 0 if you want no initial demand). * @see #subscribe(Publisher, long) - * @param the observed value type - * @return a fresh TestSubscriber instance + * @param the observed value type + * @return a fresh TestSubscriber instance */ public static TestSubscriber create(long n) { return new TestSubscriber<>(n); } /** - * Create a new {@link TestSubscriber} that requests an unbounded number of elements, - * and make the specified {@code publisher} subscribe to it. + * Create a new {@link TestSubscriber} that requests an unbounded number of elements, and make the specified + * {@code publisher} subscribe to it. + * * @param publisher The publisher to subscribe with - * @param the observed value type - * @return a fresh TestSubscriber instance + * @param the observed value type + * @return a fresh TestSubscriber instance */ public static TestSubscriber subscribe(Publisher publisher) { TestSubscriber subscriber = new TestSubscriber<>(); @@ -262,13 +246,13 @@ public class TestSubscriber } /** - * Create a new {@link TestSubscriber} that requests initially {@code n} elements, - * and make the specified {@code publisher} subscribe to it. You can then manage the - * demand with {@link Subscription#request(long)}. + * Create a new {@link TestSubscriber} that requests initially {@code n} elements, and make the specified + * {@code publisher} subscribe to it. You can then manage the demand with {@link Subscription#request(long)}. + * * @param publisher The publisher to subscribe with * @param n Number of elements to request (can be 0 if you want no initial demand). - * @param the observed value type - * @return a fresh TestSubscriber instance + * @param the observed value type + * @return a fresh TestSubscriber instance */ public static TestSubscriber subscribe(Publisher publisher, long n) { TestSubscriber subscriber = new TestSubscriber<>(n); @@ -276,12 +260,12 @@ public class TestSubscriber return subscriber; } -// ============================================================================================================== -// Private constructors -// ============================================================================================================== + // ============================================================================================================== + // Private constructors + // ============================================================================================================== private TestSubscriber() { - this(Long.MAX_VALUE); + this(Long.MAX_VALUE); } private TestSubscriber(long n) { @@ -291,15 +275,14 @@ public class TestSubscriber REQUESTED.lazySet(this, n); } -// ============================================================================================================== -// Configuration -// ============================================================================================================== - + // ============================================================================================================== + // Configuration + // ============================================================================================================== /** - * Enable or disabled the values storage. It is enabled by default, and can be disable - * in order to be able to perform performance benchmarks or tests with a huge amount - * values. + * Enable or disabled the values storage. It is enabled by default, and can be disable in order to be able to perform + * performance benchmarks or tests with a huge amount values. + * * @param enabled enable value storage? * @return this */ @@ -309,8 +292,8 @@ public class TestSubscriber } /** - * Configure the timeout in seconds for waiting next values to be received (3 seconds - * by default). + * Configure the timeout in seconds for waiting next values to be received (3 seconds by default). + * * @param timeout the new default value timeout duration * @return this */ @@ -328,12 +311,13 @@ public class TestSubscriber return establishedFusionMode; } -// ============================================================================================================== -// Assertions -// ============================================================================================================== + // ============================================================================================================== + // Assertions + // ============================================================================================================== /** * Assert a complete successfully signal has been received. + * * @return this */ public final TestSubscriber assertComplete() { @@ -349,16 +333,15 @@ public class TestSubscriber } /** - * Assert the specified values have been received. Values storage should be enabled to - * use this method. + * Assert the specified values have been received. Values storage should be enabled to use this method. + * * @param expectedValues the values to assert * @see #configureValuesStorage(boolean) * @return this */ public final TestSubscriber assertContainValues(Set expectedValues) { if (!valuesStorage) { - throw new IllegalStateException( - "Using assertNoValues() requires enabling values storage"); + throw new IllegalStateException("Using assertNoValues() requires enabling values storage"); } if (expectedValues.size() > values.size()) { throw new AssertionError("Actual contains fewer elements" + values, null); @@ -366,17 +349,15 @@ public class TestSubscriber Iterator expected = expectedValues.iterator(); - for (; ; ) { + for (;;) { boolean n2 = expected.hasNext(); if (n2) { T t2 = expected.next(); if (!values.contains(t2)) { - throw new AssertionError("The element is not contained in the " + - "received resuls" + - " = " + valueAndClass(t2), null); + throw new AssertionError( + "The element is not contained in the " + "received resuls" + " = " + valueAndClass(t2), null); } - } - else{ + } else { break; } } @@ -385,6 +366,7 @@ public class TestSubscriber /** * Assert an error signal has been received. + * * @return this */ public final TestSubscriber assertError() { @@ -401,20 +383,20 @@ public class TestSubscriber /** * Assert an error signal has been received. + * * @param clazz The class of the exception contained in the error signal * @return this */ public final TestSubscriber assertError(Class clazz) { assertNotComplete(); - int s = errors.size(); + int s = errors.size(); if (s == 0) { throw new AssertionError("No error", null); } if (s == 1) { Throwable e = errors.get(0); if (!clazz.isInstance(e)) { - throw new AssertionError("Error class incompatible: expected = " + - clazz + ", actual = " + e, null); + throw new AssertionError("Error class incompatible: expected = " + clazz + ", actual = " + e, null); } } if (s > 1) { @@ -430,11 +412,10 @@ public class TestSubscriber assertionError("No error", null); } if (s == 1) { - if (!Objects.equals(message, - errors.get(0) - .getMessage())) { - assertionError("Error class incompatible: expected = \"" + message + - "\", actual = \"" + errors.get(0).getMessage() + "\"", null); + if (!Objects.equals(message, errors.get(0).getMessage())) { + assertionError( + "Error class incompatible: expected = \"" + message + "\", actual = \"" + errors.get(0).getMessage() + "\"", + null); } } if (s > 1) { @@ -446,8 +427,9 @@ public class TestSubscriber /** * Assert an error signal has been received. - * @param expectation A method that can verify the exception contained in the error signal - * and throw an exception (like an {@link AssertionError}) if the exception is not valid. + * + * @param expectation A method that can verify the exception contained in the error signal and throw an exception + * (like an {@link AssertionError}) if the exception is not valid. * @return this */ public final TestSubscriber assertErrorWith(Consumer expectation) { @@ -491,8 +473,8 @@ public class TestSubscriber public final TestSubscriber assertFusionMode(int expectedMode) { if (establishedFusionMode != expectedMode) { - throw new AssertionError("Wrong fusion mode: expected: " + fusionModeName( - expectedMode) + ", actual: " + fusionModeName(establishedFusionMode)); + throw new AssertionError("Wrong fusion mode: expected: " + fusionModeName(expectedMode) + ", actual: " + + fusionModeName(establishedFusionMode)); } return this; } @@ -511,7 +493,8 @@ public class TestSubscriber /** * Assert no error signal has been received. - * @return this + * + * @return this */ public final TestSubscriber assertNoError() { int s = errors.size(); @@ -533,14 +516,14 @@ public class TestSubscriber */ public final TestSubscriber assertNoValues() { if (valueCount != 0) { - throw new AssertionError("No values expected but received: [length = " + values.size() + "] " + values, - null); + throw new AssertionError("No values expected but received: [length = " + values.size() + "] " + values, null); } return this; } /** * Assert that the upstream was not a Fuseable source. + * * @return this */ public final TestSubscriber assertNonFuseableSource() { @@ -552,6 +535,7 @@ public class TestSubscriber /** * Assert no complete successfully signal has been received. + * * @return this */ public final TestSubscriber assertNotComplete() { @@ -585,6 +569,7 @@ public class TestSubscriber /** * Assert no complete successfully or error signal has been received. + * * @return this */ public final TestSubscriber assertNotTerminated() { @@ -596,6 +581,7 @@ public class TestSubscriber /** * Assert subscription occurred (once). + * * @return this */ public final TestSubscriber assertSubscribed() { @@ -613,6 +599,7 @@ public class TestSubscriber /** * Assert either complete successfully or error signal has been received. + * * @return this */ public final TestSubscriber assertTerminated() { @@ -626,25 +613,22 @@ public class TestSubscriber * Assert {@code n} values has been received. * * @param n the expected value count - * * @return this */ public final TestSubscriber assertValueCount(long n) { if (valueCount != n) { - throw new AssertionError("Different value count: expected = " + n + ", actual = " + valueCount, - null); + throw new AssertionError("Different value count: expected = " + n + ", actual = " + valueCount, null); } return this; } /** - * Assert the specified values have been received in the same order read by the - * passed {@link Iterable}. Values storage - * should be enabled to - * use this method. + * Assert the specified values have been received in the same order read by the passed {@link Iterable}. Values + * storage should be enabled to use this method. + * * @param expectedSequence the values to assert * @see #configureValuesStorage(boolean) - * @return this + * @return this */ public final TestSubscriber assertValueSequence(Iterable expectedSequence) { if (!valuesStorage) { @@ -653,16 +637,15 @@ public class TestSubscriber Iterator actual = values.iterator(); Iterator expected = expectedSequence.iterator(); int i = 0; - for (; ; ) { + for (;;) { boolean n1 = actual.hasNext(); boolean n2 = expected.hasNext(); if (n1 && n2) { T t1 = actual.next(); T t2 = expected.next(); if (!Objects.equals(t1, t2)) { - throw new AssertionError("The element with index " + i + " does not match: expected = " + valueAndClass(t2) + ", actual = " - + valueAndClass( - t1), null); + throw new AssertionError("The element with index " + i + " does not match: expected = " + valueAndClass(t2) + + ", actual = " + valueAndClass(t1), null); } i++; } else if (n1 && !n2) { @@ -677,13 +660,11 @@ public class TestSubscriber } /** - * Assert the specified values have been received in the declared order. Values - * storage should be enabled to use this method. + * Assert the specified values have been received in the declared order. Values storage should be enabled to use this + * method. * * @param expectedValues the values to assert - * * @return this - * * @see #configureValuesStorage(boolean) */ @SafeVarargs @@ -692,25 +673,23 @@ public class TestSubscriber } /** - * Assert the specified values have been received in the declared order. Values - * storage should be enabled to use this method. - * - * @param expectations One or more methods that can verify the values and throw a - * exception (like an {@link AssertionError}) if the value is not valid. + * Assert the specified values have been received in the declared order. Values storage should be enabled to use this + * method. * + * @param expectations One or more methods that can verify the values and throw a exception (like an + * {@link AssertionError}) if the value is not valid. * @return this - * * @see #configureValuesStorage(boolean) */ @SafeVarargs public final TestSubscriber assertValuesWith(Consumer... expectations) { if (!valuesStorage) { - throw new IllegalStateException( - "Using assertNoValues() requires enabling values storage"); + throw new IllegalStateException("Using assertNoValues() requires enabling values storage"); } final int expectedValueCount = expectations.length; if (expectedValueCount != values.size()) { - throw new AssertionError("Different value count: expected = " + expectedValueCount + ", actual = " + valueCount, null); + throw new AssertionError("Different value count: expected = " + expectedValueCount + ", actual = " + valueCount, + null); } for (int i = 0; i < expectedValueCount; i++) { Consumer consumer = expectations[i]; @@ -720,13 +699,14 @@ public class TestSubscriber return this; } -// ============================================================================================================== -// Await methods -// ============================================================================================================== + // ============================================================================================================== + // Await methods + // ============================================================================================================== /** * Blocking method that waits until a complete successfully or error signal is received. - * @return this + * + * @return this */ public final TestSubscriber await() { if (cdl.getCount() == 0) { @@ -741,10 +721,10 @@ public class TestSubscriber } /** - * Blocking method that waits until a complete successfully or error signal is received - * or until a timeout occurs. + * Blocking method that waits until a complete successfully or error signal is received or until a timeout occurs. + * * @param timeout The timeout value - * @return this + * @return this */ public final TestSubscriber await(Duration timeout) { if (cdl.getCount() == 0) { @@ -755,8 +735,7 @@ public class TestSubscriber throw new AssertionError("No complete or error signal before timeout"); } return this; - } - catch (InterruptedException ex) { + } catch (InterruptedException ex) { throw new AssertionError("Wait interrupted", ex); } } @@ -765,23 +744,15 @@ public class TestSubscriber * Blocking method that waits until {@code n} next values have been received. * * @param n the value count to assert - * * @return this */ public final TestSubscriber awaitAndAssertNextValueCount(final long n) { await(valuesTimeout, () -> { - if(valuesStorage){ - return String.format("%d out of %d next values received within %d, " + - "values : %s", - valueCount - nextValueAssertedCount, - n, - valuesTimeout.toMillis(), - values.toString() - ); + if (valuesStorage) { + return String.format("%d out of %d next values received within %d, " + "values : %s", + valueCount - nextValueAssertedCount, n, valuesTimeout.toMillis(), values.toString()); } - return String.format("%d out of %d next values received within %d", - valueCount - nextValueAssertedCount, - n, + return String.format("%d out of %d next values received within %d", valueCount - nextValueAssertedCount, n, valuesTimeout.toMillis()); }, () -> valueCount >= (nextValueAssertedCount + n)); nextValueAssertedCount += n; @@ -789,11 +760,10 @@ public class TestSubscriber } /** - * Blocking method that waits until {@code n} next values have been received (n is the - * number of values provided) to assert them. + * Blocking method that waits until {@code n} next values have been received (n is the number of values provided) to + * assert them. * * @param values the values to assert - * * @return this */ @SafeVarargs @@ -805,10 +775,7 @@ public class TestSubscriber final T expectedValue = values[i]; expectations.add(actualValue -> { if (!actualValue.equals(expectedValue)) { - throw new AssertionError(String.format( - "Expected Next signal: %s, but got: %s", - expectedValue, - actualValue)); + throw new AssertionError(String.format("Expected Next signal: %s, but got: %s", expectedValue, actualValue)); } }); } @@ -817,42 +784,35 @@ public class TestSubscriber } /** - * Blocking method that waits until {@code n} next values have been received - * (n is the number of expectations provided) to assert them. - * @param expectations One or more methods that can verify the values and throw a - * exception (like an {@link AssertionError}) if the value is not valid. - * @return this + * Blocking method that waits until {@code n} next values have been received (n is the number of expectations + * provided) to assert them. + * + * @param expectations One or more methods that can verify the values and throw a exception (like an + * {@link AssertionError}) if the value is not valid. + * @return this */ @SafeVarargs public final TestSubscriber awaitAndAssertNextValuesWith(Consumer... expectations) { valuesStorage = true; final int expectedValueCount = expectations.length; await(valuesTimeout, () -> { - if(valuesStorage){ - return String.format("%d out of %d next values received within %d, " + - "values : %s", - valueCount - nextValueAssertedCount, - expectedValueCount, - valuesTimeout.toMillis(), - values.toString() - ); + if (valuesStorage) { + return String.format("%d out of %d next values received within %d, " + "values : %s", + valueCount - nextValueAssertedCount, expectedValueCount, valuesTimeout.toMillis(), values.toString()); } - return String.format("%d out of %d next values received within %d ms", - valueCount - nextValueAssertedCount, - expectedValueCount, - valuesTimeout.toMillis()); + return String.format("%d out of %d next values received within %d ms", valueCount - nextValueAssertedCount, + expectedValueCount, valuesTimeout.toMillis()); }, () -> valueCount >= (nextValueAssertedCount + expectedValueCount)); List nextValuesSnapshot; List empty = new ArrayList<>(); - for(;;){ + for (;;) { nextValuesSnapshot = values; - if(NEXT_VALUES.compareAndSet(this, values, empty)){ + if (NEXT_VALUES.compareAndSet(this, values, empty)) { break; } } if (nextValuesSnapshot.size() < expectedValueCount) { - throw new AssertionError(String.format("Expected %d number of signals but received %d", - expectedValueCount, + throw new AssertionError(String.format("Expected %d number of signals but received %d", expectedValueCount, nextValuesSnapshot.size())); } for (int i = 0; i < expectedValueCount; i++) { @@ -864,9 +824,9 @@ public class TestSubscriber return this; } -// ============================================================================================================== -// Overrides -// ============================================================================================================== + // ============================================================================================================== + // Overrides + // ============================================================================================================== @Override public void cancel() { @@ -909,7 +869,7 @@ public class TestSubscriber @Override public void onNext(T t) { if (establishedFusionMode == Fuseable.ASYNC) { - for (; ; ) { + for (;;) { t = qs.poll(); if (t == null) { break; @@ -917,28 +877,23 @@ public class TestSubscriber valueCount++; if (valuesStorage) { List nextValuesSnapshot; - for (; ; ) { + for (;;) { nextValuesSnapshot = values; nextValuesSnapshot.add(t); - if (NEXT_VALUES.compareAndSet(this, - nextValuesSnapshot, - nextValuesSnapshot)) { + if (NEXT_VALUES.compareAndSet(this, nextValuesSnapshot, nextValuesSnapshot)) { break; } } } } - } - else { + } else { valueCount++; if (valuesStorage) { List nextValuesSnapshot; - for (; ; ) { + for (;;) { nextValuesSnapshot = values; nextValuesSnapshot.add(t); - if (NEXT_VALUES.compareAndSet(this, - nextValuesSnapshot, - nextValuesSnapshot)) { + if (NEXT_VALUES.compareAndSet(this, nextValuesSnapshot, nextValuesSnapshot)) { break; } } @@ -954,12 +909,11 @@ public class TestSubscriber if (requestMode >= 0) { if (!setWithoutRequesting(s)) { if (!isCancelled()) { - errors.add(new IllegalStateException("Subscription already set: " + - subscriptionCount)); + errors.add(new IllegalStateException("Subscription already set: " + subscriptionCount)); } } else { if (s instanceof Fuseable.QueueSubscription) { - this.qs = (Fuseable.QueueSubscription)s; + this.qs = (Fuseable.QueueSubscription) s; int m = qs.requestFusion(requestMode); establishedFusionMode = m; @@ -974,20 +928,17 @@ public class TestSubscriber onNext(v); } - } - else { + } else { requestDeferred(); } - } - else { + } else { requestDeferred(); } } } else { if (!set(s)) { if (!isCancelled()) { - errors.add(new IllegalStateException("Subscription already set: " + - subscriptionCount)); + errors.add(new IllegalStateException("Subscription already set: " + subscriptionCount)); } } } @@ -1008,8 +959,8 @@ public class TestSubscriber } /** - * Setup what fusion mode should be requested from the incomining - * Subscription if it happens to be QueueSubscription + * Setup what fusion mode should be requested from the incomining Subscription if it happens to be QueueSubscription + * * @param requestMode the mode to request, see Fuseable constants * @return this */ @@ -1023,10 +974,9 @@ public class TestSubscriber return s; } - -// ============================================================================================================== -// Non public methods -// ============================================================================================================== + // ============================================================================================================== + // Non public methods + // ============================================================================================================== protected final void normalRequest(long n) { Subscription a = s; @@ -1101,6 +1051,7 @@ public class TestSubscriber /** * Sets the Subscription once but does not request anything. + * * @param s the Subscription to set * @return true if successful, false if the current subscription is not null */ @@ -1125,12 +1076,11 @@ public class TestSubscriber } /** - * Prepares and throws an AssertionError exception based on the message, cause, the - * active state and the potential errors so far. + * Prepares and throws an AssertionError exception based on the message, cause, the active state and the potential + * errors so far. * * @param message the message * @param cause the optional Throwable cause - * * @throws AssertionError as expected */ protected final void assertionError(String message, Throwable cause) { @@ -1143,9 +1093,7 @@ public class TestSubscriber List err = errors; if (!err.isEmpty()) { - b.append(" (+ ") - .append(err.size()) - .append(" errors)"); + b.append(" (+ ").append(err.size()).append(" errors)"); } AssertionError e = new AssertionError(b.toString(), cause);