DATACASS-663 - Replace StepVerifier.create(…) style with .as(StepVerifier::create) style.

This commit is contained in:
Mark Paluch
2019-06-05 16:34:10 +02:00
parent 624e6a1bdf
commit e90777c69f
84 changed files with 516 additions and 584 deletions

View File

@@ -113,9 +113,8 @@ public interface AsyncCassandraOperations {
<T> ListenableFuture<List<T>> select(Statement statement, Class<T> entityClass) throws DataAccessException;
/**
* Execute a {@code SELECT} query with paging and convert the result set to a {@link Slice} of entities.
*
* A sliced query translates the effective {@link Statement#getFetchSize() fetch size} to the page size.
* Execute a {@code SELECT} query with paging and convert the result set to a {@link Slice} of entities. A sliced
* query translates the effective {@link Statement#getFetchSize() fetch size} to the page size.
*
* @param statement the CQL statement, must not be {@literal null}.
* @param entityClass The entity type must not be {@literal null}.
@@ -230,10 +229,9 @@ public interface AsyncCassandraOperations {
ListenableFuture<Long> count(Class<?> entityClass) throws DataAccessException;
/**
* Returns the number of rows for the given entity class applying {@link Query}.
*
* This overridden method allows users to further refine the selection criteria using a {@link Query} predicate
* to determine how many entities of the given {@link Class type} match the criteria.
* Returns the number of rows for the given entity class applying {@link Query}. This overridden method allows users
* to further refine the selection criteria using a {@link Query} predicate to determine how many entities of the
* given {@link Class type} match the criteria.
*
* @param query user-provided count {@link Query} to execute; must not be {@literal null}.
* @param entityClass {@link Class type} of the entity; must not be {@literal null}.
@@ -246,9 +244,9 @@ public interface AsyncCassandraOperations {
/**
* Determine whether a row of {@code entityClass} with the given {@code id} exists.
*
* @param id Id value. For single primary keys it's the plain value. For composite primary keys either, it's
* an instance of either {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass}
* or {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
* @param id Id value. For single primary keys it's the plain value. For composite primary keys either, it's an
* instance of either {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass} or
* {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
* @param entityClass {@link Class type} of the entity; must not be {@literal null}.
* @return {@literal true} if the object exists.
* @throws DataAccessException if any problem occurs while executing the query.

View File

@@ -312,8 +312,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
Assert.notNull(query, "Query must not be null");
Assert.notNull(entityClass, "Entity type must not be null");
return select(getStatementFactory().select(query, getRequiredPersistentEntity(entityClass)),
entityClass);
return select(getStatementFactory().select(query, getRequiredPersistentEntity(entityClass)), entityClass);
}
/* (non-Javadoc)
@@ -325,8 +324,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
Assert.notNull(query, "Query must not be null");
Assert.notNull(entityClass, "Entity type must not be null");
return slice(this.statementFactory.select(query, getRequiredPersistentEntity(entityClass)),
entityClass);
return slice(this.statementFactory.select(query, getRequiredPersistentEntity(entityClass)), entityClass);
}
/* (non-Javadoc)
@@ -340,8 +338,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
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)
@@ -353,8 +351,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
Assert.notNull(query, "Query must not be null");
Assert.notNull(entityClass, "Entity type must not be null");
return selectOne(getStatementFactory().select(query, getRequiredPersistentEntity(entityClass)),
entityClass);
return selectOne(getStatementFactory().select(query, getRequiredPersistentEntity(entityClass)), entityClass);
}
/* (non-Javadoc)
@@ -368,8 +365,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
Assert.notNull(update, "Update must not be null");
Assert.notNull(entityClass, "Entity type must not be null");
return getAsyncCqlOperations().execute(
getStatementFactory().update(query, update, getRequiredPersistentEntity(entityClass)));
return getAsyncCqlOperations()
.execute(getStatementFactory().update(query, update, getRequiredPersistentEntity(entityClass)));
}
/* (non-Javadoc)
@@ -482,7 +479,7 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
return new MappingListenableFutureAdapter<>(
getAsyncCqlOperations().query(select, (row, rowNum) -> mapper.apply(row)),
it -> it.isEmpty() ? null : (T) it.get(0));
it -> it.isEmpty() ? null : (T) it.get(0));
}
/* (non-Javadoc)

View File

@@ -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
*/

View File

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

View File

@@ -134,9 +134,8 @@ public interface CassandraOperations extends FluentCassandraOperations {
<T> List<T> select(Statement statement, Class<T> entityClass) throws DataAccessException;
/**
* Execute a {@code SELECT} query with paging and convert the result set to a {@link Slice} of entities.
*
* A sliced query translates the effective {@link Statement#getFetchSize() fetch size} to the page size.
* Execute a {@code SELECT} query with paging and convert the result set to a {@link Slice} of entities. A sliced
* query translates the effective {@link Statement#getFetchSize() fetch size} to the page size.
*
* @param statement the CQL statement, must not be {@literal null}.
* @param entityClass The entity type must not be {@literal null}.
@@ -257,10 +256,9 @@ public interface CassandraOperations extends FluentCassandraOperations {
long count(Class<?> entityClass) throws DataAccessException;
/**
* Returns the number of rows for the given entity class applying {@link Query}.
*
* This overridden method allows users to further refine the selection criteria using a {@link Query} predicate
* to determine how many entities of the given {@link Class type} match the criteria.
* Returns the number of rows for the given entity class applying {@link Query}. This overridden method allows users
* to further refine the selection criteria using a {@link Query} predicate to determine how many entities of the
* given {@link Class type} match the criteria.
*
* @param query user-defined count {@link Query} to execute; must not be {@literal null}.
* @param entityClass {@link Class type} of the entity; must not be {@literal null}.
@@ -273,9 +271,9 @@ public interface CassandraOperations extends FluentCassandraOperations {
/**
* Determine whether a row of {@code entityClass} with the given {@code id} exists.
*
* @param id Id value. For single primary keys it's the plain value. For composite primary keys either, it's
* an instance of either {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass}
* or {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
* @param id Id value. For single primary keys it's the plain value. For composite primary keys either, it's an
* instance of either {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass} or
* {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
* @param entityClass {@link Class type} of the entity; must not be {@literal null}.
* @return {@literal true} if the object exists.
* @throws DataAccessException if any problem occurs while executing the query.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -95,7 +95,6 @@ public interface ReactiveCassandraBatchOperations {
*/
ReactiveCassandraBatchOperations insert(Iterable<?> entities, WriteOptions options);
/**
* Add a collection of inserts with given {@link WriteOptions} to the batch.
*

View File

@@ -203,10 +203,9 @@ public interface ReactiveCassandraOperations extends ReactiveFluentCassandraOper
Mono<Long> count(Class<?> entityClass) throws DataAccessException;
/**
* Returns the number of rows for the given entity class applying {@link Query}.
*
* This overridden method allows users to further refine the selection criteria using a {@link Query} predicate
* to determine how many entities of the given {@link Class type} match the criteria.
* Returns the number of rows for the given entity class applying {@link Query}. This overridden method allows users
* to further refine the selection criteria using a {@link Query} predicate to determine how many entities of the
* given {@link Class type} match the criteria.
*
* @param query user-defined count {@link Query} to execute; must not be {@literal null}.
* @param entityClass {@link Class type} of the entity; must not be {@literal null}.
@@ -219,9 +218,9 @@ public interface ReactiveCassandraOperations extends ReactiveFluentCassandraOper
/**
* Determine whether a row of {@code entityClass} with the given {@code id} exists.
*
* @param id Id value. For single primary keys it's the plain value. For composite primary keys either, it's
* an instance of either {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass}
* or {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
* @param id Id value. For single primary keys it's the plain value. For composite primary keys either, it's an
* instance of either {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass} or
* {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
* @param entityClass {@link Class type} of the entity; must not be {@literal null}.
* @return {@literal true} if the object exists.
* @throws DataAccessException if any problem occurs while executing the query.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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>
@@ -136,8 +136,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 {}

View File

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

View File

@@ -190,8 +190,8 @@ public class StatementFactory {
return createSelect(query, entity, filter, selectors, tableName);
}
private Select createSelect(Query query, CassandraPersistentEntity<?> entity, Filter filter,
List<Selector> selectors, CqlIdentifier tableName) {
private Select createSelect(Query query, CassandraPersistentEntity<?> entity, Filter filter, List<Selector> selectors,
CqlIdentifier tableName) {
Sort sort = Optional.of(query.getSort()).map(querySort -> getQueryMapper().getMappedSort(querySort, entity))
.orElse(Sort.unsorted());
@@ -223,8 +223,8 @@ public class StatementFactory {
Selection selection = QueryBuilder.select();
selectors.forEach(selector ->
selector.getAlias().map(CqlIdentifier::toCql).ifPresent(getSelection(selection, selector)::as));
selectors.forEach(
selector -> selector.getAlias().map(CqlIdentifier::toCql).ifPresent(getSelection(selection, selector)::as));
select = selection.from(from.toCql());
}
@@ -538,7 +538,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()));
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -132,9 +132,8 @@ public class QueryMapper {
Object value = predicate.getValue();
Object mappedValue = value != null
? getConverter().convertToColumnType(value, getTypeInformation(field, value))
: null;
Object mappedValue = value != null ? getConverter().convertToColumnType(value, getTypeInformation(field, value))
: null;
Predicate mappedPredicate = new Predicate(predicate.getOperator(), mappedValue);
@@ -166,9 +165,8 @@ public class QueryMapper {
Field field = createPropertyField(entity, column);
columns.getSelector(column).ifPresent(selector ->
getCqlIdentifier(column, field).ifPresent(cqlIdentifier ->
selectors.add(getMappedSelector(selector, cqlIdentifier))));
columns.getSelector(column).ifPresent(selector -> getCqlIdentifier(column, field)
.ifPresent(cqlIdentifier -> selectors.add(getMappedSelector(selector, cqlIdentifier))));
}
if (columns.isEmpty()) {
@@ -255,10 +253,8 @@ public class QueryMapper {
field.getProperty().ifPresent(seen::add);
columns.getSelector(column)
.filter(selector -> selector instanceof ColumnSelector)
.ifPresent(columnSelector ->
getCqlIdentifier(column, field).map(CqlIdentifier::toCql).ifPresent(columnNames::add));
columns.getSelector(column).filter(selector -> selector instanceof ColumnSelector).ifPresent(
columnSelector -> getCqlIdentifier(column, field).map(CqlIdentifier::toCql).ifPresent(columnNames::add));
}
if (columns.isEmpty()) {
@@ -333,7 +329,7 @@ public class QueryMapper {
Field createPropertyField(@Nullable CassandraPersistentEntity<?> entity, ColumnName key) {
return Optional.ofNullable(entity).<Field>map(e -> new MetadataBackedField(key, e, getMappingContext()))
return Optional.ofNullable(entity).<Field> map(e -> new MetadataBackedField(key, e, getMappingContext()))
.orElseGet(() -> new Field(key));
}
@@ -464,8 +460,8 @@ public class QueryMapper {
PropertyPath propertyPath = PropertyPath.from(pathExpression.replaceAll("\\.\\d", ""),
this.entity.getTypeInformation());
PersistentPropertyPath<CassandraPersistentProperty> persistentPropertyPath =
this.mappingContext.getPersistentPropertyPath(propertyPath);
PersistentPropertyPath<CassandraPersistentProperty> persistentPropertyPath = this.mappingContext
.getPersistentPropertyPath(propertyPath);
return Optional.of(persistentPropertyPath);
} catch (PropertyReferenceException e) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -39,14 +39,14 @@ public @interface CassandraType {
DataType.Name type();
/**
* If the property is {@link java.util.Collection Collection-like}, then this attribute holds
* a single {@link DataType.Name DataType Name} representing the element type of the {@link java.util.Collection}.
* If the property is {@link java.util.Collection Collection-like}, then this attribute holds a single
* {@link DataType.Name DataType Name} representing the element type of the {@link java.util.Collection}.
* <p/>
* If the property is a {@link java.util.Map}, then this attribute holds exactly
* two {@link DataType.Name DataType Names}; the first is the key type and the second is the value type.
* If the property is a {@link java.util.Map}, then this attribute holds exactly two {@link DataType.Name DataType
* Names}; the first is the key type and the second is the value type.
* <p/>
* If the property is neither {@link java.util.Collection Collection-like} nor a {@link java.util.Map},
* then this attribute is ignored.
* If the property is neither {@link java.util.Collection Collection-like} nor a {@link java.util.Map}, then this
* attribute is ignored.
*
* @return an array of {@link DataType.Name} objects.
* @see com.datastax.driver.core.DataType.Name
@@ -54,10 +54,9 @@ public @interface CassandraType {
DataType.Name[] typeArguments() default {};
/**
* If the property maps to a User-Defined Type (UDT) then this attribute holds the user type name.
*
* For {@link java.util.Collection Collection-like} properties the user type name applies to the component type.
* The user type name is only required if the UDT does not map to a class annotated with {@link UserDefinedType}.
* If the property maps to a User-Defined Type (UDT) then this attribute holds the user type name. For
* {@link java.util.Collection Collection-like} properties the user type name applies to the component type. The user
* type name is only required if the UDT does not map to a class annotated with {@link UserDefinedType}.
*
* @return {@link String name} of the user type
* @since 1.5

View File

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

View File

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

View File

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

View File

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

View File

@@ -113,9 +113,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
@@ -131,12 +129,7 @@ public interface CriteriaDefinition {
return toString();
}
},
GT(">"),
GTE(">="),
LT("<"),
LTE("<="),
IN("IN"),
LIKE("LIKE");
GT(">"), GTE(">="), LT("<"), LTE("<="), IN("IN"), LIKE("LIKE");
private final String operator;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,10 +15,13 @@
*/
package org.springframework.data.cassandra.repository.query;
import lombok.RequiredArgsConstructor;
import java.util.Optional;
import java.util.function.Function;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.cassandra.core.StatementFactory;
import org.springframework.data.cassandra.core.cql.QueryOptions;
@@ -30,9 +33,6 @@ import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.repository.query.QueryCreationException;
import org.springframework.data.repository.query.parser.PartTree;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.datastax.driver.core.RegularStatement;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Statement;
@@ -65,8 +65,7 @@ class QueryStatementCreator {
* @param parameterAccessor must not be {@literal null}.
* @return the {@literal SELECT} {@link Statement}.
*/
Statement select(StatementFactory statementFactory, PartTree tree,
CassandraParameterAccessor parameterAccessor) {
Statement select(StatementFactory statementFactory, PartTree tree, CassandraParameterAccessor parameterAccessor) {
Function<Query, Statement> function = query -> {
@@ -144,8 +143,7 @@ class QueryStatementCreator {
<T> T doWithQuery(CassandraParameterAccessor parameterAccessor, PartTree tree,
Function<Query, ? extends T> function) {
CassandraQueryCreator queryCreator =
new CassandraQueryCreator(tree, parameterAccessor, this.mappingContext);
CassandraQueryCreator queryCreator = new CassandraQueryCreator(tree, parameterAccessor, this.mappingContext);
Query query = queryCreator.createQuery();
@@ -164,9 +162,8 @@ class QueryStatementCreator {
if (queryOptions.isPresent()) {
query = Optional.ofNullable(parameterAccessor.getQueryOptions()).map(query::queryOptions).orElse(query);
} else if (this.queryMethod.hasConsistencyLevel()) {
query = query.queryOptions(QueryOptions.builder()
.consistencyLevel(this.queryMethod.getRequiredAnnotatedConsistencyLevel())
.build());
query = query.queryOptions(
QueryOptions.builder().consistencyLevel(this.queryMethod.getRequiredAnnotatedConsistencyLevel()).build());
}
return function.apply(query);
@@ -178,8 +175,7 @@ class QueryStatementCreator {
private boolean allowsFiltering() {
return this.queryMethod.getQueryAnnotation()
.map(org.springframework.data.cassandra.repository.Query::allowFiltering)
.orElse(false);
.map(org.springframework.data.cassandra.repository.Query::allowFiltering).orElse(false);
}
/**
@@ -201,8 +197,7 @@ class QueryStatementCreator {
if (queryOptions.isPresent()) {
queryToUse = Optional.ofNullable(parameterAccessor.getQueryOptions())
.map(it -> QueryOptionsUtil.addQueryOptions(boundQuery, it))
.orElse(boundQuery);
.map(it -> QueryOptionsUtil.addQueryOptions(boundQuery, it)).orElse(boundQuery);
} else if (this.queryMethod.hasConsistencyLevel()) {
queryToUse.setConsistencyLevel(this.queryMethod.getRequiredAnnotatedConsistencyLevel());
}

View File

@@ -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
*/

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

@@ -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();
}
@@ -377,7 +377,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 {

View File

@@ -89,7 +89,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();
@@ -102,7 +102,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();
@@ -123,7 +123,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();
@@ -136,7 +136,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';");
@@ -147,7 +147,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';");
@@ -158,7 +158,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;");
@@ -169,7 +169,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;");
@@ -182,7 +182,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;");
@@ -195,7 +195,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;");
@@ -208,7 +208,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())
@@ -222,7 +222,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);
@@ -237,7 +237,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())
@@ -252,7 +252,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';");
@@ -261,7 +261,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;");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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,18 +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",
new Sort(Direction.ASC, "id.username"))) //
groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash", new Sort(Direction.ASC, "id.username"))
.as(StepVerifier::create) //
.expectNext(new Group(key1), new Group(key2)) //
.verifyComplete();
StepVerifier
.create(groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash",
new Sort(Direction.DESC, "id.username"))) //
groupRepostitory.findByIdGroupnameAndIdHashPrefix("Simpsons", "hash", new Sort(Direction.DESC, "id.username"))
.as(StepVerifier::create) //
.expectNext(new Group(key2), new Group(key1)) //
.verifyComplete();
}
@@ -201,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> {

View File

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