use of org.springframework.data.cassandra.core.cql.QueryOptions in project spring-data-cassandra by spring-projects.
the class ReactiveStringBasedCassandraQueryUnitTests method shouldApplyQueryOptions.
// DATACASS-146
@Test
void shouldApplyQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().pageSize(777).build();
ReactiveStringBasedCassandraQuery cassandraQuery = getQueryMethod("findByLastname", QueryOptions.class, String.class);
CassandraParametersParameterAccessor parameterAccessor = new CassandraParametersParameterAccessor(cassandraQuery.getQueryMethod(), queryOptions, "White");
SimpleStatement actual = cassandraQuery.createQuery(parameterAccessor).block();
assertThat(actual.getQuery()).isEqualTo("SELECT * FROM person WHERE lastname=?;");
assertThat(actual.getPositionalValues().get(0)).isEqualTo("White");
assertThat(actual.getPageSize()).isEqualTo(777);
}
use of org.springframework.data.cassandra.core.cql.QueryOptions in project spring-data-cassandra by spring-projects.
the class CassandraParametersParameterAccessorUnitTests method shouldProvideQueryOptions.
// DATACASS-146
@Test
void shouldProvideQueryOptions() throws Exception {
QueryOptions options = QueryOptions.builder().build();
Method method = PossibleRepository.class.getMethod("findByFirstname", QueryOptions.class, String.class);
CassandraParameterAccessor accessor = new CassandraParametersParameterAccessor(getCassandraQueryMethod(method), options, "firstname");
assertThat(accessor.getQueryOptions()).isEqualTo(options);
}
use of org.springframework.data.cassandra.core.cql.QueryOptions in project spring-data-cassandra by spring-projects.
the class PartTreeCassandraQueryUnitTests method shouldApplyQueryOptions.
// DATACASS-146
@Test
void shouldApplyQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().pageSize(777).build();
SimpleStatement statement = deriveQueryFromMethod(Repo.class, "findByFirstname", new Class[] { QueryOptions.class, String.class }, queryOptions, "Walter");
assertThat(statement.getQuery()).isEqualTo("SELECT * FROM person WHERE firstname=?");
assertThat(statement.getPageSize()).isEqualTo(777);
}
use of org.springframework.data.cassandra.core.cql.QueryOptions in project spring-data-cassandra by spring-projects.
the class StringBasedCassandraQueryUnitTests method shouldApplyQueryOptions.
// DATACASS-146
@Test
void shouldApplyQueryOptions() {
QueryOptions queryOptions = QueryOptions.builder().pageSize(777).build();
StringBasedCassandraQuery cassandraQuery = getQueryMethod("findByLastname", QueryOptions.class, String.class);
CassandraParametersParameterAccessor parameterAccessor = new CassandraParametersParameterAccessor(cassandraQuery.getQueryMethod(), queryOptions, "Matthews");
SimpleStatement actual = cassandraQuery.createQuery(parameterAccessor);
assertThat(actual.getQuery()).isEqualTo("SELECT * FROM person WHERE lastname = ?;");
assertThat(actual.getPositionalValues().get(0)).isEqualTo("Matthews");
assertThat(actual.getPageSize()).isEqualTo(777);
}
use of org.springframework.data.cassandra.core.cql.QueryOptions in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method selectByQueryWithKeyspaceShouldRetrieveData.
// DATACASS-767
@Test
void selectByQueryWithKeyspaceShouldRetrieveData() {
assumeThat(cassandraVersion.isGreaterThanOrEqualTo(CASSANDRA_4)).isTrue();
QueryOptions queryOptions = QueryOptions.builder().keyspace(CqlIdentifier.fromCql(keyspace)).build();
User user = new User("heisenberg", "Walter", "White");
template.insert(user);
Query query = Query.query(where("id").is("heisenberg")).queryOptions(queryOptions);
assertThat(template.select(query, User.class)).isNotEmpty();
}
Aggregations