DATACASS-663 - Replace StepVerifier.create(…) style with .as(StepVerifier::create) style.
This commit is contained in:
@@ -149,8 +149,8 @@ public abstract class AbstractCassandraConfiguration extends AbstractClusterConf
|
||||
|
||||
UserTypeResolver userTypeResolver = new SimpleUserTypeResolver(cluster, getKeyspaceName());
|
||||
|
||||
CassandraMappingContext mappingContext =
|
||||
new CassandraMappingContext(userTypeResolver, new SimpleTupleTypeFactory(cluster));
|
||||
CassandraMappingContext mappingContext = new CassandraMappingContext(userTypeResolver,
|
||||
new SimpleTupleTypeFactory(cluster));
|
||||
|
||||
Optional.ofNullable(this.beanClassLoader).ifPresent(mappingContext::setBeanClassLoader);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
@@ -48,20 +49,9 @@ import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.datastax.driver.core.AuthProvider;
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.*;
|
||||
import com.datastax.driver.core.Cluster.Builder;
|
||||
import com.datastax.driver.core.Host;
|
||||
import com.datastax.driver.core.LatencyTracker;
|
||||
import com.datastax.driver.core.NettyOptions;
|
||||
import com.datastax.driver.core.PoolingOptions;
|
||||
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.Session;
|
||||
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.LoadBalancingPolicy;
|
||||
import com.datastax.driver.core.policies.ReconnectionPolicy;
|
||||
@@ -186,8 +176,7 @@ public class CassandraClusterFactoryBean
|
||||
|
||||
Builder clusterBuilder = newClusterBuilder()
|
||||
.addContactPoints(StringUtils.commaDelimitedListToStringArray(this.contactPoints))
|
||||
.withMaxSchemaAgreementWaitSeconds(this.maxSchemaAgreementWaitSeconds)
|
||||
.withPort(this.port);
|
||||
.withMaxSchemaAgreementWaitSeconds(this.maxSchemaAgreementWaitSeconds).withPort(this.port);
|
||||
|
||||
Optional.ofNullable(this.addressTranslator).ifPresent(clusterBuilder::withAddressTranslator);
|
||||
Optional.ofNullable(this.loadBalancingPolicy).ifPresent(clusterBuilder::withLoadBalancingPolicy);
|
||||
@@ -201,15 +190,12 @@ public class CassandraClusterFactoryBean
|
||||
Optional.ofNullable(this.speculativeExecutionPolicy).ifPresent(clusterBuilder::withSpeculativeExecutionPolicy);
|
||||
Optional.ofNullable(this.timestampGenerator).ifPresent(clusterBuilder::withTimestampGenerator);
|
||||
|
||||
Optional.ofNullable(this.authProvider)
|
||||
.map(clusterBuilder::withAuthProvider)
|
||||
.orElseGet(() -> StringUtils.hasText(this.username)
|
||||
? clusterBuilder.withCredentials(this.username, this.password)
|
||||
: clusterBuilder);
|
||||
Optional.ofNullable(this.authProvider).map(clusterBuilder::withAuthProvider).orElseGet(
|
||||
() -> StringUtils.hasText(this.username) ? clusterBuilder.withCredentials(this.username, this.password)
|
||||
: clusterBuilder);
|
||||
|
||||
Optional.ofNullable(this.compressionType)
|
||||
.map(CassandraClusterFactoryBean::convertCompressionType)
|
||||
.ifPresent(clusterBuilder::withCompression);
|
||||
Optional.ofNullable(this.compressionType).map(CassandraClusterFactoryBean::convertCompressionType)
|
||||
.ifPresent(clusterBuilder::withCompression);
|
||||
|
||||
if (!this.jmxReportingEnabled) {
|
||||
clusterBuilder.withoutJMXReporting();
|
||||
@@ -220,14 +206,10 @@ public class CassandraClusterFactoryBean
|
||||
}
|
||||
|
||||
if (this.sslEnabled) {
|
||||
Optional.ofNullable(this.sslOptions)
|
||||
.map(clusterBuilder::withSSL)
|
||||
.orElseGet(clusterBuilder::withSSL);
|
||||
Optional.ofNullable(this.sslOptions).map(clusterBuilder::withSSL).orElseGet(clusterBuilder::withSSL);
|
||||
}
|
||||
|
||||
Optional.ofNullable(resolveClusterName())
|
||||
.filter(StringUtils::hasText)
|
||||
.ifPresent(clusterBuilder::withClusterName);
|
||||
Optional.ofNullable(resolveClusterName()).filter(StringUtils::hasText).ifPresent(clusterBuilder::withClusterName);
|
||||
|
||||
if (this.clusterBuilderConfigurer != null) {
|
||||
this.clusterBuilderConfigurer.configure(clusterBuilder);
|
||||
@@ -254,7 +236,8 @@ public class CassandraClusterFactoryBean
|
||||
* (non-Javadoc)
|
||||
* @see com.datastax.driver.core.Cluster#builder()
|
||||
*/
|
||||
@NonNull Cluster.Builder newClusterBuilder() {
|
||||
@NonNull
|
||||
Cluster.Builder newClusterBuilder() {
|
||||
return Cluster.builder();
|
||||
}
|
||||
|
||||
@@ -274,8 +257,8 @@ public class CassandraClusterFactoryBean
|
||||
|
||||
generateSpecificationsFromFactoryBeans();
|
||||
|
||||
List<KeyspaceActionSpecification> startupSpecifications =
|
||||
new ArrayList<>(this.keyspaceCreations.size() + this.keyspaceAlterations.size());
|
||||
List<KeyspaceActionSpecification> startupSpecifications = new ArrayList<>(
|
||||
this.keyspaceCreations.size() + this.keyspaceAlterations.size());
|
||||
|
||||
startupSpecifications.addAll(this.keyspaceCreations);
|
||||
startupSpecifications.addAll(this.keyspaceAlterations);
|
||||
@@ -295,7 +278,7 @@ public class CassandraClusterFactoryBean
|
||||
CqlTemplate template = new CqlTemplate(session);
|
||||
|
||||
keyspaceActionSpecifications
|
||||
.forEach(keyspaceActionSpecification -> template.execute(toCql(keyspaceActionSpecification)));
|
||||
.forEach(keyspaceActionSpecification -> template.execute(toCql(keyspaceActionSpecification)));
|
||||
|
||||
scripts.forEach(template::execute);
|
||||
}
|
||||
@@ -303,8 +286,8 @@ public class CassandraClusterFactoryBean
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the contents of all the KeyspaceSpecificationFactoryBeans
|
||||
* and generates the proper KeyspaceSpecification from them.
|
||||
* Evaluates the contents of all the KeyspaceSpecificationFactoryBeans and generates the proper KeyspaceSpecification
|
||||
* from them.
|
||||
*/
|
||||
private void generateSpecificationsFromFactoryBeans() {
|
||||
|
||||
@@ -318,31 +301,26 @@ public class CassandraClusterFactoryBean
|
||||
|
||||
if (keyspaceActionSpecification instanceof AlterKeyspaceSpecification) {
|
||||
this.keyspaceAlterations.add((AlterKeyspaceSpecification) keyspaceActionSpecification);
|
||||
}
|
||||
else if (keyspaceActionSpecification instanceof CreateKeyspaceSpecification) {
|
||||
} else if (keyspaceActionSpecification instanceof CreateKeyspaceSpecification) {
|
||||
this.keyspaceCreations.add((CreateKeyspaceSpecification) keyspaceActionSpecification);
|
||||
}
|
||||
else if (keyspaceActionSpecification instanceof DropKeyspaceSpecification) {
|
||||
} else if (keyspaceActionSpecification instanceof DropKeyspaceSpecification) {
|
||||
this.keyspaceDrops.add((DropKeyspaceSpecification) keyspaceActionSpecification);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private String toCql(KeyspaceActionSpecification specification) {
|
||||
|
||||
if (specification instanceof AlterKeyspaceSpecification) {
|
||||
return new AlterKeyspaceCqlGenerator((AlterKeyspaceSpecification) specification).toCql();
|
||||
}
|
||||
else if (specification instanceof CreateKeyspaceSpecification) {
|
||||
} else if (specification instanceof CreateKeyspaceSpecification) {
|
||||
return new CreateKeyspaceCqlGenerator((CreateKeyspaceSpecification) specification).toCql();
|
||||
}
|
||||
else if (specification instanceof DropKeyspaceSpecification) {
|
||||
} else if (specification instanceof DropKeyspaceSpecification) {
|
||||
return new DropKeyspaceCqlGenerator((DropKeyspaceSpecification) specification).toCql();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unsupported specification type: "
|
||||
+ ClassUtils.getQualifiedName(specification.getClass()));
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported specification type: " + ClassUtils.getQualifiedName(specification.getClass()));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -698,13 +676,12 @@ public class CassandraClusterFactoryBean
|
||||
|
||||
/**
|
||||
* Sets the {@link ClusterBuilderConfigurer} used to apply additional configuration logic to the
|
||||
* {@link com.datastax.driver.core.Cluster.Builder} object.
|
||||
*
|
||||
* {@link ClusterBuilderConfigurer} is invoked after all provided options are configured. The factory will
|
||||
* {@link Builder#build()} the {@link Cluster} after applying {@link ClusterBuilderConfigurer}.
|
||||
* {@link com.datastax.driver.core.Cluster.Builder} object. {@link ClusterBuilderConfigurer} is invoked after all
|
||||
* provided options are configured. The factory will {@link Builder#build()} the {@link Cluster} after applying
|
||||
* {@link ClusterBuilderConfigurer}.
|
||||
*
|
||||
* @param clusterBuilderConfigurer {@link ClusterBuilderConfigurer} used to configure the
|
||||
* {@link com.datastax.driver.core.Cluster.Builder}.
|
||||
* {@link com.datastax.driver.core.Cluster.Builder}.
|
||||
* @see org.springframework.data.cassandra.config.ClusterBuilderConfigurer
|
||||
*/
|
||||
public void setClusterBuilderConfigurer(@Nullable ClusterBuilderConfigurer clusterBuilderConfigurer) {
|
||||
|
||||
@@ -87,9 +87,7 @@ public class CassandraCqlSessionFactoryBean
|
||||
/* (non-Javadoc) */
|
||||
Session connect(@Nullable String keyspaceName) {
|
||||
|
||||
return StringUtils.hasText(keyspaceName)
|
||||
? getCluster().connect(keyspaceName)
|
||||
: getCluster().connect();
|
||||
return StringUtils.hasText(keyspaceName) ? getCluster().connect(keyspaceName) : getCluster().connect();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -159,13 +159,13 @@ public class CassandraSessionFactoryBean extends CassandraCqlSessionFactoryBean
|
||||
|
||||
private void performSchemaActions(boolean drop, boolean dropUnused, boolean ifNotExists) {
|
||||
|
||||
CassandraPersistentEntitySchemaCreator schemaCreator =
|
||||
new CassandraPersistentEntitySchemaCreator(getMappingContext(), getCassandraAdminOperations());
|
||||
CassandraPersistentEntitySchemaCreator schemaCreator = new CassandraPersistentEntitySchemaCreator(
|
||||
getMappingContext(), getCassandraAdminOperations());
|
||||
|
||||
if (drop) {
|
||||
|
||||
CassandraPersistentEntitySchemaDropper schemaDropper =
|
||||
new CassandraPersistentEntitySchemaDropper(getMappingContext(), getCassandraAdminOperations());
|
||||
CassandraPersistentEntitySchemaDropper schemaDropper = new CassandraPersistentEntitySchemaDropper(
|
||||
getMappingContext(), getCassandraAdminOperations());
|
||||
|
||||
schemaDropper.dropTables(dropUnused);
|
||||
schemaDropper.dropUserTypes(dropUnused);
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
@@ -193,8 +193,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link EntityOperations} used to perform data access operations on an entity
|
||||
* inside a Cassandra data source.
|
||||
* Returns the {@link EntityOperations} used to perform data access operations on an entity inside a Cassandra data
|
||||
* source.
|
||||
*
|
||||
* @return the configured {@link EntityOperations} for this template.
|
||||
* @see org.springframework.data.cassandra.core.EntityOperations
|
||||
@@ -299,7 +299,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
*/
|
||||
@Override
|
||||
public <T> ListenableFuture<Void> select(Statement statement, Consumer<T> entityConsumer, Class<T> entityClass)
|
||||
throws DataAccessException {
|
||||
throws DataAccessException {
|
||||
|
||||
Assert.notNull(statement, "Statement must not be null");
|
||||
Assert.notNull(entityConsumer, "Entity Consumer must not be empty");
|
||||
@@ -360,14 +360,14 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
*/
|
||||
@Override
|
||||
public <T> ListenableFuture<Void> select(Query query, Consumer<T> entityConsumer, Class<T> entityClass)
|
||||
throws DataAccessException {
|
||||
throws DataAccessException {
|
||||
|
||||
Assert.notNull(query, "Query must not be null");
|
||||
Assert.notNull(entityConsumer, "Entity Consumer must not be empty");
|
||||
Assert.notNull(entityClass, "Entity type must not be null");
|
||||
|
||||
return select(getStatementFactory()
|
||||
.select(query, getRequiredPersistentEntity(entityClass)), entityConsumer, entityClass);
|
||||
return select(getStatementFactory().select(query, getRequiredPersistentEntity(entityClass)), entityConsumer,
|
||||
entityClass);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -550,8 +550,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
Insert insert = EntityQueryUtils.createInsertQuery(tableName.toCql(), entityToUse, options, getConverter(),
|
||||
persistentEntity);
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doInsertVersioned(insert.ifNotExists(), entityToUse, source, tableName)
|
||||
return source.isVersionedEntity() ? doInsertVersioned(insert.ifNotExists(), entityToUse, source, tableName)
|
||||
: doInsert(insert, entityToUse, source, tableName);
|
||||
}
|
||||
|
||||
@@ -562,8 +561,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
|
||||
if (!result.wasApplied()) {
|
||||
throw new OptimisticLockingFailureException(
|
||||
String.format("Cannot insert entity %s with version %s into table %s as it already exists",
|
||||
entity, source.getVersion(), tableName));
|
||||
String.format("Cannot insert entity %s with version %s into table %s as it already exists", entity,
|
||||
source.getVersion(), tableName));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -596,8 +595,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
CqlIdentifier tableName = persistentEntity.getTableName();
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doUpdateVersioned(source, options, tableName, persistentEntity)
|
||||
return source.isVersionedEntity() ? doUpdateVersioned(source, options, tableName, persistentEntity)
|
||||
: doUpdate(entity, options, tableName, persistentEntity);
|
||||
}
|
||||
|
||||
@@ -614,8 +612,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
|
||||
if (!result.wasApplied()) {
|
||||
throw new OptimisticLockingFailureException(
|
||||
String.format("Cannot save entity %s with version %s to table %s. Has it been modified meanwhile?",
|
||||
entity, source.getVersion(), tableName));
|
||||
String.format("Cannot save entity %s with version %s to table %s. Has it been modified meanwhile?", entity,
|
||||
source.getVersion(), tableName));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -651,8 +649,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
|
||||
Delete delete = getStatementFactory().delete(entity, options, getConverter(), persistentEntity, tableName);
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doDeleteVersioned(delete, entity, source, tableName)
|
||||
return source.isVersionedEntity() ? doDeleteVersioned(delete, entity, source, tableName)
|
||||
: doDelete(delete, entity, tableName);
|
||||
}
|
||||
|
||||
@@ -722,7 +719,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
private <T> ListenableFuture<EntityWriteResult<T>> executeSave(T entity, CqlIdentifier tableName,
|
||||
Statement statement) {
|
||||
|
||||
return executeSave(entity, tableName, statement, ignore -> { });
|
||||
return executeSave(entity, tableName, statement, ignore -> {});
|
||||
}
|
||||
|
||||
private <T> ListenableFuture<EntityWriteResult<T>> executeSave(T entity, CqlIdentifier tableName, Statement statement,
|
||||
@@ -784,8 +781,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
|
||||
return getAsyncCqlOperations()
|
||||
.execute((AsyncSessionCallback<Integer>) session -> AsyncResult.forValue(getConfiguredFetchSize(session)))
|
||||
.completable()
|
||||
.join();
|
||||
.completable().join();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -49,10 +49,8 @@ public interface CassandraAdminOperations extends CassandraOperations {
|
||||
Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* Drops a table based on the given {@link Class entity type}.
|
||||
*
|
||||
* The name of the table is derived from either the simple name of the {@link Class entity class}
|
||||
* or name of the table specified with the {@link Table} mapping annotation.
|
||||
* Drops a table based on the given {@link Class entity type}. The name of the table is derived from either the simple
|
||||
* name of the {@link Class entity class} or name of the table specified with the {@link Table} mapping annotation.
|
||||
*
|
||||
* @param entityType {@link Class type} of the entity for which the table will be dropped.
|
||||
*/
|
||||
@@ -69,8 +67,7 @@ public interface CassandraAdminOperations extends CassandraOperations {
|
||||
/**
|
||||
* Drops the {@link String named} table.
|
||||
*
|
||||
* @param ifExists If {@literal true}, will only drop the table if it exists,
|
||||
* else the drop operation will be ignored.
|
||||
* @param ifExists If {@literal true}, will only drop the table if it exists, else the drop operation will be ignored.
|
||||
* @param tableName {@link String Name} of the table to drop.
|
||||
* @since 2.1
|
||||
*/
|
||||
|
||||
@@ -103,8 +103,7 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
@Override
|
||||
public void dropTable(boolean ifExists, CqlIdentifier tableName) {
|
||||
|
||||
String dropTableCql =
|
||||
DropTableCqlGenerator.toCql(DropTableSpecification.dropTable(tableName).ifExists(ifExists));
|
||||
String dropTableCql = DropTableCqlGenerator.toCql(DropTableSpecification.dropTable(tableName).ifExists(ifExists));
|
||||
|
||||
getCqlOperations().execute(dropTableCql);
|
||||
}
|
||||
@@ -117,8 +116,7 @@ public class CassandraAdminTemplate extends CassandraTemplate implements Cassand
|
||||
|
||||
Assert.notNull(typeName, "Type name must not be null");
|
||||
|
||||
String dropUserTypeCql =
|
||||
DropUserTypeCqlGenerator.toCql(DropUserTypeSpecification.dropType(typeName));
|
||||
String dropUserTypeCql = DropUserTypeCqlGenerator.toCql(DropUserTypeSpecification.dropType(typeName));
|
||||
|
||||
getCqlOperations().execute(dropUserTypeCql);
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to the configured {@link CassandraConverter} used to map {@link Object Objects}
|
||||
* to {@link com.datastax.driver.core.Row Rows}.
|
||||
* Return a reference to the configured {@link CassandraConverter} used to map {@link Object Objects} to
|
||||
* {@link com.datastax.driver.core.Row Rows}.
|
||||
*
|
||||
* @return a reference to the configured {@link CassandraConverter}.
|
||||
* @see org.springframework.data.cassandra.core.convert.CassandraConverter
|
||||
@@ -83,8 +83,8 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the configured {@link CassandraMappingContext} used to map entities to Cassandra tables
|
||||
* and back.
|
||||
* Returns a reference to the configured {@link CassandraMappingContext} used to map entities to Cassandra tables and
|
||||
* back.
|
||||
*
|
||||
* @return a reference to the configured {@link CassandraMappingContext}.
|
||||
* @see org.springframework.data.cassandra.core.mapping.CassandraMappingContext
|
||||
@@ -94,8 +94,8 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to the configured {@link StatementFactory} used to create Cassandra {@link Statement} objects
|
||||
* to perform data access operations on a Cassandra cluster.
|
||||
* Return a reference to the configured {@link StatementFactory} used to create Cassandra {@link Statement} objects to
|
||||
* perform data access operations on a Cassandra cluster.
|
||||
*
|
||||
* @return a reference to the configured {@link StatementFactory}.
|
||||
* @see org.springframework.data.cassandra.core.StatementFactory
|
||||
@@ -166,11 +166,11 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
|
||||
|
||||
Assert.notNull(entity, "Entity must not be null");
|
||||
|
||||
BasicCassandraPersistentEntity<?> persistentEntity =
|
||||
mappingContext.getRequiredPersistentEntity(entity.getClass());
|
||||
BasicCassandraPersistentEntity<?> persistentEntity = mappingContext
|
||||
.getRequiredPersistentEntity(entity.getClass());
|
||||
|
||||
Insert insertQuery = EntityQueryUtils.createInsertQuery(persistentEntity.getTableName().toCql(),
|
||||
entity, options, getConverter(), persistentEntity);
|
||||
Insert insertQuery = EntityQueryUtils.createInsertQuery(persistentEntity.getTableName().toCql(), entity, options,
|
||||
getConverter(), persistentEntity);
|
||||
|
||||
this.batch.add(insertQuery);
|
||||
}
|
||||
@@ -214,8 +214,8 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
|
||||
Update update = getStatementFactory()
|
||||
.update(entity, options, getConverter(), persistentEntity, persistentEntity.getTableName());
|
||||
Update update = getStatementFactory().update(entity, options, getConverter(), persistentEntity,
|
||||
persistentEntity.getTableName());
|
||||
|
||||
this.batch.add(update);
|
||||
}
|
||||
@@ -259,8 +259,8 @@ class CassandraBatchTemplate implements CassandraBatchOperations {
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
|
||||
Delete delete = getStatementFactory()
|
||||
.delete(entity, options, this.converter, persistentEntity, persistentEntity.getTableName());
|
||||
Delete delete = getStatementFactory().delete(entity, options, this.converter, persistentEntity,
|
||||
persistentEntity.getTableName());
|
||||
|
||||
this.batch.add(delete);
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ public class CassandraPersistentEntitySchemaCreator {
|
||||
*/
|
||||
protected List<CreateUserTypeSpecification> createUserTypeSpecifications(boolean ifNotExists) {
|
||||
|
||||
Collection<? extends CassandraPersistentEntity<?>> entities =
|
||||
new ArrayList<>(this.mappingContext.getUserDefinedTypeEntities());
|
||||
Collection<? extends CassandraPersistentEntity<?>> entities = new ArrayList<>(
|
||||
this.mappingContext.getUserDefinedTypeEntities());
|
||||
|
||||
Map<CqlIdentifier, CassandraPersistentEntity<?>> byTableName = entities.stream()
|
||||
.collect(Collectors.toMap(CassandraPersistentEntity::getTableName, entity -> entity));
|
||||
@@ -166,9 +166,10 @@ public class CassandraPersistentEntitySchemaCreator {
|
||||
|
||||
Collections.reverse(ordered);
|
||||
|
||||
specifications.addAll(ordered.stream().filter(created::add).map(identifier ->
|
||||
this.mappingContext.getCreateUserTypeSpecificationFor(byTableName.get(identifier)).ifNotExists(ifNotExists))
|
||||
.collect(Collectors.toList()));
|
||||
specifications.addAll(ordered
|
||||
.stream().filter(created::add).map(identifier -> this.mappingContext
|
||||
.getCreateUserTypeSpecificationFor(byTableName.get(identifier)).ifNotExists(ifNotExists))
|
||||
.collect(Collectors.toList()));
|
||||
});
|
||||
|
||||
return specifications;
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
@@ -204,8 +204,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link EntityOperations} used to perform data access operations on an entity
|
||||
* inside a Cassandra data source.
|
||||
* Returns the {@link EntityOperations} used to perform data access operations on an entity inside a Cassandra data
|
||||
* source.
|
||||
*
|
||||
* @return the configured {@link EntityOperations} for this template.
|
||||
* @see org.springframework.data.cassandra.core.EntityOperations
|
||||
@@ -367,8 +367,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entityClass);
|
||||
|
||||
Columns columns = getStatementFactory()
|
||||
.computeColumnsForProjection(query.getColumns(), persistentEntity, returnType);
|
||||
Columns columns = getStatementFactory().computeColumnsForProjection(query.getColumns(), persistentEntity,
|
||||
returnType);
|
||||
|
||||
Query queryToUse = query.columns(columns);
|
||||
|
||||
@@ -418,13 +418,12 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
<T> Stream<T> doStream(Query query, Class<?> entityClass, CqlIdentifier tableName, Class<T> returnType) {
|
||||
|
||||
RegularStatement statement = getStatementFactory()
|
||||
.select(query, getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement statement = getStatementFactory().select(query, getRequiredPersistentEntity(entityClass),
|
||||
tableName);
|
||||
|
||||
ResultSet resultSet = getCqlOperations().queryForResultSet(statement);
|
||||
|
||||
return StreamSupport.stream(resultSet.spliterator(), false)
|
||||
.map(getMapper(entityClass, returnType, tableName));
|
||||
return StreamSupport.stream(resultSet.spliterator(), false).map(getMapper(entityClass, returnType, tableName));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -438,8 +437,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
Assert.notNull(update, "Update must not be null");
|
||||
Assert.notNull(entityClass, "Entity type must not be null");
|
||||
|
||||
Statement updateStatement = getStatementFactory()
|
||||
.update(query, update, getRequiredPersistentEntity(entityClass));
|
||||
Statement updateStatement = getStatementFactory().update(query, update, getRequiredPersistentEntity(entityClass));
|
||||
|
||||
return getCqlOperations().execute(updateStatement);
|
||||
}
|
||||
@@ -448,8 +446,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
WriteResult doUpdate(Query query, org.springframework.data.cassandra.core.query.Update update, Class<?> entityClass,
|
||||
CqlIdentifier tableName) {
|
||||
|
||||
RegularStatement updateStatement = getStatementFactory()
|
||||
.update(query, update, getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement updateStatement = getStatementFactory().update(query, update,
|
||||
getRequiredPersistentEntity(entityClass), tableName);
|
||||
|
||||
return getCqlOperations().execute(new StatementCallback(updateStatement));
|
||||
}
|
||||
@@ -515,8 +513,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
long doCount(Query query, Class<?> entityClass, CqlIdentifier tableName) {
|
||||
|
||||
RegularStatement countStatement = getStatementFactory()
|
||||
.count(query, getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement countStatement = getStatementFactory().count(query, getRequiredPersistentEntity(entityClass),
|
||||
tableName);
|
||||
|
||||
Long count = getCqlOperations().queryForObject(countStatement, Long.class);
|
||||
|
||||
@@ -555,8 +553,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
boolean doExists(Query query, Class<?> entityClass, CqlIdentifier tableName) {
|
||||
|
||||
RegularStatement select = getStatementFactory()
|
||||
.select(query.limit(1), getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement select = getStatementFactory().select(query.limit(1), getRequiredPersistentEntity(entityClass),
|
||||
tableName);
|
||||
|
||||
return getCqlOperations().queryForResultSet(select).iterator().hasNext();
|
||||
}
|
||||
@@ -613,8 +611,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
Insert insert = EntityQueryUtils.createInsertQuery(tableName.toCql(), entityToUse, options, getConverter(),
|
||||
persistentEntity);
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doInsertVersioned(insert.ifNotExists(), entityToUse, source, tableName)
|
||||
return source.isVersionedEntity() ? doInsertVersioned(insert.ifNotExists(), entityToUse, source, tableName)
|
||||
: doInsert(insert, entityToUse, tableName);
|
||||
}
|
||||
|
||||
@@ -625,8 +622,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
if (!result.wasApplied()) {
|
||||
throw new OptimisticLockingFailureException(
|
||||
String.format("Cannot insert entity %s with version %s into table %s as it already exists",
|
||||
entity, source.getVersion(), tableName));
|
||||
String.format("Cannot insert entity %s with version %s into table %s as it already exists", entity,
|
||||
source.getVersion(), tableName));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -656,8 +653,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
CqlIdentifier tableName = persistentEntity.getTableName();
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doUpdateVersioned(source, options, tableName, persistentEntity)
|
||||
return source.isVersionedEntity() ? doUpdateVersioned(source, options, tableName, persistentEntity)
|
||||
: doUpdate(entity, options, tableName, persistentEntity);
|
||||
}
|
||||
|
||||
@@ -674,8 +670,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
if (!result.wasApplied()) {
|
||||
throw new OptimisticLockingFailureException(
|
||||
String.format("Cannot save entity %s with version %s to table %s. Has it been modified meanwhile?",
|
||||
entity, source.getVersion(), tableName));
|
||||
String.format("Cannot save entity %s with version %s to table %s. Has it been modified meanwhile?", entity,
|
||||
source.getVersion(), tableName));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -711,9 +707,8 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
|
||||
|
||||
Delete delete = getStatementFactory().delete(entity, options, getConverter(), persistentEntity, tableName);
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doDeleteVersioned(delete, entity, source, tableName)
|
||||
: doDelete(delete, entity, tableName);
|
||||
return source.isVersionedEntity() ? doDeleteVersioned(delete, entity, source, tableName)
|
||||
: doDelete(delete, entity, tableName);
|
||||
}
|
||||
|
||||
private WriteResult doDeleteVersioned(Delete delete, Object entity, AdaptibleEntity<Object> source,
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.WriteOptions;
|
||||
import org.springframework.data.cassandra.core.query.CriteriaDefinition;
|
||||
import org.springframework.data.cassandra.core.query.Filter;
|
||||
@@ -299,8 +299,8 @@ public class DeleteOptions extends WriteOptions {
|
||||
*/
|
||||
public DeleteOptions build() {
|
||||
|
||||
return new DeleteOptions(this.consistencyLevel, this.retryPolicy, this.tracing, this.fetchSize,
|
||||
this.readTimeout, this.ttl, this.timestamp, this.ifExists, this.ifCondition);
|
||||
return new DeleteOptions(this.consistencyLevel, this.retryPolicy, this.tracing, this.fetchSize, this.readTimeout,
|
||||
this.ttl, this.timestamp, this.ifExists, this.ifCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ import com.datastax.driver.core.querybuilder.Update;
|
||||
@RequiredArgsConstructor
|
||||
class EntityOperations {
|
||||
|
||||
@NonNull @Getter(AccessLevel.PROTECTED)
|
||||
private final MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext;
|
||||
@NonNull @Getter(AccessLevel.PROTECTED) private final MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Entity} for the given bean.
|
||||
@@ -251,8 +250,7 @@ class EntityOperations {
|
||||
|
||||
PersistentPropertyAccessor<T> propertyAccessor = entity.getPropertyAccessor(bean);
|
||||
|
||||
return new AdaptibleMappedEntity<>(entity,
|
||||
new ConvertingPropertyAccessor<>(propertyAccessor, conversionService));
|
||||
return new AdaptibleMappedEntity<>(entity, new ConvertingPropertyAccessor<>(propertyAccessor, conversionService));
|
||||
}
|
||||
|
||||
private AdaptibleMappedEntity(CassandraPersistentEntity<?> entity, ConvertingPropertyAccessor<T> propertyAccessor) {
|
||||
|
||||
@@ -122,8 +122,7 @@ public interface ExecutableDeleteOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* the {@link ExecutableDelete} interface provides methods for constructing {@code DELETE} operations
|
||||
* in a fluent way.
|
||||
* the {@link ExecutableDelete} interface provides methods for constructing {@code DELETE} operations in a fluent way.
|
||||
*/
|
||||
interface ExecutableDelete extends DeleteWithTable, DeleteWithQuery {}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class ExecutableDeleteOperationSupport implements ExecutableDeleteOperation {
|
||||
// While the use of final fields and construction on mutation effectively makes this class Thread-safe,
|
||||
// it is possible this implementation could generate a high-level of young-gen garbage on the JVM heap,
|
||||
// particularly if the template delete(..) (and this class) are used inside of a loop for a large number
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's `Query`
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's `Query`
|
||||
// in addition to his/her application design.
|
||||
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -123,8 +123,7 @@ public interface ExecutableInsertOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ExecutableInsert} interface provides methods for constructing {@code INSERT} operations
|
||||
* in a fluent way.
|
||||
* The {@link ExecutableInsert} interface provides methods for constructing {@code INSERT} operations in a fluent way.
|
||||
*/
|
||||
interface ExecutableInsert<T> extends InsertWithTable<T> {}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class ExecutableInsertOperationSupport implements ExecutableInsertOperation {
|
||||
// While the use of final fields and construction on mutation effectively makes this class Thread-safe,
|
||||
// it is possible this implementation could generate a high-level of young-gen garbage on the JVM heap,
|
||||
// particularly if the template insert(..) (and this class) are used inside of a loop for a large number
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's application design.
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's application design.
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
||||
|
||||
@@ -33,9 +33,9 @@ import org.springframework.util.Assert;
|
||||
* the result from the {@link com.datastax.driver.core.Row}. However, it is possible to define an different
|
||||
* {@literal returnType} via {@code as} for mapping the result.
|
||||
* <p>
|
||||
* By default, the table to operate on is derived from the initial {@literal domainType} and can be defined there
|
||||
* with the {@link org.springframework.data.cassandra.core.mapping.Table} annotation as well. Using {@code inTable}
|
||||
* allows a user to override the table name for the execution.
|
||||
* By default, the table to operate on is derived from the initial {@literal domainType} and can be defined there with
|
||||
* the {@link org.springframework.data.cassandra.core.mapping.Table} annotation as well. Using {@code inTable} allows a
|
||||
* user to override the table name for the execution.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
@@ -211,8 +211,8 @@ public interface ExecutableSelectOperation {
|
||||
/**
|
||||
* Stream all matching elements.
|
||||
*
|
||||
* @return a {@link Stream} wrapping the Cassandra {@link com.datastax.driver.core.ResultSet},
|
||||
* which needs to be closed; never {@literal null}.
|
||||
* @return a {@link Stream} wrapping the Cassandra {@link com.datastax.driver.core.ResultSet}, which needs to be
|
||||
* closed; never {@literal null}.
|
||||
* @see java.util.stream.Stream
|
||||
* @see #all()
|
||||
*/
|
||||
@@ -222,8 +222,8 @@ public interface ExecutableSelectOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ExecutableSelect} interface provides methods for constructing {@code SELECT} query operations
|
||||
* in a fluent way.
|
||||
* The {@link ExecutableSelect} interface provides methods for constructing {@code SELECT} query operations in a
|
||||
* fluent way.
|
||||
*/
|
||||
interface ExecutableSelect<T> extends SelectWithTable<T>, SelectWithProjection<T> {}
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.data.cassandra.core.query.Query;
|
||||
@@ -58,7 +58,7 @@ class ExecutableSelectOperationSupport implements ExecutableSelectOperation {
|
||||
// While the use of final fields and construction on mutation effectively makes this class Thread-safe,
|
||||
// it is possible this implementation could generate a high-level of young-gen garbage on the JVM heap,
|
||||
// particularly if the template query(..) (and this class) are used inside of a loop for a large number
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's `Query`
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's `Query`
|
||||
// in addition to his/her application design.
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@@ -83,8 +83,7 @@ class ExecutableSelectOperationSupport implements ExecutableSelectOperation {
|
||||
|
||||
Assert.notNull(tableName, "Table name must not be null");
|
||||
|
||||
return new ExecutableSelectSupport<>(this.template, this.domainType, this.returnType,
|
||||
this.query, tableName);
|
||||
return new ExecutableSelectSupport<>(this.template, this.domainType, this.returnType, this.query, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -95,8 +94,7 @@ class ExecutableSelectOperationSupport implements ExecutableSelectOperation {
|
||||
|
||||
Assert.notNull(returnType, "ReturnType must not be null");
|
||||
|
||||
return new ExecutableSelectSupport<>(this.template, this.domainType, returnType,
|
||||
this.query, this.tableName);
|
||||
return new ExecutableSelectSupport<>(this.template, this.domainType, returnType, this.query, this.tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -107,8 +105,7 @@ class ExecutableSelectOperationSupport implements ExecutableSelectOperation {
|
||||
|
||||
Assert.notNull(query, "Query must not be null");
|
||||
|
||||
return new ExecutableSelectSupport<>(this.template, this.domainType, this.returnType,
|
||||
query, this.tableName);
|
||||
return new ExecutableSelectSupport<>(this.template, this.domainType, this.returnType, query, this.tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -133,8 +130,7 @@ class ExecutableSelectOperationSupport implements ExecutableSelectOperation {
|
||||
@Override
|
||||
public T firstValue() {
|
||||
|
||||
List<T> result =
|
||||
this.template.doSelect(this.query.limit(1), this.domainType, getTableName(), this.returnType);
|
||||
List<T> result = this.template.doSelect(this.query.limit(1), this.domainType, getTableName(), this.returnType);
|
||||
|
||||
return ObjectUtils.isEmpty(result) ? null : result.iterator().next();
|
||||
}
|
||||
@@ -145,8 +141,7 @@ class ExecutableSelectOperationSupport implements ExecutableSelectOperation {
|
||||
@Override
|
||||
public T oneValue() {
|
||||
|
||||
List<T> result =
|
||||
this.template.doSelect(this.query.limit(2), this.domainType, getTableName(), this.returnType);
|
||||
List<T> result = this.template.doSelect(this.query.limit(2), this.domainType, getTableName(), this.returnType);
|
||||
|
||||
if (ObjectUtils.isEmpty(result)) {
|
||||
return null;
|
||||
|
||||
@@ -21,14 +21,14 @@ import org.springframework.data.cassandra.core.query.Update;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link ExecutableUpdateOperation} allows creation and execution of Cassandra {@code UPDATE} operation
|
||||
* in a fluent API style.
|
||||
* {@link ExecutableUpdateOperation} allows creation and execution of Cassandra {@code UPDATE} operation in a fluent API
|
||||
* style.
|
||||
* <p>
|
||||
* The starting {@literal domainType} is used for mapping the {@link Query} provided via {@code matching},
|
||||
* as well as the {@link Update} provided via {@code apply} into the Cassandra specific representations.
|
||||
* The table to operate on is by default derived from the initial {@literal domainType} and can be defined
|
||||
* there via {@link org.springframework.data.cassandra.core.mapping.Table}. Using {@code inTable} allows
|
||||
* the developer to override the table name for the execution.
|
||||
* The starting {@literal domainType} is used for mapping the {@link Query} provided via {@code matching}, as well as
|
||||
* the {@link Update} provided via {@code apply} into the Cassandra specific representations. The table to operate on is
|
||||
* by default derived from the initial {@literal domainType} and can be defined there via
|
||||
* {@link org.springframework.data.cassandra.core.mapping.Table}. Using {@code inTable} allows the developer to override
|
||||
* the table name for the execution.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
@@ -131,8 +131,7 @@ public interface ExecutableUpdateOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ExecutableUpdate} interface provides methods for constructing {@code UPDATE} operations
|
||||
* in a fluent way.
|
||||
* The {@link ExecutableUpdate} interface provides methods for constructing {@code UPDATE} operations in a fluent way.
|
||||
*/
|
||||
interface ExecutableUpdate extends UpdateWithTable, UpdateWithQuery {}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
||||
// While the use of final fields and construction on mutation effectively makes this class Thread-safe,
|
||||
// it is possible this implementation could generate a high-level of young-gen garbage on the JVM heap,
|
||||
// particularly if the template update(..) (and this class) are used inside of a loop for a large number
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's `Query`
|
||||
// of domain types. Of course, this assumption is highly contingent on the user's `Query`
|
||||
// in addition to his/her application design.
|
||||
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -23,9 +26,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.convert.UpdateMapper;
|
||||
import org.springframework.data.cassandra.core.cql.WriteOptions;
|
||||
@@ -86,8 +86,8 @@ class ReactiveCassandraBatchTemplate implements ReactiveCassandraBatchOperations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to the configured {@link CassandraConverter} used to map {@link Object Objects}
|
||||
* to {@link com.datastax.driver.core.Row Rows}.
|
||||
* Return a reference to the configured {@link CassandraConverter} used to map {@link Object Objects} to
|
||||
* {@link com.datastax.driver.core.Row Rows}.
|
||||
*
|
||||
* @return a reference to the configured {@link CassandraConverter}.
|
||||
* @see org.springframework.data.cassandra.core.convert.CassandraConverter
|
||||
@@ -97,8 +97,8 @@ class ReactiveCassandraBatchTemplate implements ReactiveCassandraBatchOperations
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the configured {@link CassandraMappingContext} used to map entities to Cassandra tables
|
||||
* and back.
|
||||
* Returns a reference to the configured {@link CassandraMappingContext} used to map entities to Cassandra tables and
|
||||
* back.
|
||||
*
|
||||
* @return a reference to the configured {@link CassandraMappingContext}.
|
||||
* @see org.springframework.data.cassandra.core.mapping.CassandraMappingContext
|
||||
@@ -112,8 +112,8 @@ class ReactiveCassandraBatchTemplate implements ReactiveCassandraBatchOperations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to the configured {@link StatementFactory} used to create Cassandra {@link Statement} objects
|
||||
* to perform data access operations on a Cassandra cluster.
|
||||
* Return a reference to the configured {@link StatementFactory} used to create Cassandra {@link Statement} objects to
|
||||
* perform data access operations on a Cassandra cluster.
|
||||
*
|
||||
* @return a reference to the configured {@link StatementFactory}.
|
||||
* @see org.springframework.data.cassandra.core.StatementFactory
|
||||
@@ -231,11 +231,11 @@ class ReactiveCassandraBatchTemplate implements ReactiveCassandraBatchOperations
|
||||
|
||||
Assert.notNull(entity, "Entity must not be null");
|
||||
|
||||
BasicCassandraPersistentEntity<?> persistentEntity =
|
||||
mappingContext.getRequiredPersistentEntity(entity.getClass());
|
||||
BasicCassandraPersistentEntity<?> persistentEntity = mappingContext
|
||||
.getRequiredPersistentEntity(entity.getClass());
|
||||
|
||||
Insert insertQuery = EntityQueryUtils.createInsertQuery(persistentEntity.getTableName().toCql(),
|
||||
entity, options, converter, persistentEntity);
|
||||
Insert insertQuery = EntityQueryUtils.createInsertQuery(persistentEntity.getTableName().toCql(), entity, options,
|
||||
converter, persistentEntity);
|
||||
|
||||
insertQueries.add(insertQuery);
|
||||
}
|
||||
@@ -313,8 +313,8 @@ class ReactiveCassandraBatchTemplate implements ReactiveCassandraBatchOperations
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
|
||||
Update update = getStatementFactory()
|
||||
.update(entity, options, converter, persistentEntity, persistentEntity.getTableName());
|
||||
Update update = getStatementFactory().update(entity, options, converter, persistentEntity,
|
||||
persistentEntity.getTableName());
|
||||
|
||||
updateQueries.add(update);
|
||||
}
|
||||
@@ -392,8 +392,8 @@ class ReactiveCassandraBatchTemplate implements ReactiveCassandraBatchOperations
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
|
||||
Delete delete = getStatementFactory()
|
||||
.delete(entity, options, converter, persistentEntity, persistentEntity.getTableName());
|
||||
Delete delete = getStatementFactory().delete(entity, options, converter, persistentEntity,
|
||||
persistentEntity.getTableName());
|
||||
|
||||
deleteQueries.add(delete);
|
||||
}
|
||||
|
||||
@@ -15,17 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.SynchronousSink;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
@@ -198,8 +198,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link EntityOperations} used to perform data access operations on an entity
|
||||
* inside a Cassandra data source.
|
||||
* Returns the {@link EntityOperations} used to perform data access operations on an entity inside a Cassandra data
|
||||
* source.
|
||||
*
|
||||
* @return the configured {@link EntityOperations} for this template.
|
||||
* @see org.springframework.data.cassandra.core.EntityOperations
|
||||
@@ -310,17 +310,15 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
Mono<Integer> effectiveFetchSizeMono = getEffectiveFetchSize(statement);
|
||||
RowMapper<T> rowMapper = (row, i) -> getConverter().read(entityClass, row);
|
||||
|
||||
return resultSetMono.zipWith(effectiveFetchSizeMono)
|
||||
.flatMap(tuple -> {
|
||||
return resultSetMono.zipWith(effectiveFetchSizeMono).flatMap(tuple -> {
|
||||
|
||||
ReactiveResultSet resultSet = tuple.getT1();
|
||||
Integer effectiveFetchSize = tuple.getT2();
|
||||
ReactiveResultSet resultSet = tuple.getT1();
|
||||
Integer effectiveFetchSize = tuple.getT2();
|
||||
|
||||
return resultSet.availableRows().collectList().map(it ->
|
||||
EntityQueryUtils.readSlice(it, resultSet.getExecutionInfo().getPagingState(), rowMapper,
|
||||
1, effectiveFetchSize));
|
||||
return resultSet.availableRows().collectList().map(it -> EntityQueryUtils.readSlice(it,
|
||||
resultSet.getExecutionInfo().getPagingState(), rowMapper, 1, effectiveFetchSize));
|
||||
|
||||
}).defaultIfEmpty(new SliceImpl<>(Collections.emptyList()));
|
||||
}).defaultIfEmpty(new SliceImpl<>(Collections.emptyList()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -343,8 +341,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entityClass);
|
||||
|
||||
Columns columns = getStatementFactory()
|
||||
.computeColumnsForProjection(query.getColumns(), persistentEntity, returnType);
|
||||
Columns columns = getStatementFactory().computeColumnsForProjection(query.getColumns(), persistentEntity,
|
||||
returnType);
|
||||
|
||||
Query queryToUse = query.columns(columns);
|
||||
|
||||
@@ -398,8 +396,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
Mono<WriteResult> doUpdate(Query query, org.springframework.data.cassandra.core.query.Update update,
|
||||
Class<?> entityClass, CqlIdentifier tableName) {
|
||||
|
||||
RegularStatement statement = getStatementFactory()
|
||||
.update(query, update, getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement statement = getStatementFactory().update(query, update, getRequiredPersistentEntity(entityClass),
|
||||
tableName);
|
||||
|
||||
return getReactiveCqlOperations().execute(new StatementCallback(statement)).next();
|
||||
}
|
||||
@@ -418,8 +416,7 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
|
||||
Mono<WriteResult> doDelete(Query query, Class<?> entityClass, CqlIdentifier tableName) {
|
||||
|
||||
RegularStatement delete = getStatementFactory()
|
||||
.delete(query, getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement delete = getStatementFactory().delete(query, getRequiredPersistentEntity(entityClass), tableName);
|
||||
|
||||
Mono<WriteResult> writeResult = getReactiveCqlOperations().execute(new StatementCallback(delete))
|
||||
.doOnSubscribe(it -> maybeEmitEvent(new BeforeDeleteEvent<>(delete, entityClass, tableName))).next();
|
||||
@@ -495,8 +492,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
|
||||
Mono<Boolean> doExists(Query query, Class<?> entityClass, CqlIdentifier tableName) {
|
||||
|
||||
RegularStatement select = getStatementFactory()
|
||||
.select(query.limit(1), getRequiredPersistentEntity(entityClass), tableName);
|
||||
RegularStatement select = getStatementFactory().select(query.limit(1), getRequiredPersistentEntity(entityClass),
|
||||
tableName);
|
||||
|
||||
return getReactiveCqlOperations().queryForRows(select).hasElements();
|
||||
}
|
||||
@@ -549,8 +546,7 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
Insert insert = EntityQueryUtils.createInsertQuery(tableName.toCql(), entityToUse, options, getConverter(),
|
||||
persistentEntity);
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doInsertVersioned(insert.ifNotExists(), entityToUse, source, tableName)
|
||||
return source.isVersionedEntity() ? doInsertVersioned(insert.ifNotExists(), entityToUse, source, tableName)
|
||||
: doInsert(insert, entityToUse, tableName);
|
||||
}
|
||||
|
||||
@@ -562,8 +558,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
if (!result.wasApplied()) {
|
||||
|
||||
sink.error(new OptimisticLockingFailureException(
|
||||
String.format("Cannot insert entity %s with version %s into table %s as it already exists",
|
||||
entity, source.getVersion(), tableName)));
|
||||
String.format("Cannot insert entity %s with version %s into table %s as it already exists", entity,
|
||||
source.getVersion(), tableName)));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -597,8 +593,7 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
CassandraPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(entity.getClass());
|
||||
CqlIdentifier tableName = persistentEntity.getTableName();
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doUpdateVersioned(source, options, tableName, persistentEntity)
|
||||
return source.isVersionedEntity() ? doUpdateVersioned(source, options, tableName, persistentEntity)
|
||||
: doUpdate(entity, options, tableName, persistentEntity);
|
||||
}
|
||||
|
||||
@@ -616,8 +611,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
if (!result.wasApplied()) {
|
||||
|
||||
sink.error(new OptimisticLockingFailureException(
|
||||
String.format("Cannot save entity %s with version %s to table %s. Has it been modified meanwhile?",
|
||||
entity, source.getVersion(), tableName)));
|
||||
String.format("Cannot save entity %s with version %s to table %s. Has it been modified meanwhile?", entity,
|
||||
source.getVersion(), tableName)));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -657,8 +652,7 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
|
||||
Delete delete = getStatementFactory().delete(entity, options, getConverter(), persistentEntity, tableName);
|
||||
|
||||
return source.isVersionedEntity()
|
||||
? doDeleteVersioned(delete, entity, source, tableName)
|
||||
return source.isVersionedEntity() ? doDeleteVersioned(delete, entity, source, tableName)
|
||||
: doDelete(delete, entity, tableName);
|
||||
}
|
||||
|
||||
@@ -806,8 +800,8 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
}
|
||||
}
|
||||
|
||||
return getReactiveCqlOperations().execute((ReactiveSessionCallback<Integer>) session ->
|
||||
Mono.just(session.getCluster().getConfiguration().getQueryOptions().getFetchSize())).single();
|
||||
return getReactiveCqlOperations().execute((ReactiveSessionCallback<Integer>) session -> Mono
|
||||
.just(session.getCluster().getConfiguration().getQueryOptions().getFetchSize())).single();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -821,9 +815,7 @@ public class ReactiveCassandraTemplate implements ReactiveCassandraOperations, A
|
||||
|
||||
Object source = getConverter().read(typeToRead, row);
|
||||
|
||||
T result = (T) (targetType.isInterface()
|
||||
? getProjectionFactory().createProjection(targetType, source)
|
||||
: source);
|
||||
T result = (T) (targetType.isInterface() ? getProjectionFactory().createProjection(targetType, source) : source);
|
||||
|
||||
maybeEmitEvent(new AfterConvertEvent<>(row, result, tableName));
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The {@link ReactiveDeleteOperation} interface allows creation and execution of Cassandra {@code DELETE} operations
|
||||
* in a fluent API style.
|
||||
* The {@link ReactiveDeleteOperation} interface allows creation and execution of Cassandra {@code DELETE} operations in
|
||||
* a fluent API style.
|
||||
* <p>
|
||||
* The starting {@literal domainType} is used for mapping the {@link Query} provided via {@code matching}
|
||||
* into the Cassandra specific representation. By default, the table to operate on is derived from the initial
|
||||
* The starting {@literal domainType} is used for mapping the {@link Query} provided via {@code matching} into the
|
||||
* Cassandra specific representation. By default, the table to operate on is derived from the initial
|
||||
* {@literal domainType} and can be defined there via {@link org.springframework.data.cassandra.core.mapping.Table}
|
||||
* annotation. Using {@code inTable} allows a developer to override the table name for the execution.
|
||||
*
|
||||
@@ -127,8 +127,7 @@ public interface ReactiveDeleteOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ReactiveDelete} interface provides methods for constructing {@code DELETE} operations
|
||||
* in a fluent way.
|
||||
* The {@link ReactiveDelete} interface provides methods for constructing {@code DELETE} operations in a fluent way.
|
||||
*/
|
||||
interface ReactiveDelete extends DeleteWithTable, DeleteWithQuery {}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
|
||||
@@ -21,12 +21,12 @@ import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The {@link ReactiveInsertOperation} interface allows creation and execution of Cassandra {@code INSERT} operations
|
||||
* in a fluent API style.
|
||||
* The {@link ReactiveInsertOperation} interface allows creation and execution of Cassandra {@code INSERT} operations in
|
||||
* a fluent API style.
|
||||
* <p>
|
||||
* By default,the table to operate on is derived from the initial {@link Class domainType} and can be defined
|
||||
* there via {@link org.springframework.data.cassandra.core.mapping.Table} annotation. Using {@code inTable}
|
||||
* allows a developer to override the table name for the execution.
|
||||
* By default,the table to operate on is derived from the initial {@link Class domainType} and can be defined there via
|
||||
* {@link org.springframework.data.cassandra.core.mapping.Table} annotation. Using {@code inTable} allows a developer to
|
||||
* override the table name for the execution.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
@@ -128,8 +128,7 @@ public interface ReactiveInsertOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ReactiveInsert} interface provides methods for constructing {@code INSERT} operations
|
||||
* in a fluent way.
|
||||
* The {@link ReactiveInsert} interface provides methods for constructing {@code INSERT} operations in a fluent way.
|
||||
*/
|
||||
interface ReactiveInsert<T> extends InsertWithTable<T> {}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The {@link ReactiveSelectOperation} interface allows creation and execution of Cassandra {@code SELECT} operations
|
||||
* in a fluent API style.
|
||||
* The {@link ReactiveSelectOperation} interface allows creation and execution of Cassandra {@code SELECT} operations in
|
||||
* a fluent API style.
|
||||
* <p>
|
||||
* The starting {@literal domainType} is used for mapping the {@link Query} provided via {@code matching} int the
|
||||
* Cassandra specific representation. By default, the originating {@literal domainType} is also used for mapping back
|
||||
@@ -32,8 +32,8 @@ import org.springframework.util.Assert;
|
||||
* {@literal returnType} via {@code as} to mapping the result.
|
||||
* <p>
|
||||
* By default, the table to operate on is derived from the initial {@literal domainType} and can be defined there via
|
||||
* the {@link org.springframework.data.cassandra.core.mapping.Table} annotation. Using {@code inTable} allows
|
||||
* a developer to override the table name for the execution.
|
||||
* the {@link org.springframework.data.cassandra.core.mapping.Table} annotation. Using {@code inTable} allows a
|
||||
* developer to override the table name for the execution.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
@@ -155,8 +155,7 @@ public interface ReactiveSelectOperation {
|
||||
/**
|
||||
* Check for the presence of matching elements.
|
||||
*
|
||||
* @return a {@link Mono} emitting {@literal true} if at least one matching element exists;
|
||||
* never {@literal null}.
|
||||
* @return a {@link Mono} emitting {@literal true} if at least one matching element exists; never {@literal null}.
|
||||
* @see reactor.core.publisher.Mono
|
||||
*/
|
||||
Mono<Boolean> exists();
|
||||
@@ -189,8 +188,7 @@ public interface ReactiveSelectOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ReactiveSelect} interface provides methods for constructing {@code SELECT} operations
|
||||
* in a fluent way.
|
||||
* The {@link ReactiveSelect} interface provides methods for constructing {@code SELECT} operations in a fluent way.
|
||||
*/
|
||||
interface ReactiveSelect<T> extends SelectWithTable<T>, SelectWithProjection<T> {}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -130,8 +129,7 @@ class ReactiveSelectOperationSupport implements ReactiveSelectOperation {
|
||||
@Override
|
||||
public Mono<T> one() {
|
||||
|
||||
Flux<T> result =
|
||||
this.template.doSelect(this.query.limit(2), this.domainType, getTableName(), this.returnType);
|
||||
Flux<T> result = this.template.doSelect(this.query.limit(2), this.domainType, getTableName(), this.returnType);
|
||||
|
||||
return result.collectList() //
|
||||
.flatMap(it -> {
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.springframework.data.cassandra.core.query.Update;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The {@link ReactiveUpdateOperation} interface allows creation and execution of Cassandra {@code UPDATE} operations
|
||||
* in a fluent API style.
|
||||
* The {@link ReactiveUpdateOperation} interface allows creation and execution of Cassandra {@code UPDATE} operations in
|
||||
* a fluent API style.
|
||||
* <p>
|
||||
* The starting {@literal domainType} is used for mapping the {@link Query} provided via {@code matching}, as well as
|
||||
* the {@link Update} via {@code apply} into the Cassandra specific representations.
|
||||
* <p>
|
||||
* By default, the table to operate on is derived from the initial {@literal domainType} and can be defined there
|
||||
* via the {@link org.springframework.data.cassandra.core.mapping.Table} annotation. Using {@code inTable} allows
|
||||
* a developer to override the table name for the execution.
|
||||
* By default, the table to operate on is derived from the initial {@literal domainType} and can be defined there via
|
||||
* the {@link org.springframework.data.cassandra.core.mapping.Table} annotation. Using {@code inTable} allows a
|
||||
* developer to override the table name for the execution.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
@@ -135,8 +135,7 @@ public interface ReactiveUpdateOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ReactiveUpdate} interface provides methods for constructing {@code UPDATE} operations
|
||||
* in a fluent way.
|
||||
* The {@link ReactiveUpdate} interface provides methods for constructing {@code UPDATE} operations in a fluent way.
|
||||
*/
|
||||
interface ReactiveUpdate extends UpdateWithTable, UpdateWithQuery {}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
|
||||
@@ -358,8 +358,8 @@ public class StatementFactory {
|
||||
EntityWriter<Object, Object> entityWriter, CassandraPersistentEntity<?> persistentEntity,
|
||||
CqlIdentifier tableName) {
|
||||
|
||||
com.datastax.driver.core.querybuilder.Update update =
|
||||
EntityQueryUtils.createUpdateQuery(tableName.toCql(), entity, options, entityWriter);
|
||||
com.datastax.driver.core.querybuilder.Update update = EntityQueryUtils.createUpdateQuery(tableName.toCql(), entity,
|
||||
options, entityWriter);
|
||||
|
||||
potentiallyApplyIfCondition(options, UpdateOptions.class, UpdateOptions::getIfCondition,
|
||||
condition -> addIfCondition(condition, update, persistentEntity));
|
||||
@@ -635,9 +635,9 @@ public class StatementFactory {
|
||||
|
||||
Predicate predicate = criteriaDefinition.getPredicate();
|
||||
|
||||
CriteriaDefinition.Operators predicateOperator =
|
||||
CriteriaDefinition.Operators.from(predicate.getOperator().toString())
|
||||
.orElseThrow(() -> new IllegalArgumentException(String.format("Unknown operator [%s]", predicate.getOperator())));
|
||||
CriteriaDefinition.Operators predicateOperator = CriteriaDefinition.Operators
|
||||
.from(predicate.getOperator().toString()).orElseThrow(
|
||||
() -> new IllegalArgumentException(String.format("Unknown operator [%s]", predicate.getOperator())));
|
||||
|
||||
switch (predicateOperator) {
|
||||
|
||||
@@ -692,7 +692,7 @@ public class StatementFactory {
|
||||
return QueryBuilder.containsKey(columnName, predicate.getValue());
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format("Criteria %s %s %s not supported",
|
||||
columnName, predicate.getOperator(), predicate.getValue()));
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Criteria %s %s %s not supported", columnName, predicate.getOperator(), predicate.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.WriteOptions;
|
||||
import org.springframework.data.cassandra.core.query.CriteriaDefinition;
|
||||
import org.springframework.data.cassandra.core.query.Filter;
|
||||
@@ -307,8 +307,8 @@ public class UpdateOptions extends WriteOptions {
|
||||
*/
|
||||
public UpdateOptions build() {
|
||||
|
||||
return new UpdateOptions(this.consistencyLevel, this.retryPolicy, this.tracing, this.fetchSize,
|
||||
this.readTimeout, this.ttl, this.timestamp, this.ifExists, this.ifCondition);
|
||||
return new UpdateOptions(this.consistencyLevel, this.retryPolicy, this.tracing, this.fetchSize, this.readTimeout,
|
||||
this.ttl, this.timestamp, this.ifExists, this.ifCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.GenericConversionService;
|
||||
|
||||
@@ -76,9 +76,8 @@ public class BasicCassandraRowValueProvider implements CassandraRowValueProvider
|
||||
|
||||
String spelExpression = property.getSpelExpression();
|
||||
|
||||
return spelExpression != null
|
||||
? this.evaluator.evaluate(spelExpression)
|
||||
: (T) this.reader.get(property.getRequiredColumnName());
|
||||
return spelExpression != null ? this.evaluator.evaluate(spelExpression)
|
||||
: (T) this.reader.get(property.getRequiredColumnName());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -82,8 +82,7 @@ public class CassandraCustomConversions extends org.springframework.data.convert
|
||||
ResolvableType classType = ResolvableType.forClass(it).as(Converter.class).getGeneric(0);
|
||||
|
||||
return classType.getRawClass();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
NATIVE_TIME_TYPE_MARKERS = new HashSet<>(timeMarkers);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,8 @@ import com.datastax.driver.core.DataType.Name;
|
||||
*/
|
||||
public abstract class CassandraThreeTenBackPortConverters {
|
||||
|
||||
private static final boolean THREE_TEN_BACK_PORT_IS_PRESENT =
|
||||
ClassUtils.isPresent("org.threeten.bp.LocalDateTime",
|
||||
ThreeTenBackPortConverters.class.getClassLoader());
|
||||
private static final boolean THREE_TEN_BACK_PORT_IS_PRESENT = ClassUtils.isPresent("org.threeten.bp.LocalDateTime",
|
||||
ThreeTenBackPortConverters.class.getClassLoader());
|
||||
|
||||
private CassandraThreeTenBackPortConverters() {}
|
||||
|
||||
|
||||
@@ -47,8 +47,7 @@ public class CassandraUDTValueProvider implements CassandraValueProvider {
|
||||
* @param evaluator must not be {@literal null}.
|
||||
* @since 2.1
|
||||
*/
|
||||
public CassandraUDTValueProvider(UDTValue udtValue, CodecRegistry codecRegistry,
|
||||
SpELExpressionEvaluator evaluator) {
|
||||
public CassandraUDTValueProvider(UDTValue udtValue, CodecRegistry codecRegistry, SpELExpressionEvaluator evaluator) {
|
||||
|
||||
Assert.notNull(udtValue, "UDTValue must not be null");
|
||||
Assert.notNull(codecRegistry, "CodecRegistry must not be null");
|
||||
|
||||
@@ -132,8 +132,8 @@ public class UpdateMapper extends QueryMapper {
|
||||
Assert.state(op.getValue() != null,
|
||||
() -> String.format("SetAtKeyOp for %s attempts to set null", field.getProperty()));
|
||||
|
||||
Optional<? extends TypeInformation<?>> typeInformation =
|
||||
field.getProperty().map(PersistentProperty::getTypeInformation);
|
||||
Optional<? extends TypeInformation<?>> typeInformation = field.getProperty()
|
||||
.map(PersistentProperty::getTypeInformation);
|
||||
|
||||
Optional<TypeInformation<?>> keyType = typeInformation.map(TypeInformation::getComponentType);
|
||||
Optional<TypeInformation<?>> valueType = typeInformation.map(TypeInformation::getMapValueType);
|
||||
@@ -167,8 +167,8 @@ public class UpdateMapper extends QueryMapper {
|
||||
|
||||
if (collection.isEmpty()) {
|
||||
|
||||
DataType.Name dataType = field.getProperty().map(property ->
|
||||
getMappingContext().getDataType(property)).map(DataType::getName).orElse(Name.LIST);
|
||||
DataType.Name dataType = field.getProperty().map(property -> getMappingContext().getDataType(property))
|
||||
.map(DataType::getName).orElse(Name.LIST);
|
||||
|
||||
if (dataType == Name.SET) {
|
||||
return new SetOp(field.getMappedKey(), Collections.emptySet());
|
||||
|
||||
@@ -96,8 +96,7 @@ public interface AsyncCqlOperations {
|
||||
* @return boolean value whether the statement was applied.
|
||||
* @throws DataAccessException if there is any problem executing the query.
|
||||
*/
|
||||
ListenableFuture<Boolean> execute(String cql, @Nullable PreparedStatementBinder psb)
|
||||
throws DataAccessException;
|
||||
ListenableFuture<Boolean> execute(String cql, @Nullable PreparedStatementBinder psb) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a CQL data access operation, implemented as callback action working on a CQL {@link PreparedStatement}.
|
||||
@@ -223,8 +222,8 @@ public interface AsyncCqlOperations {
|
||||
* @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<Void> query(String cql, @Nullable PreparedStatementBinder psb,
|
||||
RowCallbackHandler rowCallbackHandler) throws DataAccessException;
|
||||
ListenableFuture<Void> query(String cql, @Nullable PreparedStatementBinder psb, RowCallbackHandler rowCallbackHandler)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Query given CQL to create a prepared statement from CQL and a {@link PreparedStatementBinder} implementation that
|
||||
@@ -238,8 +237,8 @@ public interface AsyncCqlOperations {
|
||||
* @return the result {@link List}, containing mapped objects.
|
||||
* @throws DataAccessException if there is any problem executing the query.
|
||||
*/
|
||||
<T> ListenableFuture<List<T>> query(String cql, @Nullable PreparedStatementBinder psb,
|
||||
RowMapper<T> rowMapper) throws DataAccessException;
|
||||
<T> ListenableFuture<List<T>> query(String cql, @Nullable PreparedStatementBinder psb, RowMapper<T> rowMapper)
|
||||
throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Execute a query for a result {@link List}, given static CQL.
|
||||
@@ -697,8 +696,7 @@ public interface AsyncCqlOperations {
|
||||
* @throws DataAccessException if there is any problem executing the query.
|
||||
*/
|
||||
<T> ListenableFuture<T> query(AsyncPreparedStatementCreator preparedStatementCreator,
|
||||
@Nullable PreparedStatementBinder psb, ResultSetExtractor<T> resultSetExtractor)
|
||||
throws DataAccessException;
|
||||
@Nullable PreparedStatementBinder psb, ResultSetExtractor<T> resultSetExtractor) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values
|
||||
@@ -713,8 +711,7 @@ public interface AsyncCqlOperations {
|
||||
* @throws DataAccessException if there is any problem executing the query.
|
||||
*/
|
||||
ListenableFuture<Void> query(AsyncPreparedStatementCreator preparedStatementCreator,
|
||||
@Nullable PreparedStatementBinder psb, RowCallbackHandler rowCallbackHandler)
|
||||
throws DataAccessException;
|
||||
@Nullable PreparedStatementBinder psb, RowCallbackHandler rowCallbackHandler) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Query using a prepared statement and a {@link PreparedStatementBinder} implementation that knows how to bind values
|
||||
|
||||
@@ -541,8 +541,8 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
* @see org.springframework.data.cassandra.core.cqlOperations#query(org.springframework.data.cassandra.core.cql.PreparedStatementCreator, org.springframework.data.cassandra.core.cql.PreparedStatementBinder, org.springframework.data.cassandra.core.cql.RowMapper)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator preparedStatementCreator,
|
||||
@Nullable PreparedStatementBinder psb, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
public <T> List<T> query(PreparedStatementCreator preparedStatementCreator, @Nullable PreparedStatementBinder psb,
|
||||
RowMapper<T> rowMapper) throws DataAccessException {
|
||||
// noinspection ConstantConditions
|
||||
return query(preparedStatementCreator, psb, newResultSetExtractor(rowMapper));
|
||||
}
|
||||
@@ -582,8 +582,8 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
* @see org.springframework.data.cassandra.core.cqlOperations#query(java.lang.String, org.springframework.data.cassandra.core.cql.PreparedStatementBinder, org.springframework.data.cassandra.core.cql.ResultSetExtractor)
|
||||
*/
|
||||
@Override
|
||||
public <T> T query(String cql, @Nullable PreparedStatementBinder psb,
|
||||
ResultSetExtractor<T> resultSetExtractor) throws DataAccessException {
|
||||
public <T> T query(String cql, @Nullable PreparedStatementBinder psb, ResultSetExtractor<T> resultSetExtractor)
|
||||
throws DataAccessException {
|
||||
|
||||
return query(newPreparedStatementCreator(cql), psb, resultSetExtractor);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.cql;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -312,8 +312,7 @@ public class QueryOptions {
|
||||
* @return a new {@link QueryOptions} with the configured values
|
||||
*/
|
||||
public QueryOptions build() {
|
||||
return new QueryOptions(this.consistencyLevel, this.retryPolicy, this.tracing,
|
||||
this.fetchSize, this.readTimeout);
|
||||
return new QueryOptions(this.consistencyLevel, this.retryPolicy, this.tracing, this.fetchSize, this.readTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,8 +615,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
|
||||
Assert.hasText(cql, "CQL must not be empty");
|
||||
|
||||
return query(newReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), Mono::just)
|
||||
.next();
|
||||
return query(newReactivePreparedStatementCreator(cql), newArgPreparedStatementBinder(args), Mono::just).next();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -641,8 +640,7 @@ public class ReactiveCqlTemplate extends ReactiveCassandraAccessor implements Re
|
||||
*/
|
||||
@Override
|
||||
public Mono<Boolean> execute(String cql, @Nullable PreparedStatementBinder psb) throws DataAccessException {
|
||||
return query(newReactivePreparedStatementCreator(cql), psb, resultSet -> Mono.just(resultSet.wasApplied()))
|
||||
.next();
|
||||
return query(newReactivePreparedStatementCreator(cql), psb, resultSet -> Mono.just(resultSet.wasApplied())).next();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -37,7 +37,6 @@ public class AddColumnCqlGenerator extends ColumnChangeCqlGenerator<AddColumnSpe
|
||||
*/
|
||||
@Override
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
return cql.append("ADD ").append(spec().getName()).append(' ')
|
||||
.append(spec().getType().asFunctionParameterString());
|
||||
return cql.append("ADD ").append(spec().getName()).append(' ').append(spec().getType().asFunctionParameterString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ public class CreateIndexCqlGenerator extends IndexNameCqlGenerator<CreateIndexSp
|
||||
|
||||
List<String> entries = new ArrayList<>(options.size());
|
||||
|
||||
options.forEach((key, value) -> entries.add(String.format("'%s': '%s'",
|
||||
CqlStringUtils.escapeSingle(key), CqlStringUtils.escapeSingle(value))));
|
||||
options.forEach((key, value) -> entries
|
||||
.add(String.format("'%s': '%s'", CqlStringUtils.escapeSingle(key), CqlStringUtils.escapeSingle(value))));
|
||||
|
||||
StringBuilder optionsCql = new StringBuilder(" WITH OPTIONS = ").append("{");
|
||||
|
||||
|
||||
@@ -50,8 +50,7 @@ public class CreateKeyspaceCqlGenerator extends KeyspaceOptionsCqlGenerator<Crea
|
||||
}
|
||||
|
||||
private void preambleCql(StringBuilder cql) {
|
||||
cql.append("CREATE KEYSPACE ").append(spec().getIfNotExists() ? "IF NOT EXISTS " : "")
|
||||
.append(spec().getName());
|
||||
cql.append("CREATE KEYSPACE ").append(spec().getIfNotExists() ? "IF NOT EXISTS " : "").append(spec().getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -59,8 +59,7 @@ public class CreateUserTypeCqlGenerator extends UserTypeNameCqlGenerator<CreateU
|
||||
|
||||
private StringBuilder preambleCql(StringBuilder cql) {
|
||||
|
||||
return cql.append("CREATE TYPE ").append(spec().getIfNotExists() ? "IF NOT EXISTS " : "")
|
||||
.append(spec().getName());
|
||||
return cql.append("CREATE TYPE ").append(spec().getIfNotExists() ? "IF NOT EXISTS " : "").append(spec().getName());
|
||||
}
|
||||
|
||||
private StringBuilder columns(StringBuilder cql) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DropKeyspaceCqlGenerator extends KeyspaceNameCqlGenerator<DropKeysp
|
||||
|
||||
@Override
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
return cql.append("DROP KEYSPACE ").append(spec().getIfExists() ? "IF EXISTS " : "")
|
||||
.append(spec().getName()).append(";");
|
||||
return cql.append("DROP KEYSPACE ").append(spec().getIfExists() ? "IF EXISTS " : "").append(spec().getName())
|
||||
.append(";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,7 @@ public class DropTableCqlGenerator extends TableNameCqlGenerator<DropTableSpecif
|
||||
|
||||
DropTableSpecification specification = spec();
|
||||
|
||||
return cql.append("DROP TABLE ")
|
||||
.append(specification.getIfExists() ? "IF EXISTS " : "")
|
||||
return cql.append("DROP TABLE ").append(specification.getIfExists() ? "IF EXISTS " : "")
|
||||
.append(specification.getName()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class RenameColumnCqlGenerator extends ColumnChangeCqlGenerator<RenameCol
|
||||
* @see org.springframework.data.cassandra.core.cql.generator.ColumnChangeCqlGenerator#toCql(java.lang.StringBuilder)
|
||||
*/
|
||||
public StringBuilder toCql(StringBuilder cql) {
|
||||
return cql.append(keyword).append(' ').append(spec().getName()).append(" TO ")
|
||||
.append(spec().getTargetName());
|
||||
return cql.append(keyword).append(' ').append(spec().getName()).append(" TO ").append(spec().getTargetName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,21 @@ import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.data.cassandra.ReactiveResultSet;
|
||||
import org.springframework.data.cassandra.ReactiveSession;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.datastax.driver.core.*;
|
||||
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.Row;
|
||||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.SimpleStatement;
|
||||
import com.datastax.driver.core.Statement;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
|
||||
@@ -102,15 +102,14 @@ public class CachedPreparedStatementCreator implements PreparedStatementCreator
|
||||
* @param queryOptions must not be {@literal null}.
|
||||
* @return the {@link CachedPreparedStatementCreator} for {@code cql}.
|
||||
*/
|
||||
public static CachedPreparedStatementCreator of(PreparedStatementCache cache, String cql,
|
||||
QueryOptions queryOptions) {
|
||||
public static CachedPreparedStatementCreator of(PreparedStatementCache cache, String cql, QueryOptions queryOptions) {
|
||||
|
||||
Assert.notNull(cache, "Cache must not be null");
|
||||
Assert.hasText(cql, "CQL statement is required");
|
||||
Assert.notNull(queryOptions, "QueryOptions must not be null");
|
||||
|
||||
return new CachedPreparedStatementCreator(cache,
|
||||
QueryOptionsUtil.addQueryOptions(new SimpleStatement(cql), queryOptions));
|
||||
QueryOptionsUtil.addQueryOptions(new SimpleStatement(cql), queryOptions));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.mapping;
|
||||
|
||||
import static org.springframework.data.cassandra.core.cql.CqlIdentifier.of;
|
||||
import static org.springframework.data.cassandra.core.cql.CqlIdentifier.*;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Optional;
|
||||
@@ -51,8 +51,7 @@ import com.datastax.driver.core.UserType;
|
||||
public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T, CassandraPersistentProperty>
|
||||
implements CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
|
||||
private static final CassandraPersistentEntityMetadataVerifier DEFAULT_VERIFIER =
|
||||
new CompositeCassandraPersistentEntityMetadataVerifier();
|
||||
private static final CassandraPersistentEntityMetadataVerifier DEFAULT_VERIFIER = new CompositeCassandraPersistentEntityMetadataVerifier();
|
||||
|
||||
private Boolean forceQuote;
|
||||
|
||||
@@ -103,7 +102,6 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
|
||||
setVerifier(verifier);
|
||||
}
|
||||
|
||||
|
||||
protected CqlIdentifier determineTableName() {
|
||||
|
||||
Table annotation = findAnnotation(Table.class);
|
||||
@@ -121,9 +119,7 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
|
||||
return of(getType().getSimpleName(), forceQuote);
|
||||
}
|
||||
|
||||
String name = Optional.ofNullable(this.spelContext)
|
||||
.map(it -> SpelUtils.evaluate(value, it))
|
||||
.orElse(value);
|
||||
String name = Optional.ofNullable(this.spelContext).map(it -> SpelUtils.evaluate(value, it)).orElse(value);
|
||||
|
||||
Assert.state(name != null, () -> String.format("Cannot determine default name for %s", this));
|
||||
|
||||
@@ -142,8 +138,7 @@ public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T,
|
||||
* @see org.springframework.data.mapping.model.BasicPersistentEntity#doWithAssociations(org.springframework.data.mapping.AssociationHandler)
|
||||
*/
|
||||
@Override
|
||||
public void doWithAssociations(AssociationHandler<CassandraPersistentProperty> handler) {
|
||||
}
|
||||
public void doWithAssociations(AssociationHandler<CassandraPersistentProperty> handler) {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.mapping.CassandraPersistentEntity#isCompositePrimaryKey()
|
||||
|
||||
@@ -83,8 +83,8 @@ public class BasicCassandraPersistentEntityMetadataVerifier implements Cassandra
|
||||
|
||||
// Can only have one PK
|
||||
if (idProperties.size() != 1) {
|
||||
exceptions.add(new MappingException(
|
||||
String.format("@%s types must have only one primary attribute, if any; Found %s",
|
||||
exceptions
|
||||
.add(new MappingException(String.format("@%s types must have only one primary attribute, if any; Found %s",
|
||||
Table.class.getSimpleName(), idProperties.size())));
|
||||
|
||||
fail(entity, exceptions);
|
||||
@@ -102,8 +102,8 @@ public class BasicCassandraPersistentEntityMetadataVerifier implements Cassandra
|
||||
|
||||
// We have no PKs & only PK Column(s); ensure at least one is of type PARTITIONED
|
||||
if (!primaryKeyColumns.isEmpty() && partitionKeyColumns.isEmpty()) {
|
||||
exceptions.add(new MappingException(
|
||||
String.format("At least one of the @%s annotations must have a type of PARTITIONED",
|
||||
exceptions
|
||||
.add(new MappingException(String.format("At least one of the @%s annotations must have a type of PARTITIONED",
|
||||
PrimaryKeyColumn.class.getSimpleName())));
|
||||
}
|
||||
|
||||
|
||||
@@ -134,8 +134,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
this.columnName = determineColumnName();
|
||||
}
|
||||
|
||||
Assert.state(this.columnName != null,
|
||||
() -> String.format("Cannot determine column name for %s", this));
|
||||
Assert.state(this.columnName != null, () -> String.format("Cannot determine column name for %s", this));
|
||||
|
||||
return this.columnName;
|
||||
}
|
||||
@@ -172,7 +171,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException(String.format(
|
||||
"Unknown type [%s] for property [%s] in entity [%s]; only primitive types and Collections or Maps of primitive types are allowed",
|
||||
getType(), getName(), getOwner().getName()));
|
||||
getType(), getName(), getOwner().getName()));
|
||||
}
|
||||
|
||||
return dataType;
|
||||
@@ -266,7 +265,7 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException(String.format(
|
||||
"Only primitive types are allowed inside Collections for property [%1$s] of type ['%2$s'] in entity [%3$s]",
|
||||
getName(), getType(), getOwner().getName()));
|
||||
getName(), getType(), getOwner().getName()));
|
||||
}
|
||||
|
||||
return dataType;
|
||||
@@ -275,9 +274,9 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
private void assertTypeArguments(int args, int expected) {
|
||||
|
||||
if (args != expected) {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
String.format("Expected [%1$s] type arguments for property ['%2$s'] of type ['%3$s'] in entity [%4$s]; actual was [%5$d]",
|
||||
expected, getName(), getType(), getOwner().getName(), args));
|
||||
throw new InvalidDataAccessApiUsageException(String.format(
|
||||
"Expected [%1$s] type arguments for property ['%2$s'] of type ['%3$s'] in entity [%4$s]; actual was [%5$d]",
|
||||
expected, getName(), getType(), getOwner().getName(), args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +429,8 @@ public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentP
|
||||
@Override
|
||||
public AnnotatedType findAnnotatedType(Class<? extends Annotation> annotationType) {
|
||||
|
||||
return Optionals.toStream(Optional.ofNullable(getField()).map(Field::getAnnotatedType),
|
||||
return Optionals
|
||||
.toStream(Optional.ofNullable(getField()).map(Field::getAnnotatedType),
|
||||
Optional.ofNullable(getGetter()).map(Method::getAnnotatedReturnType),
|
||||
Optional.ofNullable(getSetter()).map(it -> it.getParameters()[0].getAnnotatedType()))
|
||||
.filter(it -> hasAnnotation(it, annotationType, getTypeInformation())).findFirst().orElse(null);
|
||||
|
||||
@@ -59,10 +59,8 @@ public class BasicCassandraPersistentTupleEntity<T> extends BasicCassandraPersis
|
||||
|
||||
private List<DataType> getTupleFieldDataTypes() {
|
||||
|
||||
return StreamSupport.stream(spliterator(), false)
|
||||
.sorted(TuplePropertyComparator.INSTANCE)
|
||||
.map(CassandraPersistentProperty::getDataType)
|
||||
.collect(Collectors.toList());
|
||||
return StreamSupport.stream(spliterator(), false).sorted(TuplePropertyComparator.INSTANCE)
|
||||
.map(CassandraPersistentProperty::getDataType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -75,13 +75,14 @@ public class BasicCassandraPersistentTupleProperty extends BasicCassandraPersist
|
||||
ordinal = getRequiredAnnotation(Element.class).value();
|
||||
} catch (IllegalStateException cause) {
|
||||
throw new MappingException(
|
||||
String.format("Missing @Element annotation in mapped tuple type for property [%s] in entity [%s]",
|
||||
getName(), getOwner().getName()), cause);
|
||||
String.format("Missing @Element annotation in mapped tuple type for property [%s] in entity [%s]", getName(),
|
||||
getOwner().getName()),
|
||||
cause);
|
||||
}
|
||||
|
||||
Assert.isTrue(ordinal >= 0,
|
||||
String.format("Element ordinal must be greater or equal to zero for property [%s] in entity [%s]",
|
||||
getName(), getOwner().getName()));
|
||||
String.format("Element ordinal must be greater or equal to zero for property [%s] in entity [%s]", getName(),
|
||||
getOwner().getName()));
|
||||
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@@ -294,8 +294,8 @@ public class CassandraMappingContext
|
||||
}
|
||||
// now do some caching of the entity
|
||||
|
||||
Set<CassandraPersistentEntity<?>> entities =
|
||||
this.entitySetsByTableName.computeIfAbsent(entity.getTableName(), cqlIdentifier -> new HashSet<>());
|
||||
Set<CassandraPersistentEntity<?>> entities = this.entitySetsByTableName.computeIfAbsent(entity.getTableName(),
|
||||
cqlIdentifier -> new HashSet<>());
|
||||
|
||||
entities.add(entity);
|
||||
|
||||
@@ -324,10 +324,9 @@ public class CassandraMappingContext
|
||||
protected <T> BasicCassandraPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
|
||||
BasicCassandraPersistentEntity<T> entity = isUserDefinedType(typeInformation)
|
||||
? new CassandraUserTypePersistentEntity<>(typeInformation, getVerifier(), resolveUserTypeResolver())
|
||||
: isTuple(typeInformation)
|
||||
? new BasicCassandraPersistentTupleEntity<>(typeInformation, getTupleTypeFactory())
|
||||
: new BasicCassandraPersistentEntity<>(typeInformation, getVerifier());
|
||||
? new CassandraUserTypePersistentEntity<>(typeInformation, getVerifier(), resolveUserTypeResolver())
|
||||
: isTuple(typeInformation) ? new BasicCassandraPersistentTupleEntity<>(typeInformation, getTupleTypeFactory())
|
||||
: new BasicCassandraPersistentEntity<>(typeInformation, getVerifier());
|
||||
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(entity::setApplicationContext);
|
||||
|
||||
@@ -360,8 +359,8 @@ public class CassandraMappingContext
|
||||
BasicCassandraPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||
|
||||
BasicCassandraPersistentProperty persistentProperty = owner.isTupleType()
|
||||
? new BasicCassandraPersistentTupleProperty(property, owner, simpleTypeHolder, getUserTypeResolver())
|
||||
: new BasicCassandraPersistentProperty(property, owner, simpleTypeHolder, getUserTypeResolver());
|
||||
? new BasicCassandraPersistentTupleProperty(property, owner, simpleTypeHolder, getUserTypeResolver())
|
||||
: new BasicCassandraPersistentProperty(property, owner, simpleTypeHolder, getUserTypeResolver());
|
||||
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(persistentProperty::setApplicationContext);
|
||||
|
||||
@@ -403,9 +402,7 @@ public class CassandraMappingContext
|
||||
|
||||
return getPersistentEntities().stream().flatMap(entity -> StreamSupport.stream(entity.spliterator(), false))
|
||||
.flatMap(it -> Optionals.toStream(Optional.ofNullable(it.findAnnotation(CassandraType.class))))
|
||||
.map(CassandraType::userTypeName)
|
||||
.filter(StringUtils::hasText)
|
||||
.map(CqlIdentifier::of)
|
||||
.map(CassandraType::userTypeName).filter(StringUtils::hasText).map(CqlIdentifier::of)
|
||||
.anyMatch(identifier::equals);
|
||||
}
|
||||
|
||||
@@ -548,8 +545,7 @@ public class CassandraMappingContext
|
||||
|
||||
if (annotation.type() == Name.TUPLE) {
|
||||
|
||||
DataType[] dataTypes = Arrays.stream(annotation.typeArguments())
|
||||
.map(CassandraSimpleTypeHolder::getDataTypeFor)
|
||||
DataType[] dataTypes = Arrays.stream(annotation.typeArguments()).map(CassandraSimpleTypeHolder::getDataTypeFor)
|
||||
.toArray(DataType[]::new);
|
||||
|
||||
return getTupleTypeFactory().create(dataTypes);
|
||||
|
||||
@@ -65,8 +65,7 @@ public interface CassandraPersistentProperty
|
||||
|
||||
CqlIdentifier columnName = getColumnName();
|
||||
|
||||
Assert.state(columnName != null,
|
||||
String.format("No column name available for this persistent property [%1$s.%2$s]",
|
||||
Assert.state(columnName != null, String.format("No column name available for this persistent property [%1$s.%2$s]",
|
||||
getOwner().getName(), getName()));
|
||||
|
||||
return columnName;
|
||||
@@ -105,8 +104,7 @@ public interface CassandraPersistentProperty
|
||||
|
||||
Integer ordinal = getOrdinal();
|
||||
|
||||
Assert.state(ordinal != null ,
|
||||
String.format("No ordinal available for this persistent property [%1$s.%2$s]",
|
||||
Assert.state(ordinal != null, String.format("No ordinal available for this persistent property [%1$s.%2$s]",
|
||||
getOwner().getName(), getName()));
|
||||
|
||||
return ordinal;
|
||||
|
||||
@@ -53,15 +53,14 @@ enum CassandraPersistentTupleMetadataVerifier implements CassandraPersistentEnti
|
||||
}
|
||||
|
||||
if (!ordinals.add(tupleProperty.getOrdinal())) {
|
||||
throw new MappingException(String.format("Duplicate ordinal [%d] in entity [%s]",
|
||||
tupleProperty.getOrdinal(), entity.getName()));
|
||||
throw new MappingException(
|
||||
String.format("Duplicate ordinal [%d] in entity [%s]", tupleProperty.getOrdinal(), entity.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (ordinals.isEmpty()) {
|
||||
throw new MappingException(
|
||||
String.format("Mapped tuple contains no persistent elements annotated with @Element in entity [%s]",
|
||||
entity.getName()));
|
||||
throw new MappingException(String.format(
|
||||
"Mapped tuple contains no persistent elements annotated with @Element in entity [%s]", entity.getName()));
|
||||
}
|
||||
|
||||
List<Integer> missingMappings = IntStream.range(0, ordinals.size()).boxed().collect(Collectors.toList());
|
||||
|
||||
@@ -151,11 +151,8 @@ public class CassandraSimpleTypeHolder extends SimpleTypeHolder {
|
||||
*/
|
||||
private static Set<Class<?>> getCassandraPrimitiveTypes(CodecRegistry codecRegistry) {
|
||||
|
||||
return DataType.allPrimitiveTypes().stream()
|
||||
.map(codecRegistry::codecFor)
|
||||
.map(TypeCodec::getJavaType)
|
||||
.map(TypeToken::getRawType)
|
||||
.collect(Collectors.toSet());
|
||||
return DataType.allPrimitiveTypes().stream().map(codecRegistry::codecFor).map(TypeCodec::getJavaType)
|
||||
.map(TypeToken::getRawType).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,7 +145,7 @@ public class EntityMapping {
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"{ @type = %1$s, entityClassName = %2$s, tableName = %3$s, forceQuote = %4$s, propertyMappings = %5$s }",
|
||||
"{ @type = %1$s, entityClassName = %2$s, tableName = %3$s, forceQuote = %4$s, propertyMappings = %5$s }",
|
||||
getClass().getName(), getEntityClassName(), getTableName(), getForceQuote(), toString(getPropertyMappings()));
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,12 @@ class IndexSpecificationFactory {
|
||||
AnnotatedParameterizedType parameterizedType = (AnnotatedParameterizedType) type;
|
||||
AnnotatedType[] typeArgs = parameterizedType.getAnnotatedActualTypeArguments();
|
||||
|
||||
Indexed keyIndex = typeArgs.length == 2
|
||||
? AnnotatedElementUtils.getMergedAnnotation(typeArgs[0], Indexed.class) : null;
|
||||
Indexed keyIndex = typeArgs.length == 2 ? AnnotatedElementUtils.getMergedAnnotation(typeArgs[0], Indexed.class)
|
||||
: null;
|
||||
|
||||
Indexed valueIndex = typeArgs.length == 2
|
||||
? AnnotatedElementUtils.getMergedAnnotation(typeArgs[1], Indexed.class) : null;
|
||||
? AnnotatedElementUtils.getMergedAnnotation(typeArgs[1], Indexed.class)
|
||||
: null;
|
||||
|
||||
if ((!indexes.isEmpty() && (keyIndex != null || valueIndex != null))
|
||||
|| (keyIndex != null && valueIndex != null)) {
|
||||
@@ -152,8 +153,8 @@ class IndexSpecificationFactory {
|
||||
long analyzerCount = INDEX_CONFIGURERS.keySet().stream().filter(property::isAnnotationPresent).count();
|
||||
|
||||
if (analyzerCount > 1) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"SASI indexed property %s must be annotated only with a single analyzer annotation", property));
|
||||
throw new IllegalStateException(
|
||||
String.format("SASI indexed property %s must be annotated only with a single analyzer annotation", property));
|
||||
}
|
||||
|
||||
for (Class<? extends Annotation> annotationType : INDEX_CONFIGURERS.keySet()) {
|
||||
|
||||
@@ -64,8 +64,8 @@ public class PrimaryKeyClassEntityMetadataVerifier implements CassandraPersisten
|
||||
|
||||
// Ensure PrimaryKeyClass only extends Object
|
||||
if (!entityType.getSuperclass().equals(Object.class)) {
|
||||
exceptions.add(new MappingException(String.format("@%s must only extend Object",
|
||||
PrimaryKeyClass.class.getSimpleName())));
|
||||
exceptions.add(
|
||||
new MappingException(String.format("@%s must only extend Object", PrimaryKeyClass.class.getSimpleName())));
|
||||
}
|
||||
|
||||
entity.forEach(property -> {
|
||||
@@ -82,29 +82,29 @@ public class PrimaryKeyClassEntityMetadataVerifier implements CassandraPersisten
|
||||
});
|
||||
|
||||
if (!compositePrimaryKeys.isEmpty()) {
|
||||
exceptions.add(new MappingException(
|
||||
"Composite primary keys are not allowed inside of composite primary key classes"));
|
||||
exceptions
|
||||
.add(new MappingException("Composite primary keys are not allowed inside of composite primary key classes"));
|
||||
}
|
||||
|
||||
// Must have at least 1 attribute annotated with @PrimaryKeyColumn
|
||||
if (primaryKeyColumns.isEmpty()) {
|
||||
exceptions.add(new MappingException(String.format(
|
||||
"Composite primary key type [%1$s] has no fields annotated with @%2$s",
|
||||
entity.getType().getName(), PrimaryKeyColumn.class.getSimpleName())));
|
||||
exceptions.add(
|
||||
new MappingException(String.format("Composite primary key type [%1$s] has no fields annotated with @%2$s",
|
||||
entity.getType().getName(), PrimaryKeyColumn.class.getSimpleName())));
|
||||
}
|
||||
|
||||
// At least one of the PrimaryKeyColumns must have a type PARTIONED
|
||||
if (partitionKeyColumns.isEmpty()) {
|
||||
exceptions.add(new MappingException(String.format(
|
||||
"At least one of the @%s annotations must have a type of PARTITIONED",
|
||||
PrimaryKeyColumn.class.getSimpleName())));
|
||||
exceptions
|
||||
.add(new MappingException(String.format("At least one of the @%s annotations must have a type of PARTITIONED",
|
||||
PrimaryKeyColumn.class.getSimpleName())));
|
||||
}
|
||||
|
||||
// Cannot have any Id or PrimaryKey Annotations
|
||||
if (!idProperties.isEmpty()) {
|
||||
exceptions.add(new MappingException(String.format(
|
||||
"Annotations @%1$s and @%2$s are invalid for type annotated with @%3$s",
|
||||
Id.class.getSimpleName(), PrimaryKey.class.getSimpleName(), PrimaryKeyClass.class.getSimpleName())));
|
||||
exceptions.add(
|
||||
new MappingException(String.format("Annotations @%1$s and @%2$s are invalid for type annotated with @%3$s",
|
||||
Id.class.getSimpleName(), PrimaryKey.class.getSimpleName(), PrimaryKeyClass.class.getSimpleName())));
|
||||
}
|
||||
|
||||
// Determine whether or not to throw Exception based on errors found
|
||||
|
||||
@@ -198,8 +198,7 @@ public class CassandraPageRequest extends PageRequest {
|
||||
|
||||
Assert.state(hasNext(), "Cannot create a next page request without a PagingState");
|
||||
|
||||
return new CassandraPageRequest(getPageNumber() + 1, getPageSize(), getSort(),
|
||||
this.pagingState, false);
|
||||
return new CassandraPageRequest(getPageNumber() + 1, getPageSize(), getSort(), this.pagingState, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.query;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -115,9 +115,7 @@ public interface CriteriaDefinition {
|
||||
*/
|
||||
enum Operators implements Operator {
|
||||
|
||||
CONTAINS("CONTAINS"),
|
||||
CONTAINS_KEY("CONTAINS KEY"),
|
||||
EQ("="),
|
||||
CONTAINS("CONTAINS"), CONTAINS_KEY("CONTAINS KEY"), EQ("="),
|
||||
|
||||
/**
|
||||
* @since 2.1
|
||||
@@ -134,12 +132,7 @@ public interface CriteriaDefinition {
|
||||
}
|
||||
},
|
||||
|
||||
GT(">"),
|
||||
GTE(">="),
|
||||
LT("<"),
|
||||
LTE("<="),
|
||||
IN("IN"),
|
||||
LIKE("LIKE");
|
||||
GT(">"), GTE(">="), LT("<"), LTE("<="), IN("IN"), LIKE("LIKE");
|
||||
|
||||
public static Optional<Operators> from(String operator) {
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.query;
|
||||
|
||||
import static java.util.stream.StreamSupport.stream;
|
||||
import static org.springframework.util.ObjectUtils.nullSafeEquals;
|
||||
import static org.springframework.util.ObjectUtils.nullSafeHashCode;
|
||||
import static java.util.stream.StreamSupport.*;
|
||||
import static org.springframework.util.ObjectUtils.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -108,11 +107,10 @@ public class Query implements Filter {
|
||||
|
||||
Assert.notNull(criteriaDefinitions, "CriteriaDefinitions must not be null");
|
||||
|
||||
List<CriteriaDefinition> collect = stream(criteriaDefinitions.spliterator(), false)
|
||||
.collect(Collectors.toList());
|
||||
List<CriteriaDefinition> collect = stream(criteriaDefinitions.spliterator(), false).collect(Collectors.toList());
|
||||
|
||||
return new Query(collect, Columns.empty(), Sort.unsorted(), Optional.empty(), Optional.empty(),
|
||||
Optional.empty(), false);
|
||||
return new Query(collect, Columns.empty(), Sort.unsorted(), Optional.empty(), Optional.empty(), Optional.empty(),
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,8 +182,8 @@ public class Query implements Filter {
|
||||
}
|
||||
}
|
||||
|
||||
return new Query(this.criteriaDefinitions, this.columns, this.sort.and(sort), this.pagingState,
|
||||
this.queryOptions, this.limit, this.allowFiltering);
|
||||
return new Query(this.criteriaDefinitions, this.columns, this.sort.and(sort), this.pagingState, this.queryOptions,
|
||||
this.limit, this.allowFiltering);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,8 +287,8 @@ public class Query implements Filter {
|
||||
* @return a new {@link Query} object containing the former settings with {@code allowFiltering} applied.
|
||||
*/
|
||||
public Query withAllowFiltering() {
|
||||
return new Query(this.criteriaDefinitions, this.columns, this.sort, this.pagingState, this.queryOptions,
|
||||
this.limit, true);
|
||||
return new Query(this.criteriaDefinitions, this.columns, this.sort, this.pagingState, this.queryOptions, this.limit,
|
||||
true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,8 +360,7 @@ public class Query implements Filter {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
String query = stream(this.spliterator(), false)
|
||||
.map(SerializationUtils::serializeToCqlSafely)
|
||||
String query = stream(this.spliterator(), false).map(SerializationUtils::serializeToCqlSafely)
|
||||
.collect(Collectors.joining(" AND "));
|
||||
|
||||
return String.format("Query: %s, Columns: %s, Sort: %s, Limit: %d", query, getColumns(), getSort(), getLimit());
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.query;
|
||||
|
||||
import static org.springframework.data.cassandra.core.query.SerializationUtils.serializeToCqlSafely;
|
||||
import static org.springframework.data.cassandra.core.query.SerializationUtils.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -95,8 +95,8 @@ public abstract class AbstractCassandraQuery extends CassandraRepositoryQuerySup
|
||||
|
||||
Statement statement = createQuery(parameterAccessor);
|
||||
|
||||
CassandraQueryExecution queryExecution = getExecution(parameterAccessor, new ResultProcessingConverter(
|
||||
resultProcessor, toMappingContext(getOperations()), getEntityInstantiators()));
|
||||
CassandraQueryExecution queryExecution = getExecution(parameterAccessor,
|
||||
new ResultProcessingConverter(resultProcessor, toMappingContext(getOperations()), getEntityInstantiators()));
|
||||
|
||||
Class<?> resultType = resolveResultType(resultProcessor);
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ public class CassandraQueryMethod extends QueryMethod {
|
||||
CassandraPersistentEntity<?> returnedEntity = this.mappingContext.getPersistentEntity(returnedObjectType);
|
||||
CassandraPersistentEntity<?> managedEntity = this.mappingContext.getRequiredPersistentEntity(domainClass);
|
||||
|
||||
returnedEntity = returnedEntity == null || returnedEntity.getType().isInterface()
|
||||
? managedEntity : returnedEntity;
|
||||
returnedEntity = returnedEntity == null || returnedEntity.getType().isInterface() ? managedEntity
|
||||
: returnedEntity;
|
||||
|
||||
this.entityMetadata = new SimpleCassandraEntityMetadata<>((Class<Object>) returnedEntity.getType(),
|
||||
managedEntity);
|
||||
|
||||
@@ -106,7 +106,6 @@ class ConvertingParameterAccessor implements CassandraParameterAccessor {
|
||||
return this.delegate.getDataType(index);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.repository.query.CassandraParameterAccessor#getParameterType(int)
|
||||
*/
|
||||
@@ -155,16 +154,15 @@ class ConvertingParameterAccessor implements CassandraParameterAccessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.converter.convertToColumnType(bindableValue,
|
||||
findTypeInformation(index, bindableValue, null));
|
||||
return this.converter.convertToColumnType(bindableValue, findTypeInformation(index, bindableValue, null));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private Object potentiallyConvert(int index, @Nullable Object bindableValue, CassandraPersistentProperty property) {
|
||||
|
||||
return (bindableValue == null ? null : this.converter.convertToColumnType(bindableValue,
|
||||
findTypeInformation(index, bindableValue, property)));
|
||||
return (bindableValue == null ? null
|
||||
: this.converter.convertToColumnType(bindableValue, findTypeInformation(index, bindableValue, property)));
|
||||
}
|
||||
|
||||
private TypeInformation<?> findTypeInformation(int index, Object bindableValue,
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.query;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import com.datastax.driver.core.ColumnDefinitions;
|
||||
import com.datastax.driver.core.DataType;
|
||||
import com.datastax.driver.core.Row;
|
||||
@@ -48,9 +48,8 @@ class ProjectionUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the {@link Row} qualifies as a count projection.
|
||||
*
|
||||
* Count projection candidates have a single numeric column.
|
||||
* Determine whether the {@link Row} qualifies as a count projection. Count projection candidates have a single
|
||||
* numeric column.
|
||||
*
|
||||
* @param row {@link Row} to evaluate for a count projection.
|
||||
* @return a boolean value indicating whether the {@link Row} qualifies as a count projection.
|
||||
|
||||
@@ -47,14 +47,14 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
|
||||
|
||||
/**
|
||||
* Create a new {@link ReactiveStringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
|
||||
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser},
|
||||
* and {@link QueryMethodEvaluationContextProvider}.
|
||||
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser}, and
|
||||
* {@link QueryMethodEvaluationContextProvider}.
|
||||
*
|
||||
* @param queryMethod {@link ReactiveCassandraQueryMethod} on which this query is based.
|
||||
* @param operations {@link ReactiveCassandraOperations} used to perform data access in Cassandra.
|
||||
* @param expressionParser {@link SpelExpressionParser} used to parse expressions in the query.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access
|
||||
* the potentially shared {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access the potentially shared
|
||||
* {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @see org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryMethod
|
||||
* @see org.springframework.data.cassandra.core.ReactiveCassandraOperations
|
||||
*/
|
||||
@@ -62,20 +62,19 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
|
||||
ReactiveCassandraOperations operations, SpelExpressionParser expressionParser,
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
this(queryMethod.getRequiredAnnotatedQuery(), queryMethod, operations, expressionParser,
|
||||
evaluationContextProvider);
|
||||
this(queryMethod.getRequiredAnnotatedQuery(), queryMethod, operations, expressionParser, evaluationContextProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link ReactiveStringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
|
||||
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser},
|
||||
* and {@link QueryMethodEvaluationContextProvider}.
|
||||
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser}, and
|
||||
* {@link QueryMethodEvaluationContextProvider}.
|
||||
*
|
||||
* @param method {@link ReactiveCassandraQueryMethod} on which this query is based.
|
||||
* @param operations {@link ReactiveCassandraOperations} used to perform data access in Cassandra.
|
||||
* @param expressionParser {@link SpelExpressionParser} used to parse expressions in the query.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access
|
||||
* the potentially shared {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access the potentially shared
|
||||
* {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @see org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryMethod
|
||||
* @see org.springframework.data.cassandra.core.ReactiveCassandraOperations
|
||||
*/
|
||||
|
||||
@@ -51,16 +51,15 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
|
||||
* @param queryMethod {@link CassandraQueryMethod} on which this query is based.
|
||||
* @param operations {@link CassandraOperations} used to perform data access in Cassandra.
|
||||
* @param expressionParser {@link SpelExpressionParser} used to parse expressions in the query.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access
|
||||
* the potentially shared {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access the potentially shared
|
||||
* {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @see org.springframework.data.cassandra.repository.query.CassandraQueryMethod
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations
|
||||
*/
|
||||
public StringBasedCassandraQuery(CassandraQueryMethod queryMethod, CassandraOperations operations,
|
||||
SpelExpressionParser expressionParser, QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
this(queryMethod.getRequiredAnnotatedQuery(), queryMethod, operations, expressionParser,
|
||||
evaluationContextProvider);
|
||||
this(queryMethod.getRequiredAnnotatedQuery(), queryMethod, operations, expressionParser, evaluationContextProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,8 +70,8 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
|
||||
* @param method {@link CassandraQueryMethod} on which this query is based.
|
||||
* @param operations {@link CassandraOperations} used to perform data access in Cassandra.
|
||||
* @param expressionParser {@link SpelExpressionParser} used to parse expressions in the query.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access
|
||||
* the potentially shared {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @param evaluationContextProvider {@link QueryMethodEvaluationContextProvider} used to access the potentially shared
|
||||
* {@link org.springframework.expression.spel.support.StandardEvaluationContext}.
|
||||
* @see org.springframework.data.cassandra.repository.query.CassandraQueryMethod
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations
|
||||
*/
|
||||
|
||||
@@ -223,7 +223,8 @@ class StringBasedQuery {
|
||||
.expression(input.substring(exprStart + 3, currentPosition - 1), true));
|
||||
} else {
|
||||
if (matcher.pattern() == INDEX_PARAMETER_BINDING_PATTERN) {
|
||||
bindings.add(ExpressionEvaluatingParameterBinder.ParameterBinding.indexed(Integer.parseInt(matcher.group(1))));
|
||||
bindings
|
||||
.add(ExpressionEvaluatingParameterBinder.ParameterBinding.indexed(Integer.parseInt(matcher.group(1))));
|
||||
} else {
|
||||
bindings.add(ExpressionEvaluatingParameterBinder.ParameterBinding.named(matcher.group(1)));
|
||||
}
|
||||
|
||||
@@ -120,7 +120,8 @@ public class CassandraRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
private final CassandraOperations operations;
|
||||
|
||||
CassandraQueryLookupStrategy(CassandraOperations operations, QueryMethodEvaluationContextProvider evaluationContextProvider,
|
||||
CassandraQueryLookupStrategy(CassandraOperations operations,
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider,
|
||||
MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext) {
|
||||
|
||||
this.operations = operations;
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.support;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraPersistentEntity;
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ public class MappingCassandraEntityInformation<T, ID> extends PersistentEntityIn
|
||||
|
||||
CassandraPersistentProperty idProperty = this.entityMetadata.getIdProperty();
|
||||
|
||||
return idProperty != null
|
||||
? (ID) this.entityMetadata.getIdentifierAccessor(entity).getIdentifier()
|
||||
return idProperty != null ? (ID) this.entityMetadata.getIdentifierAccessor(entity).getIdentifier()
|
||||
: (ID) converter.getId(entity, entityMetadata);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
Mono<User> insert = template.insert(user);
|
||||
verifyUser(user.getId()).verifyComplete();
|
||||
|
||||
StepVerifier.create(insert).expectNext(user).verifyComplete();
|
||||
insert.as(StepVerifier::create).expectNext(user).verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).expectNext(user).verifyComplete();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
Mono<EntityWriteResult<User>> inserted = template.insert(user, lwtOptions);
|
||||
|
||||
StepVerifier.create(inserted).consumeNextWith(actual -> {
|
||||
inserted.as(StepVerifier::create).consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual.wasApplied()).isTrue();
|
||||
assertThat(actual.getEntity()).isSameAs(user);
|
||||
@@ -115,12 +115,12 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user, lwtOptions).map(WriteResult::wasApplied)).expectNext(true)
|
||||
template.insert(user, lwtOptions).map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true)
|
||||
.verifyComplete();
|
||||
|
||||
user.setFirstname("Walter Hartwell");
|
||||
|
||||
StepVerifier.create(template.insert(user, lwtOptions).map(WriteResult::wasApplied)).expectNext(false)
|
||||
template.insert(user, lwtOptions).map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(false)
|
||||
.verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).consumeNextWith(it -> assertThat(it.getFirstname()).isEqualTo("Walter")).verifyComplete();
|
||||
@@ -131,9 +131,9 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(template.count(User.class)).expectNext(1L).verifyComplete();
|
||||
template.count(User.class).as(StepVerifier::create).expectNext(1L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -141,13 +141,13 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(template.count(Query.query(where("id").is("heisenberg")), User.class)) //
|
||||
template.count(Query.query(where("id").is("heisenberg")), User.class).as(StepVerifier::create) //
|
||||
.expectNext(1L) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(template.count(Query.query(where("id").is("foo")), User.class)) //
|
||||
template.count(Query.query(where("id").is("foo")), User.class).as(StepVerifier::create) //
|
||||
.expectNext(0L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -157,13 +157,13 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(template.exists(Query.query(where("id").is("heisenberg")), User.class)) //
|
||||
template.exists(Query.query(where("id").is("heisenberg")), User.class).as(StepVerifier::create) //
|
||||
.expectNext(true) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(template.exists(Query.query(where("id").is("foo")), User.class)) //
|
||||
template.exists(Query.query(where("id").is("foo")), User.class).as(StepVerifier::create) //
|
||||
.expectNext(false) //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -173,11 +173,11 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
user.setFirstname("Walter Hartwell");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).expectNext(user).verifyComplete();
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.update(user, lwtOptions).map(WriteResult::wasApplied)).expectNext(false)
|
||||
template.update(user, lwtOptions).map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(false)
|
||||
.verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).verifyComplete();
|
||||
@@ -201,11 +201,11 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
UpdateOptions lwtOptions = UpdateOptions.builder().withIfExists().build();
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
user.setFirstname("Walter Hartwell");
|
||||
|
||||
StepVerifier.create(template.update(user, lwtOptions)).expectNextCount(1).verifyComplete();
|
||||
template.update(user, lwtOptions).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).consumeNextWith(it -> assertThat(it.getFirstname()).isEqualTo("Walter Hartwell"))
|
||||
.verifyComplete();
|
||||
@@ -257,9 +257,9 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(template.delete(user)).expectNext(user).verifyComplete();
|
||||
template.delete(user).as(StepVerifier::create).expectNext(user).verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).verifyComplete();
|
||||
}
|
||||
@@ -269,9 +269,9 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(template.deleteById(user.getId(), User.class)).expectNext(true).verifyComplete();
|
||||
template.deleteById(user.getId(), User.class).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
verifyUser(user.getId()).verifyComplete();
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build();
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
template.delete(user, lwtOptions).map(WriteResult::wasApplied) //
|
||||
.as(StepVerifier::create) //
|
||||
@@ -301,7 +301,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
DeleteOptions lwtOptions = DeleteOptions.builder().withIfExists().build();
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
StepVerifier.create(template.insert(user)).expectNextCount(1).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
Query query = Query.query(where("id").is("heisenberg")).queryOptions(lwtOptions);
|
||||
|
||||
@@ -417,7 +417,7 @@ public class ReactiveCassandraTemplateIntegrationTests extends AbstractKeyspaceC
|
||||
}
|
||||
|
||||
private FirstStep<User> verifyUser(String userId) {
|
||||
return StepVerifier.create(template.selectOneById(userId, User.class));
|
||||
return template.selectOneById(userId, User.class).as(StepVerifier::create);
|
||||
}
|
||||
|
||||
static class QueryListener implements LatencyTracker {
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
when(row.getObject(1)).thenReturn("Walter");
|
||||
when(row.getObject(2)).thenReturn("White");
|
||||
|
||||
StepVerifier.create(template.select("SELECT * FROM users", User.class)) //
|
||||
template.select("SELECT * FROM users", User.class).as(StepVerifier::create) //
|
||||
.expectNext(new User("myid", "Walter", "White")) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
when(reactiveResultSet.rows()).thenThrow(new NoHostAvailableException(Collections.emptyMap()));
|
||||
|
||||
StepVerifier.create(template.select("SELECT * FROM users", User.class)) //
|
||||
template.select("SELECT * FROM users", User.class).as(StepVerifier::create) //
|
||||
.consumeErrorWith(e -> {
|
||||
assertThat(e).hasRootCauseInstanceOf(NoHostAvailableException.class);
|
||||
}).verify();
|
||||
@@ -126,7 +126,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
when(row.getObject(1)).thenReturn("Walter");
|
||||
when(row.getObject(2)).thenReturn("White");
|
||||
|
||||
StepVerifier.create(template.selectOneById("myid", User.class)) //
|
||||
template.selectOneById("myid", User.class).as(StepVerifier::create) //
|
||||
.expectNext(new User("myid", "Walter", "White")) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -161,7 +161,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
|
||||
|
||||
StepVerifier.create(template.exists("myid", User.class)).expectNext(true).verifyComplete();
|
||||
template.exists("myid", User.class).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';");
|
||||
@@ -172,7 +172,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
when(reactiveResultSet.rows()).thenReturn(Flux.empty());
|
||||
|
||||
StepVerifier.create(template.exists("myid", User.class)).expectNext(false).verifyComplete();
|
||||
template.exists("myid", User.class).as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users WHERE id='myid';");
|
||||
@@ -183,7 +183,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
|
||||
|
||||
StepVerifier.create(template.exists(Query.empty(), User.class)).expectNext(true).verifyComplete();
|
||||
template.exists(Query.empty(), User.class).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users LIMIT 1;");
|
||||
@@ -194,7 +194,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
when(reactiveResultSet.rows()).thenReturn(Flux.empty());
|
||||
|
||||
StepVerifier.create(template.exists(Query.empty(), User.class)).expectNext(false).verifyComplete();
|
||||
template.exists(Query.empty(), User.class).as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT * FROM users LIMIT 1;");
|
||||
@@ -207,7 +207,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
when(row.getLong(0)).thenReturn(42L);
|
||||
when(columnDefinitions.size()).thenReturn(1);
|
||||
|
||||
StepVerifier.create(template.count(User.class)).expectNext(42L).verifyComplete();
|
||||
template.count(User.class).as(StepVerifier::create).expectNext(42L).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT count(*) FROM users;");
|
||||
@@ -220,7 +220,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
when(row.getLong(0)).thenReturn(42L);
|
||||
when(columnDefinitions.size()).thenReturn(1);
|
||||
|
||||
StepVerifier.create(template.count(Query.empty(), User.class)).expectNext(42L).verifyComplete();
|
||||
template.count(Query.empty(), User.class).as(StepVerifier::create).expectNext(42L).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("SELECT COUNT(1) FROM users;");
|
||||
@@ -233,7 +233,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
when(reactiveResultSet.rows()).thenReturn(Flux.just(row));
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
StepVerifier.create(template.insert(user)).expectNext(user).verifyComplete();
|
||||
template.insert(user).as(StepVerifier::create).expectNext(user).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString())
|
||||
@@ -247,7 +247,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
when(session.execute(any(Statement.class)))
|
||||
.thenReturn(Mono.error(new NoHostAvailableException(Collections.emptyMap())));
|
||||
|
||||
StepVerifier.create(template.insert(new User("heisenberg", "Walter", "White"))) //
|
||||
template.insert(new User("heisenberg", "Walter", "White")).as(StepVerifier::create) //
|
||||
.consumeErrorWith(e -> {
|
||||
|
||||
assertThat(e).hasRootCauseInstanceOf(NoHostAvailableException.class);
|
||||
@@ -262,7 +262,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.update(user)).expectNext(user).verifyComplete();
|
||||
template.update(user).as(StepVerifier::create).expectNext(user).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString())
|
||||
@@ -353,7 +353,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
|
||||
User user = new User("heisenberg", "Walter", "White");
|
||||
|
||||
StepVerifier.create(template.delete(user)).expectNext(user).verifyComplete();
|
||||
template.delete(user).as(StepVerifier::create).expectNext(user).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("DELETE FROM users WHERE id='heisenberg';");
|
||||
@@ -398,7 +398,7 @@ public class ReactiveCassandraTemplateUnitTests {
|
||||
@Test // DATACASS-335
|
||||
public void truncateShouldRemoveEntities() {
|
||||
|
||||
StepVerifier.create(template.truncate(User.class)).verifyComplete();
|
||||
template.truncate(User.class).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
verify(session).execute(statementCaptor.capture());
|
||||
assertThat(statementCaptor.getValue().toString()).isEqualTo("TRUNCATE users;");
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(query(where("id").is(han.id)))
|
||||
.all();
|
||||
|
||||
StepVerifier.create(writeResult.map(WriteResult::wasApplied)).expectNext(true).verifyComplete();
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -93,8 +93,8 @@ public class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(query(where("id").in(han.id, luke.id)))
|
||||
.all();
|
||||
|
||||
StepVerifier.create(writeResult.map(WriteResult::wasApplied)).expectNext(true).verifyComplete();
|
||||
StepVerifier.create(template.select(Query.empty(), Person.class)).verifyComplete();
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
template.select(Query.empty(), Person.class).as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -93,13 +93,13 @@ public class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<EntityWriteResult<Person>> writeResult = this.template.insert(Person.class).inTable("person").one(han);
|
||||
|
||||
StepVerifier.create(writeResult).consumeNextWith(actual -> {
|
||||
writeResult.as(StepVerifier::create).consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual.wasApplied()).isTrue();
|
||||
assertThat(actual.getEntity()).isSameAs(han);
|
||||
}).verifyComplete();
|
||||
|
||||
StepVerifier.create(template.selectOneById(han.id, Person.class)).expectNext(han).verifyComplete();
|
||||
template.selectOneById(han.id, Person.class).as(StepVerifier::create).expectNext(han).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485, DATACASS-573
|
||||
@@ -112,8 +112,8 @@ public class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeys
|
||||
.withOptions(InsertOptions.builder().withIfNotExists().build())
|
||||
.one(han);
|
||||
|
||||
StepVerifier.create(writeResult).assertNext(it -> assertThat(it.wasApplied()).isTrue()).verifyComplete();
|
||||
StepVerifier.create(template.selectOneById(han.id, Person.class)).expectNext(han).verifyComplete();
|
||||
writeResult.as(StepVerifier::create).assertNext(it -> assertThat(it.wasApplied()).isTrue()).verifyComplete();
|
||||
template.selectOneById(han.id, Person.class).as(StepVerifier::create).expectNext(han).verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -104,7 +104,8 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Person> result = this.template.query(Person.class).all();
|
||||
|
||||
StepVerifier.create(result.collectList()).assertNext(actual ->
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).containsExactlyInAnyOrder(han, luke)
|
||||
).verifyComplete();
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Human> result = this.template.query(Human.class).inTable("person").all();
|
||||
|
||||
StepVerifier.create(result).expectNextCount(2).verifyComplete();
|
||||
result.as(StepVerifier::create).expectNextCount(2).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -122,7 +123,8 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Jedi> result = this.template.query(Person.class).as(Jedi.class).all();
|
||||
|
||||
StepVerifier.create(result.collectList()).assertNext(actual ->
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).hasOnlyElementsOfType(Jedi.class).hasSize(2)
|
||||
).verifyComplete();
|
||||
}
|
||||
@@ -132,7 +134,8 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<PersonProjection> result = this.template.query(Person.class).as(PersonProjection.class).all();
|
||||
|
||||
StepVerifier.create(result.collectList()).assertNext(actual ->
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).hasOnlyElementsOfType(PersonProjection.class).hasSize(2)
|
||||
).verifyComplete();
|
||||
}
|
||||
@@ -142,7 +145,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Person> result = this.template.query(Person.class).matching(queryLuke()).all();
|
||||
|
||||
StepVerifier.create(result).expectNext(luke).verifyComplete();
|
||||
result.as(StepVerifier::create).expectNext(luke).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -150,7 +153,8 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Jedi> result = this.template.query(Jedi.class).inTable("person").all();
|
||||
|
||||
StepVerifier.create(result.collectList()).assertNext(actual ->
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)
|
||||
).verifyComplete();
|
||||
}
|
||||
@@ -160,7 +164,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Human> result = this.template.query(Human.class).inTable("person").matching(queryLuke()).all();
|
||||
|
||||
StepVerifier.create(result.collectList()).expectNextCount(1).verifyComplete();
|
||||
result.collectList().as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -168,7 +172,8 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Jedi> result = this.template.query(Person.class).as(Jedi.class).all();
|
||||
|
||||
StepVerifier.create(result.collectList()).assertNext(actual ->
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)
|
||||
).verifyComplete();
|
||||
}
|
||||
@@ -178,7 +183,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Person> result = this.template.query(Person.class).matching(queryLuke()).one();
|
||||
|
||||
StepVerifier.create(result).expectNext(luke).verifyComplete();
|
||||
result.as(StepVerifier::create).expectNext(luke).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -186,7 +191,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Person> result = this.template.query(Person.class).matching(querySpock()).one();
|
||||
|
||||
StepVerifier.create(result).verifyComplete();
|
||||
result.as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -194,7 +199,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Person> result = this.template.query(Person.class).one();
|
||||
|
||||
StepVerifier.create(result).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
result.as(StepVerifier::create).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -202,7 +207,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Person> result = this.template.query(Person.class).matching(queryLuke()).first();
|
||||
|
||||
StepVerifier.create(result).expectNext(luke).verifyComplete();
|
||||
result.as(StepVerifier::create).expectNext(luke).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -210,7 +215,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Person> result = this.template.query(Person.class).first();
|
||||
|
||||
StepVerifier.create(result).assertNext(actual ->
|
||||
result.as(StepVerifier::create).assertNext(actual ->
|
||||
assertThat(actual).isIn(han, luke)
|
||||
).verifyComplete();
|
||||
}
|
||||
@@ -224,7 +229,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering())
|
||||
.first();
|
||||
|
||||
StepVerifier.create(result).assertNext(actual -> {
|
||||
result.as(StepVerifier::create).assertNext(actual -> {
|
||||
assertThat(actual).isInstanceOf(PersonProjection.class);
|
||||
assertThat(actual.getFirstname()).isEqualTo("han");
|
||||
}).verifyComplete();
|
||||
@@ -239,7 +244,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering())
|
||||
.first();
|
||||
|
||||
StepVerifier.create(result).assertNext(actual -> {
|
||||
result.as(StepVerifier::create).assertNext(actual -> {
|
||||
assertThat(actual).isInstanceOf(PersonSpELProjection.class);
|
||||
assertThat(actual.getName()).isEqualTo("han");
|
||||
}).verifyComplete();
|
||||
@@ -250,7 +255,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Long> count = this.template.query(Person.class).count();
|
||||
|
||||
StepVerifier.create(count).expectNext(2L).verifyComplete();
|
||||
count.as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -261,7 +266,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering())
|
||||
.count();
|
||||
|
||||
StepVerifier.create(count).expectNext(1L).verifyComplete();
|
||||
count.as(StepVerifier::create).expectNext(1L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -269,17 +274,17 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Boolean> exists = this.template.query(Person.class).exists();
|
||||
|
||||
StepVerifier.create(exists).expectNext(true).verifyComplete();
|
||||
exists.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
public void existsShouldReturnFalseIfNoElementExistsInCollection() {
|
||||
|
||||
StepVerifier.create(this.template.truncate(Person.class)).verifyComplete();
|
||||
this.template.truncate(Person.class).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
Mono<Boolean> exists = this.template.query(Person.class).exists();
|
||||
|
||||
StepVerifier.create(exists).expectNext(false).verifyComplete();
|
||||
exists.as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -287,7 +292,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Boolean> exists = this.template.query(Person.class).matching(queryLuke()).exists();
|
||||
|
||||
StepVerifier.create(exists).expectNext(true).verifyComplete();
|
||||
exists.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -295,7 +300,7 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Mono<Boolean> exists = this.template.query(Person.class).matching(querySpock()).exists();
|
||||
|
||||
StepVerifier.create(exists).expectNext(false).verifyComplete();
|
||||
exists.as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -303,7 +308,8 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
|
||||
Flux<Contact> result = this.template.query(Person.class).as(Contact.class).all();
|
||||
|
||||
StepVerifier.create(result.collectList()).assertNext(actual ->
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).allMatch(it -> it instanceof Person)
|
||||
).verifyComplete();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(queryHan())
|
||||
.apply(update("firstname", "Han"));
|
||||
|
||||
StepVerifier.create(writeResult.map(WriteResult::wasApplied)).expectNext(true).verifyComplete();
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -109,7 +109,7 @@ public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeys
|
||||
.matching(query(where("id").is(han.getId())))
|
||||
.apply(update("name", "Han"));
|
||||
|
||||
StepVerifier.create(writeResult.map(WriteResult::wasApplied)).expectNext(true).verifyComplete();
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
assertThat(this.admin.selectOne(queryHan(), Person.class))
|
||||
.isNotEqualTo(han).hasFieldOrPropertyWithValue("firstname", "Han");
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
|
||||
|
||||
assertThat(keyspace.getTable("users")).isNull();
|
||||
|
||||
StepVerifier.create(execution)
|
||||
execution.as(StepVerifier::create)
|
||||
.consumeNextWith(actual -> assertThat(actual.wasApplied()).isTrue())
|
||||
.verifyComplete();
|
||||
|
||||
@@ -75,7 +75,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void executeShouldTransportExceptionsInMono() {
|
||||
StepVerifier.create(reactiveSession.execute("INSERT INTO dummy;")).expectError(SyntaxError.class).verify();
|
||||
reactiveSession.execute("INSERT INTO dummy;").as(StepVerifier::create).expectError(SyntaxError.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -84,8 +84,9 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
|
||||
session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");");
|
||||
session.execute("INSERT INTO users (userid, first_name) VALUES ('White', 'Walter');");
|
||||
|
||||
StepVerifier.create(reactiveSession.execute("SELECT * FROM users;")).consumeNextWith(actual ->
|
||||
StepVerifier.create(actual.rows()).consumeNextWith(row ->
|
||||
reactiveSession.execute("SELECT * FROM users;").as(StepVerifier::create)
|
||||
.consumeNextWith(actual -> actual.rows().as(StepVerifier::create)
|
||||
.consumeNextWith(row ->
|
||||
assertThat(row.getString("userid")).isEqualTo("White")).verifyComplete()).verifyComplete();
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
|
||||
|
||||
session.execute("CREATE TABLE users (\n" + " userid text PRIMARY KEY,\n" + " first_name text\n" + ");");
|
||||
|
||||
StepVerifier.create(reactiveSession.prepare("INSERT INTO users (userid, first_name) VALUES (?, ?);"))
|
||||
reactiveSession.prepare("INSERT INTO users (userid, first_name) VALUES (?, ?);").as(StepVerifier::create)
|
||||
.consumeNextWith(actual ->
|
||||
assertThat(actual.getQueryString()).isEqualTo("INSERT INTO users (userid, first_name) VALUES (?, ?);"))
|
||||
.verifyComplete();
|
||||
@@ -129,7 +130,7 @@ public class DefaultBridgedReactiveSessionIntegrationTests extends AbstractKeysp
|
||||
|
||||
Collection<String> received = new ConcurrentLinkedQueue<>();
|
||||
|
||||
StepVerifier.create(execution.flatMapMany(ReactiveResultSet::rows).map(row -> row.getString(0)))
|
||||
execution.flatMapMany(ReactiveResultSet::rows).map(row -> row.getString(0)).as(StepVerifier::create)
|
||||
.recordWith(() -> received)
|
||||
.expectNextCount(100)
|
||||
.verifyComplete();
|
||||
|
||||
@@ -194,7 +194,7 @@ public class DefaultBridgedReactiveSessionUnitTests {
|
||||
|
||||
Flux<Row> flux = reactiveSession.execute(new SimpleStatement("")).flatMapMany(ReactiveResultSet::availableRows);
|
||||
|
||||
StepVerifier.create(flux).expectNextCount(10).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNextCount(10).verifyComplete();
|
||||
|
||||
verify(rows, times(10)).next();
|
||||
verify(future, times(1)).addListener(any(), any());
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void executeShouldRemoveRecords() {
|
||||
|
||||
StepVerifier.create(template.execute("DELETE FROM user WHERE id = 'WHITE'")).expectNext(true).verifyComplete();
|
||||
template.execute("DELETE FROM user WHERE id = 'WHITE'").as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
assertThat(getSession().execute("SELECT * FROM user").one()).isNull();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void queryForObjectShouldReturnFirstColumn() {
|
||||
|
||||
StepVerifier.create(template.queryForObject("SELECT id FROM user;", String.class)) //
|
||||
template.queryForObject("SELECT id FROM user;", String.class).as(StepVerifier::create) //
|
||||
.expectNext("WHITE") //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void queryForObjectShouldReturnMap() {
|
||||
|
||||
StepVerifier.create(template.queryForMap("SELECT * FROM user;")) //
|
||||
template.queryForMap("SELECT * FROM user;").as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual).containsEntry("id", "WHITE").containsEntry("username", "Walter");
|
||||
@@ -88,10 +88,9 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void executeStatementShouldRemoveRecords() {
|
||||
|
||||
StepVerifier
|
||||
.create(template.execute(QueryBuilder.delete() //
|
||||
template.execute(QueryBuilder.delete() //
|
||||
.from("user") //
|
||||
.where(QueryBuilder.eq("id", "WHITE")))) //
|
||||
.where(QueryBuilder.eq("id", "WHITE"))).as(StepVerifier::create) //
|
||||
.expectNext(true) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -101,10 +100,9 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void queryForObjectStatementShouldReturnFirstColumn() {
|
||||
|
||||
StepVerifier
|
||||
.create(template.queryForObject(QueryBuilder //
|
||||
template.queryForObject(QueryBuilder //
|
||||
.select("id") //
|
||||
.from("user"), String.class)) //
|
||||
.from("user"), String.class).as(StepVerifier::create) //
|
||||
.expectNext("WHITE") //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -112,7 +110,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void queryForObjectStatementShouldReturnMap() {
|
||||
|
||||
StepVerifier.create(template.queryForMap(QueryBuilder.select().from("user"))) //
|
||||
template.queryForMap(QueryBuilder.select().from("user")).as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual).containsEntry("id", "WHITE").containsEntry("username", "Walter");
|
||||
@@ -122,7 +120,8 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void executeWithArgsShouldRemoveRecords() {
|
||||
|
||||
StepVerifier.create(template.execute("DELETE FROM user WHERE id = ?", "WHITE")).expectNext(true).verifyComplete();
|
||||
template.execute("DELETE FROM user WHERE id = ?", "WHITE").as(StepVerifier::create).expectNext(true)
|
||||
.verifyComplete();
|
||||
|
||||
assertThat(getSession().execute("SELECT * FROM user").one()).isNull();
|
||||
}
|
||||
@@ -130,7 +129,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void queryForObjectWithArgsShouldReturnFirstColumn() {
|
||||
|
||||
StepVerifier.create(template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE")) //
|
||||
template.queryForObject("SELECT id FROM user WHERE id = ?;", String.class, "WHITE").as(StepVerifier::create) //
|
||||
.expectNext("WHITE") //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -138,7 +137,7 @@ public class ReactiveCqlTemplateIntegrationTests extends AbstractKeyspaceCreatin
|
||||
@Test // DATACASS-335
|
||||
public void queryForObjectWithArgsShouldReturnMap() {
|
||||
|
||||
StepVerifier.create(template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE")) //
|
||||
template.queryForMap("SELECT * FROM user WHERE id = ?;", "WHITE").as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual).containsEntry("id", "WHITE").containsEntry("username", "Walter");
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verify(session, never()).close();
|
||||
|
||||
StepVerifier.create(flux).expectNext("OK").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
verify(session).close();
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
throw new InvalidQueryException("wrong query");
|
||||
});
|
||||
|
||||
StepVerifier.create(flux).expectError(CassandraInvalidQueryException.class).verify();
|
||||
flux.as(StepVerifier::create).expectError(CassandraInvalidQueryException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -114,7 +114,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(mono).expectNext(false).verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<Boolean> mono = template.execute("UPDATE user SET a = 'b';");
|
||||
|
||||
StepVerifier.create(mono).expectError(CassandraConnectionFailureException.class).verify();
|
||||
mono.as(StepVerifier::create).expectError(CassandraConnectionFailureException.class).verify();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -138,7 +138,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
doTestStrings(null, null, null, reactiveCqlTemplate -> {
|
||||
|
||||
StepVerifier.create(reactiveCqlTemplate.execute("SELECT * from USERS")).expectNextCount(1).verifyComplete();
|
||||
reactiveCqlTemplate.execute("SELECT * from USERS").as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
});
|
||||
@@ -149,7 +149,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, reactiveCqlTemplate -> {
|
||||
|
||||
StepVerifier.create(reactiveCqlTemplate.execute("SELECT * from USERS")) //
|
||||
reactiveCqlTemplate.execute("SELECT * from USERS").as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<ReactiveResultSet> mono = reactiveCqlTemplate.queryForResultSet("SELECT * from USERS");
|
||||
|
||||
StepVerifier.create(mono.flatMapMany(ReactiveResultSet::rows)).expectNextCount(3).verifyComplete();
|
||||
mono.flatMapMany(ReactiveResultSet::rows).as(StepVerifier::create).expectNextCount(3).verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
});
|
||||
@@ -177,7 +177,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<String> flux = reactiveCqlTemplate.query("SELECT * from USERS", (row, index) -> row.getString(0));
|
||||
|
||||
StepVerifier.create(flux).expectNext("Walter", "Hank", " Jesse").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("Walter", "Hank", " Jesse").verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
});
|
||||
@@ -190,7 +190,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<String> flux = reactiveCqlTemplate.query("SELECT * from USERS", (row, index) -> row.getString(0));
|
||||
|
||||
StepVerifier.create(flux).expectNext("Walter", "Hank", " Jesse").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("Walter", "Hank", " Jesse").verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
});
|
||||
@@ -206,7 +206,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(true).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<Boolean> flux = template.query("UPDATE user SET a = 'b';", resultSet -> Mono.just(resultSet.wasApplied()));
|
||||
|
||||
StepVerifier.create(flux).expectError(CassandraConnectionFailureException.class).verify();
|
||||
flux.as(StepVerifier::create).expectError(CassandraConnectionFailureException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -229,7 +229,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user", (row, rowNum) -> "OK");
|
||||
|
||||
StepVerifier.create(mono).verifyComplete();
|
||||
mono.as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -240,7 +240,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user", (row, rowNum) -> "OK");
|
||||
|
||||
StepVerifier.create(mono).expectNext("OK").verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -251,7 +251,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user", (row, rowNum) -> null);
|
||||
|
||||
StepVerifier.create(mono).verifyComplete();
|
||||
mono.as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -262,7 +262,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user", (row, rowNum) -> "OK");
|
||||
|
||||
StepVerifier.create(mono).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
mono.as(StepVerifier::create).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -276,7 +276,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user", String.class);
|
||||
|
||||
StepVerifier.create(mono).expectNext("OK").verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -290,7 +290,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<String> flux = template.queryForFlux("SELECT * FROM user", String.class);
|
||||
|
||||
StepVerifier.create(flux).expectNext("OK", "NOT OK").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("OK", "NOT OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -301,7 +301,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<Row> flux = template.queryForRows("SELECT * FROM user");
|
||||
|
||||
StepVerifier.create(flux).expectNext(row, row).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(row, row).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -312,7 +312,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<Boolean> mono = template.execute("UPDATE user SET a = 'b';");
|
||||
|
||||
StepVerifier.create(mono).expectNext(true).verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -325,7 +325,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(true).expectNext(false).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(true).expectNext(false).verifyComplete();
|
||||
|
||||
verify(session, times(2)).execute(any(Statement.class));
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
doTestStrings(null, null, null, reactiveCqlTemplate -> {
|
||||
|
||||
StepVerifier.create(reactiveCqlTemplate.execute(new SimpleStatement("SELECT * from USERS"))) //
|
||||
reactiveCqlTemplate.execute(new SimpleStatement("SELECT * from USERS")).as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -352,7 +352,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
doTestStrings(5, ConsistencyLevel.ONE, DowngradingConsistencyRetryPolicy.INSTANCE, reactiveCqlTemplate -> {
|
||||
|
||||
StepVerifier.create(reactiveCqlTemplate.execute(new SimpleStatement("SELECT * from USERS"))) //
|
||||
reactiveCqlTemplate.execute(new SimpleStatement("SELECT * from USERS")).as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -365,9 +365,8 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
doTestStrings(null, null, null, reactiveCqlTemplate -> {
|
||||
|
||||
StepVerifier
|
||||
.create(reactiveCqlTemplate.queryForResultSet(new SimpleStatement("SELECT * from USERS"))
|
||||
.flatMapMany(ReactiveResultSet::rows)) //
|
||||
reactiveCqlTemplate.queryForResultSet(new SimpleStatement("SELECT * from USERS"))
|
||||
.flatMapMany(ReactiveResultSet::rows).as(StepVerifier::create) //
|
||||
.expectNextCount(3) //
|
||||
.verifyComplete();
|
||||
|
||||
@@ -383,7 +382,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Flux<String> flux = reactiveCqlTemplate.query(new SimpleStatement("SELECT * from USERS"),
|
||||
(row, index) -> row.getString(0));
|
||||
|
||||
StepVerifier.create(flux).expectNext("Walter", "Hank", " Jesse").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("Walter", "Hank", " Jesse").verifyComplete();
|
||||
|
||||
verify(session).execute(any(Statement.class));
|
||||
});
|
||||
@@ -397,7 +396,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Flux<String> flux = reactiveCqlTemplate.query(new SimpleStatement("SELECT * from USERS"),
|
||||
(row, index) -> row.getString(0));
|
||||
|
||||
StepVerifier.create(flux.collectList()).consumeNextWith(rows -> {
|
||||
flux.collectList().as(StepVerifier::create).consumeNextWith(rows -> {
|
||||
|
||||
assertThat(rows).hasSize(3).contains("Walter", "Hank", " Jesse");
|
||||
}).verifyComplete();
|
||||
@@ -416,7 +415,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
resultSet -> Mono.just(resultSet.wasApplied()));
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
StepVerifier.create(flux).expectNext(true).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
verify(session).execute(any(Statement.class));
|
||||
}
|
||||
|
||||
@@ -428,7 +427,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Flux<Boolean> flux = template.query(new SimpleStatement("UPDATE user SET a = 'b';"),
|
||||
resultSet -> Mono.just(resultSet.wasApplied()));
|
||||
|
||||
StepVerifier.create(flux).expectError(CassandraConnectionFailureException.class).verify();
|
||||
flux.as(StepVerifier::create).expectError(CassandraConnectionFailureException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -439,7 +438,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject(new SimpleStatement("SELECT * FROM user"), (row, rowNum) -> "OK");
|
||||
|
||||
StepVerifier.create(mono).verifyComplete();
|
||||
mono.as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -450,7 +449,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject(new SimpleStatement("SELECT * FROM user"), (row, rowNum) -> "OK");
|
||||
|
||||
StepVerifier.create(mono).expectNext("OK").verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -461,7 +460,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject(new SimpleStatement("SELECT * FROM user"), (row, rowNum) -> null);
|
||||
|
||||
StepVerifier.create(mono).verifyComplete();
|
||||
mono.as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -472,7 +471,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject(new SimpleStatement("SELECT * FROM user"), (row, rowNum) -> "OK");
|
||||
|
||||
StepVerifier.create(mono).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
mono.as(StepVerifier::create).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -486,7 +485,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject(new SimpleStatement("SELECT * FROM user"), String.class);
|
||||
|
||||
StepVerifier.create(mono).expectNext("OK").verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -500,7 +499,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<String> flux = template.queryForFlux(new SimpleStatement("SELECT * FROM user"), String.class);
|
||||
|
||||
StepVerifier.create(flux).expectNext("OK", "NOT OK").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("OK", "NOT OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -511,7 +510,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<Row> flux = template.queryForRows(new SimpleStatement("SELECT * FROM user"));
|
||||
|
||||
StepVerifier.create(flux).expectNext(row, row).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(row, row).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -520,7 +519,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
|
||||
when(reactiveResultSet.wasApplied()).thenReturn(true);
|
||||
|
||||
StepVerifier.create(template.execute(new SimpleStatement("UPDATE user SET a = 'b';"))).expectNext(true)
|
||||
template.execute(new SimpleStatement("UPDATE user SET a = 'b';")).as(StepVerifier::create).expectNext(true)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@@ -538,7 +537,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
return session.execute(ps.bind("A")).flatMapMany(ReactiveResultSet::rows);
|
||||
});
|
||||
|
||||
StepVerifier.create(flux).expectNextCount(3).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNextCount(3).verifyComplete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -551,7 +550,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
when(this.preparedStatement.bind("White")).thenReturn(this.boundStatement);
|
||||
when(this.reactiveResultSet.wasApplied()).thenReturn(true);
|
||||
|
||||
StepVerifier.create(applied).expectNext(true).verifyComplete();
|
||||
applied.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -567,7 +566,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(reactiveResultSet).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(reactiveResultSet).verifyComplete();
|
||||
|
||||
verify(session).prepare(anyString());
|
||||
verify(session).execute(boundStatement);
|
||||
@@ -583,7 +582,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(reactiveResultSet).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(reactiveResultSet).verifyComplete();
|
||||
|
||||
verify(session).execute(boundStatement);
|
||||
}
|
||||
@@ -595,7 +594,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
throw new NoHostAvailableException(Collections.emptyMap());
|
||||
}, (session, ps) -> session.execute(boundStatement));
|
||||
|
||||
StepVerifier.create(flux).expectError(CassandraConnectionFailureException.class).verify();
|
||||
flux.as(StepVerifier::create).expectError(CassandraConnectionFailureException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -605,7 +604,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
throw new NoHostAvailableException(Collections.emptyMap());
|
||||
});
|
||||
|
||||
StepVerifier.create(flux).expectError(CassandraConnectionFailureException.class).verify();
|
||||
flux.as(StepVerifier::create).expectError(CassandraConnectionFailureException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -619,7 +618,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(row).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(row).verifyComplete();
|
||||
verify(preparedStatement).bind();
|
||||
}
|
||||
|
||||
@@ -636,7 +635,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(row).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(row).verifyComplete();
|
||||
|
||||
verify(preparedStatement).bind("a", "b");
|
||||
}
|
||||
@@ -654,7 +653,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
verifyZeroInteractions(session);
|
||||
|
||||
StepVerifier.create(flux).expectNext(row).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(row).verifyComplete();
|
||||
|
||||
verify(preparedStatement).bind("a", "b");
|
||||
}
|
||||
@@ -670,7 +669,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user WHERE username = ?", (row, rowNum) -> "OK",
|
||||
"Walter");
|
||||
|
||||
StepVerifier.create(mono).verifyComplete();
|
||||
mono.as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -684,7 +683,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user WHERE username = ?", (row, rowNum) -> "OK",
|
||||
"Walter");
|
||||
|
||||
StepVerifier.create(mono).expectNext("OK").verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -698,7 +697,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user WHERE username = ?", (row, rowNum) -> "OK",
|
||||
"Walter");
|
||||
|
||||
StepVerifier.create(mono).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
mono.as(StepVerifier::create).expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -714,7 +713,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<String> mono = template.queryForObject("SELECT * FROM user WHERE username = ?", String.class, "Walter");
|
||||
|
||||
StepVerifier.create(mono).expectNext("OK").verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext("OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -730,7 +729,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<String> flux = template.queryForFlux("SELECT * FROM user WHERE username = ?", String.class, "Walter");
|
||||
|
||||
StepVerifier.create(flux).expectNext("OK", "NOT OK").verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext("OK", "NOT OK").verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -743,7 +742,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Flux<Row> flux = template.queryForRows("SELECT * FROM user WHERE username = ?", "Walter");
|
||||
|
||||
StepVerifier.create(flux).expectNextCount(2).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNextCount(2).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -756,7 +755,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
|
||||
Mono<Boolean> mono = template.execute("UPDATE user SET username = ?", "Walter");
|
||||
|
||||
StepVerifier.create(mono).expectNext(true).verifyComplete();
|
||||
mono.as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -771,7 +770,7 @@ public class ReactiveCqlTemplateUnitTests {
|
||||
Flux<Boolean> flux = template.execute("UPDATE user SET username = ?",
|
||||
Flux.just(new Object[] { "Walter" }, new Object[] { "Hank" }));
|
||||
|
||||
StepVerifier.create(flux).expectNext(true, true).verifyComplete();
|
||||
flux.as(StepVerifier::create).expectNext(true, true).verifyComplete();
|
||||
|
||||
verify(session, atMost(1)).prepare("UPDATE user SET username = ?");
|
||||
verify(session, times(2)).execute(boundStatement);
|
||||
|
||||
@@ -89,20 +89,20 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
StepVerifier.create(reactiveRepository.deleteAll()).verifyComplete();
|
||||
reactiveRepository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||
|
||||
dave = new User("42", "Dave", "Matthews");
|
||||
oliver = new User("4", "Oliver August", "Matthews");
|
||||
carter = new User("49", "Carter", "Beauford");
|
||||
boyd = new User("45", "Boyd", "Tinsley");
|
||||
|
||||
StepVerifier.create(reactiveRepository.saveAll(Arrays.asList(oliver, dave, carter, boyd))).expectNextCount(4)
|
||||
reactiveRepository.saveAll(Arrays.asList(oliver, dave, carter, boyd)).as(StepVerifier::create).expectNextCount(4)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void reactiveStreamsMethodsShouldWork() {
|
||||
StepVerifier.create(reactiveUserRepostitory.existsById(dave.getId())).expectNext(true).verifyComplete();
|
||||
reactiveUserRepostitory.existsById(dave.getId()).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -113,11 +113,12 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace
|
||||
@Test // DATACASS-360
|
||||
public void dtoProjectionShouldWork() {
|
||||
|
||||
StepVerifier.create(reactiveUserRepostitory.findProjectedByLastname(boyd.getLastname())).consumeNextWith(actual -> {
|
||||
reactiveUserRepostitory.findProjectedByLastname(boyd.getLastname()).as(StepVerifier::create)
|
||||
.consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual.firstname).isEqualTo(boyd.getFirstname());
|
||||
assertThat(actual.lastname).isEqualTo(boyd.getLastname());
|
||||
}).verifyComplete();
|
||||
assertThat(actual.firstname).isEqualTo(boyd.getFirstname());
|
||||
assertThat(actual.lastname).isEqualTo(boyd.getLastname());
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -264,7 +265,7 @@ public class ConvertingReactiveCassandraRepositoryTests extends AbstractKeyspace
|
||||
@Test // DATACASS-335
|
||||
public void shouldFindByIdByPublisherOfLastName() {
|
||||
|
||||
StepVerifier.create(reactiveRepository.findByLastname(Single.just(this.carter.getLastname()))) //
|
||||
reactiveRepository.findByLastname(Single.just(this.carter.getLastname())).as(StepVerifier::create) //
|
||||
.expectNext(carter) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@@ -116,64 +116,66 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac
|
||||
repository = factory.getRepository(UserRepository.class);
|
||||
groupRepostitory = factory.getRepository(GroupRepository.class);
|
||||
|
||||
StepVerifier.create(repository.deleteAll().concatWith(groupRepostitory.deleteAll())).verifyComplete();
|
||||
repository.deleteAll().concatWith(groupRepostitory.deleteAll()).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
dave = new User("42", "Dave", "Matthews");
|
||||
oliver = new User("4", "Oliver August", "Matthews");
|
||||
carter = new User("49", "Carter", "Beauford");
|
||||
boyd = new User("45", "Boyd", "Tinsley");
|
||||
|
||||
StepVerifier.create(repository.saveAll(Arrays.asList(oliver, dave, carter, boyd))).expectNextCount(4)
|
||||
repository.saveAll(Arrays.asList(oliver, dave, carter, boyd)).as(StepVerifier::create).expectNextCount(4)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void shouldFindByLastName() {
|
||||
StepVerifier.create(repository.findByLastname(dave.getLastname())).expectNextCount(2).verifyComplete();
|
||||
repository.findByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(2).verifyComplete();
|
||||
}
|
||||
|
||||
@Test //DATACASS-529
|
||||
public void shouldFindSliceByLastName() {
|
||||
StepVerifier.create(repository.findByLastname(carter.getLastname(), CassandraPageRequest.first(1)))
|
||||
repository.findByLastname(carter.getLastname(), CassandraPageRequest.first(1)).as(StepVerifier::create)
|
||||
.expectNextMatches(users -> users.getSize() == 1 && users.hasNext())
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-529
|
||||
public void shouldFindEmpptySliceByLastName() {
|
||||
StepVerifier.create(repository.findByLastname("foo", CassandraPageRequest.first(1)))
|
||||
repository.findByLastname("foo", CassandraPageRequest.first(1)).as(StepVerifier::create)
|
||||
.expectNextMatches(Streamable::isEmpty).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-525
|
||||
public void findOneWithManyResultsShouldFail() {
|
||||
StepVerifier.create(repository.findOneByLastname(dave.getLastname()))
|
||||
repository.findOneByLastname(dave.getLastname()).as(StepVerifier::create)
|
||||
.expectError(IncorrectResultSizeDataAccessException.class).verify();
|
||||
}
|
||||
|
||||
@Test // DATACASS-525
|
||||
public void findOneWithNoResultsShouldNotEmitItem() {
|
||||
StepVerifier.create(repository.findByLastname("foo")).verifyComplete();
|
||||
repository.findByLastname("foo").as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-525
|
||||
public void findFirstWithManyResultsShouldEmitFirstItem() {
|
||||
StepVerifier.create(repository.findFirstByLastname(dave.getLastname())).expectNextCount(1).verifyComplete();
|
||||
repository.findFirstByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void shouldFindByIdByLastName() {
|
||||
StepVerifier.create(repository.findOneByLastname(carter.getLastname())).expectNext(carter).verifyComplete();
|
||||
repository.findOneByLastname(carter.getLastname()).as(StepVerifier::create).expectNext(carter).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void shouldFindByIdByPublisherOfLastName() {
|
||||
StepVerifier.create(repository.findByLastname(Mono.just(carter.getLastname()))).expectNext(carter).verifyComplete();
|
||||
repository.findByLastname(Mono.just(carter.getLastname())).as(StepVerifier::create).expectNext(carter)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void shouldFindUsingPublishersInStringQuery() {
|
||||
StepVerifier.create(repository.findStringQuery(Mono.just(dave.getLastname()))).expectNextCount(2).verifyComplete();
|
||||
repository.findStringQuery(Mono.just(dave.getLastname())).as(StepVerifier::create).expectNextCount(2)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -182,17 +184,16 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac
|
||||
GroupKey key1 = new GroupKey("Simpsons", "hash", "Bart");
|
||||
GroupKey key2 = new GroupKey("Simpsons", "hash", "Homer");
|
||||
|
||||
StepVerifier.create(groupRepostitory.saveAll(Flux.just(new Group(key1), new Group(key2)))).expectNextCount(2)
|
||||
groupRepostitory.saveAll(Flux.just(new Group(key1), new Group(key2))).as(StepVerifier::create).expectNextCount(2)
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier
|
||||
.create(groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash",
|
||||
Sort.by("id.username").ascending())) //
|
||||
groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash", Sort.by("id.username").ascending())
|
||||
.as(StepVerifier::create) //
|
||||
.expectNext(new Group(key1), new Group(key2)) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash",
|
||||
Sort.by("id.username").descending()))
|
||||
groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash", Sort.by("id.username").descending())
|
||||
.as(StepVerifier::create)
|
||||
.expectNext(new Group(key2), new Group(key1)) //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -200,21 +201,21 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac
|
||||
@Test // DATACASS-512
|
||||
public void shouldCountRecords() {
|
||||
|
||||
StepVerifier.create(repository.countByLastname("Matthews")).expectNext(2L).verifyComplete();
|
||||
StepVerifier.create(repository.countByLastname("None")).expectNext(0L).verifyComplete();
|
||||
repository.countByLastname("Matthews").as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||
repository.countByLastname("None").as(StepVerifier::create).expectNext(0L).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.countQueryByLastname("Matthews")).expectNext(2L).verifyComplete();
|
||||
StepVerifier.create(repository.countQueryByLastname("None")).expectNext(0L).verifyComplete();
|
||||
repository.countQueryByLastname("Matthews").as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||
repository.countQueryByLastname("None").as(StepVerifier::create).expectNext(0L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-512
|
||||
public void shouldApplyExistsProjection() {
|
||||
|
||||
StepVerifier.create(repository.existsByLastname("Matthews")).expectNext(true).verifyComplete();
|
||||
StepVerifier.create(repository.existsByLastname("None")).expectNext(false).verifyComplete();
|
||||
repository.existsByLastname("Matthews").as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
repository.existsByLastname("None").as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.existsQueryByLastname("Matthews")).expectNext(true).verifyComplete();
|
||||
StepVerifier.create(repository.existsQueryByLastname("None")).expectNext(false).verifyComplete();
|
||||
repository.existsQueryByLastname("Matthews").as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
repository.existsQueryByLastname("None").as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
}
|
||||
|
||||
interface UserRepository extends ReactiveCassandraRepository<User, String> {
|
||||
|
||||
@@ -101,12 +101,12 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
}
|
||||
|
||||
private void insertTestData() {
|
||||
StepVerifier.create(repository.saveAll(Arrays.asList(oliver, dave, carter, boyd))).expectNextCount(4)
|
||||
repository.saveAll(Arrays.asList(oliver, dave, carter, boyd)).as(StepVerifier::create).expectNextCount(4)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
private void deleteAll() {
|
||||
StepVerifier.create(repository.deleteAll()).verifyComplete();
|
||||
repository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -114,12 +114,12 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.existsById(dave.getId())).expectNext(true).verifyComplete();
|
||||
repository.existsById(dave.getId()).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void existsByIdShouldReturnFalseForAbsentObject() {
|
||||
StepVerifier.create(repository.existsById("unknown")).expectNext(false).verifyComplete();
|
||||
repository.existsById("unknown").as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -127,7 +127,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.existsById(Mono.just(dave.getId()))).expectNext(true).verifyComplete();
|
||||
repository.existsById(Mono.just(dave.getId())).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-462
|
||||
@@ -135,13 +135,13 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.existsById(Flux.just(dave.getId(), oliver.getId()))).expectNext(true)
|
||||
repository.existsById(Flux.just(dave.getId(), oliver.getId())).as(StepVerifier::create).expectNext(true)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void existsByEmptyMonoOfIdShouldReturnEmptyMono() {
|
||||
StepVerifier.create(repository.existsById(Mono.empty())).verifyComplete();
|
||||
repository.existsById(Mono.empty()).as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -149,12 +149,12 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findById(dave.getId())).expectNext(dave).verifyComplete();
|
||||
repository.findById(dave.getId()).as(StepVerifier::create).expectNext(dave).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void findByIdShouldCompleteWithoutValueForAbsentObject() {
|
||||
StepVerifier.create(repository.findById("unknown")).verifyComplete();
|
||||
repository.findById("unknown").as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -162,7 +162,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findById(Mono.just(dave.getId()))).expectNext(dave).verifyComplete();
|
||||
repository.findById(Mono.just(dave.getId())).as(StepVerifier::create).expectNext(dave).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-462
|
||||
@@ -170,12 +170,13 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findById(Flux.just(dave.getId(), oliver.getId()))).expectNext(dave).verifyComplete();
|
||||
repository.findById(Flux.just(dave.getId(), oliver.getId())).as(StepVerifier::create).expectNext(dave)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void findByIdByEmptyMonoOfIdShouldReturnEmptyMono() {
|
||||
StepVerifier.create(repository.findById(Mono.empty())).verifyComplete();
|
||||
repository.findById(Mono.empty()).as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -183,7 +184,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(4).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(4).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -191,7 +192,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findAllById(Arrays.asList(dave.getId(), boyd.getId()))) //
|
||||
repository.findAllById(Arrays.asList(dave.getId(), boyd.getId())).as(StepVerifier::create) //
|
||||
.expectNextCount(2) //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -201,14 +202,14 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findAllById(Flux.just(dave.getId(), boyd.getId()))) //
|
||||
repository.findAllById(Flux.just(dave.getId(), boyd.getId())).as(StepVerifier::create) //
|
||||
.expectNextCount(2) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void findAllByEmptyPublisherOfIdShouldReturnResults() {
|
||||
StepVerifier.create(repository.findAllById(Flux.empty())).verifyComplete();
|
||||
repository.findAllById(Flux.empty()).as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -216,7 +217,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.count()).expectNext(4L).verifyComplete();
|
||||
repository.count().as(StepVerifier::create).expectNext(4L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -224,9 +225,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
User person = new User("36", "Homer", "Simpson");
|
||||
|
||||
StepVerifier.create(repository.insert(person)).expectNext(person).verifyComplete();
|
||||
repository.insert(person).as(StepVerifier::create).expectNext(person).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(1L).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(1L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -236,23 +237,23 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
repository.insert(person);
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(0L).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(0L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void insertIterableOfEntitiesShouldInsertEntity() {
|
||||
|
||||
StepVerifier.create(repository.insert(Arrays.asList(dave, oliver, boyd))).expectNextCount(3L).verifyComplete();
|
||||
repository.insert(Arrays.asList(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3L).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(3L).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(3L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void insertPublisherOfEntitiesShouldInsertEntity() {
|
||||
|
||||
StepVerifier.create(repository.insert(Flux.just(dave, oliver, boyd))).expectNextCount(3L).verifyComplete();
|
||||
repository.insert(Flux.just(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3L).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(3L).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(3L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -261,9 +262,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
dave.setFirstname("Hello, Dave");
|
||||
dave.setLastname("Bowman");
|
||||
|
||||
StepVerifier.create(repository.save(dave)).expectNextCount(1).verifyComplete();
|
||||
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(dave.getId())).consumeNextWith(actual -> {
|
||||
repository.findById(dave.getId()).as(StepVerifier::create).consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual.getFirstname()).isEqualTo(dave.getFirstname());
|
||||
assertThat(actual.getLastname()).isEqualTo(dave.getLastname());
|
||||
@@ -275,17 +276,17 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
User person = new User("36", "Homer", "Simpson");
|
||||
|
||||
StepVerifier.create(repository.save(person)).expectNextCount(1).verifyComplete();
|
||||
repository.save(person).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(person.getId())).expectNext(person).verifyComplete();
|
||||
repository.findById(person.getId()).as(StepVerifier::create).expectNext(person).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void saveIterableOfNewEntitiesShouldInsertEntity() {
|
||||
|
||||
StepVerifier.create(repository.saveAll(Arrays.asList(dave, oliver, boyd))).expectNextCount(3).verifyComplete();
|
||||
repository.saveAll(Arrays.asList(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(3L).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(3L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -296,19 +297,19 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
dave.setFirstname("Hello, Dave");
|
||||
dave.setLastname("Bowman");
|
||||
|
||||
StepVerifier.create(repository.saveAll(Arrays.asList(person, dave))).expectNextCount(2).verifyComplete();
|
||||
repository.saveAll(Arrays.asList(person, dave)).as(StepVerifier::create).expectNextCount(2).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(dave.getId())).expectNext(dave).verifyComplete();
|
||||
repository.findById(dave.getId()).as(StepVerifier::create).expectNext(dave).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(person.getId())).expectNext(person).verifyComplete();
|
||||
repository.findById(person.getId()).as(StepVerifier::create).expectNext(person).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void savePublisherOfEntitiesShouldInsertEntity() {
|
||||
|
||||
StepVerifier.create(repository.saveAll(Flux.just(dave, oliver, boyd))).expectNextCount(3).verifyComplete();
|
||||
repository.saveAll(Flux.just(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findAll()).expectNextCount(3L).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).expectNextCount(3L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -316,9 +317,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.deleteAll()).verifyComplete();
|
||||
repository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findAll()).verifyComplete();
|
||||
repository.findAll().as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -326,9 +327,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.deleteById(dave.getId())).verifyComplete();
|
||||
repository.deleteById(dave.getId()).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(dave.getId())).expectNextCount(0).verifyComplete();
|
||||
repository.findById(dave.getId()).as(StepVerifier::create).expectNextCount(0).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-462
|
||||
@@ -336,9 +337,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.deleteById(Mono.just(dave.getId()))).verifyComplete();
|
||||
repository.deleteById(Mono.just(dave.getId())).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.existsById(dave.getId())).expectNext(false).verifyComplete();
|
||||
repository.existsById(dave.getId()).as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-462
|
||||
@@ -346,10 +347,10 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.deleteById(Flux.just(dave.getId(), oliver.getId()))).verifyComplete();
|
||||
repository.deleteById(Flux.just(dave.getId(), oliver.getId())).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.existsById(dave.getId())).expectNext(false).verifyComplete();
|
||||
StepVerifier.create(repository.existsById(oliver.getId())).expectNext(true).verifyComplete();
|
||||
repository.existsById(dave.getId()).as(StepVerifier::create).expectNext(false).verifyComplete();
|
||||
repository.existsById(oliver.getId()).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -357,9 +358,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.delete(dave)).verifyComplete();
|
||||
repository.delete(dave).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(dave.getId())).expectNextCount(0).verifyComplete();
|
||||
repository.findById(dave.getId()).as(StepVerifier::create).expectNextCount(0).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -367,9 +368,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.deleteAll(Arrays.asList(dave, boyd))).verifyComplete();
|
||||
repository.deleteAll(Arrays.asList(dave, boyd)).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(boyd.getId())).expectNextCount(0).verifyComplete();
|
||||
repository.findById(boyd.getId()).as(StepVerifier::create).expectNextCount(0).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
@@ -377,9 +378,9 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.deleteAll(Flux.just(dave, boyd))).verifyComplete();
|
||||
repository.deleteAll(Flux.just(dave, boyd)).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
StepVerifier.create(repository.findById(boyd.getId())).expectNextCount(0).verifyComplete();
|
||||
repository.findById(boyd.getId()).as(StepVerifier::create).expectNextCount(0).verifyComplete();
|
||||
}
|
||||
|
||||
interface UserRepostitory extends ReactiveCassandraRepository<User, String> { }
|
||||
|
||||
Reference in New Issue
Block a user