DATACASS-553 - Adapt to SpEL Extension API changes in Spring Data Commons.
This commit is contained in:
@@ -42,4 +42,5 @@ public interface SessionFactory {
|
||||
* @return a {@link Session} to Apache Cassandra.
|
||||
*/
|
||||
Session getSession();
|
||||
|
||||
}
|
||||
|
||||
@@ -481,9 +481,8 @@ public class AsyncCassandraTemplate implements AsyncCassandraOperations, Applica
|
||||
Function<Row, T> mapper = getMapper(entityClass, entityClass, entity.getTableName());
|
||||
|
||||
return new MappingListenableFutureAdapter<>(
|
||||
getAsyncCqlOperations().query(select, (row, rowNum) -> mapper.apply(row)), it -> {
|
||||
return it.isEmpty() ? null : (T) it.get(0);
|
||||
});
|
||||
getAsyncCqlOperations().query(select, (row, rowNum) -> mapper.apply(row)),
|
||||
it -> it.isEmpty() ? null : (T) it.get(0));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface SessionFactoryLookup {
|
||||
* @throws SessionFactoryLookupFailureException if the lookup failed.
|
||||
*/
|
||||
SessionFactory getSessionFactory(String sessionFactoryName) throws SessionFactoryLookupFailureException;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.repository.query.EvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.Parameter;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@@ -39,7 +39,7 @@ class ExpressionEvaluatingParameterBinder {
|
||||
|
||||
private final SpelExpressionParser expressionParser;
|
||||
|
||||
private final EvaluationContextProvider evaluationContextProvider;
|
||||
private final QueryMethodEvaluationContextProvider evaluationContextProvider;
|
||||
|
||||
/**
|
||||
* Creates new {@link ExpressionEvaluatingParameterBinder}
|
||||
@@ -48,7 +48,7 @@ class ExpressionEvaluatingParameterBinder {
|
||||
* @param evaluationContextProvider must not be {@literal null}.
|
||||
*/
|
||||
ExpressionEvaluatingParameterBinder(SpelExpressionParser expressionParser,
|
||||
EvaluationContextProvider evaluationContextProvider) {
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
Assert.notNull(expressionParser, "ExpressionParser must not be null");
|
||||
Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null");
|
||||
@@ -202,6 +202,7 @@ class ExpressionEvaluatingParameterBinder {
|
||||
|
||||
private ParameterBinding(int parameterIndex, boolean quoted, @Nullable String expression,
|
||||
@Nullable String parameterName) {
|
||||
|
||||
this.parameterIndex = parameterIndex;
|
||||
this.quoted = quoted;
|
||||
this.expression = expression;
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.repository.query;
|
||||
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
import org.springframework.data.cassandra.repository.Query;
|
||||
import org.springframework.data.repository.query.EvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -47,17 +47,20 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
|
||||
|
||||
/**
|
||||
* Create a new {@link ReactiveStringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
|
||||
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
|
||||
* {@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 EvaluationContextProvider} 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
|
||||
*/
|
||||
public ReactiveStringBasedCassandraQuery(ReactiveCassandraQueryMethod queryMethod,
|
||||
ReactiveCassandraOperations operations, SpelExpressionParser expressionParser,
|
||||
EvaluationContextProvider evaluationContextProvider) {
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
this(queryMethod.getRequiredAnnotatedQuery(), queryMethod, operations, expressionParser,
|
||||
evaluationContextProvider);
|
||||
@@ -65,17 +68,20 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
|
||||
|
||||
/**
|
||||
* Create a new {@link ReactiveStringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
|
||||
* {@link ReactiveCassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
|
||||
* {@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 EvaluationContextProvider} 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
|
||||
*/
|
||||
public ReactiveStringBasedCassandraQuery(String query, ReactiveCassandraQueryMethod method,
|
||||
ReactiveCassandraOperations operations, SpelExpressionParser expressionParser,
|
||||
EvaluationContextProvider evaluationContextProvider) {
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
super(method, operations);
|
||||
|
||||
@@ -86,7 +92,7 @@ public class ReactiveStringBasedCassandraQuery extends AbstractReactiveCassandra
|
||||
|
||||
if (method.hasAnnotatedQuery()) {
|
||||
|
||||
Query queryAnnotation = method.getQueryAnnotation().get();
|
||||
Query queryAnnotation = method.getQueryAnnotation().orElse(null);
|
||||
|
||||
this.isCountQuery = queryAnnotation.count();
|
||||
this.isExistsQuery = queryAnnotation.exists();
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.repository.query;
|
||||
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.repository.Query;
|
||||
import org.springframework.data.repository.query.EvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
import com.datastax.driver.core.SimpleStatement;
|
||||
@@ -46,16 +46,18 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
|
||||
|
||||
/**
|
||||
* Create a new {@link StringBasedCassandraQuery} for the given {@link CassandraQueryMethod},
|
||||
* {@link CassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
|
||||
* {@link CassandraOperations}, {@link SpelExpressionParser}, and {@link QueryMethodEvaluationContextProvider}.
|
||||
*
|
||||
* @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 EvaluationContextProvider} 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, EvaluationContextProvider evaluationContextProvider) {
|
||||
SpelExpressionParser expressionParser, QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
this(queryMethod.getRequiredAnnotatedQuery(), queryMethod, operations, expressionParser,
|
||||
evaluationContextProvider);
|
||||
@@ -63,17 +65,19 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
|
||||
|
||||
/**
|
||||
* Create a new {@link StringBasedCassandraQuery} for the given {@code query}, {@link CassandraQueryMethod},
|
||||
* {@link CassandraOperations}, {@link SpelExpressionParser}, and {@link EvaluationContextProvider}.
|
||||
* {@link CassandraOperations}, {@link SpelExpressionParser}, and {@link QueryMethodEvaluationContextProvider}.
|
||||
*
|
||||
* @param query
|
||||
* @param query {@link String} containing the Apache Cassandra CQL query to execute.
|
||||
* @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 EvaluationContextProvider} 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(String query, CassandraQueryMethod method, CassandraOperations operations,
|
||||
SpelExpressionParser expressionParser, EvaluationContextProvider evaluationContextProvider) {
|
||||
SpelExpressionParser expressionParser, QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
super(method, operations);
|
||||
|
||||
@@ -82,7 +86,7 @@ public class StringBasedCassandraQuery extends AbstractCassandraQuery {
|
||||
|
||||
if (method.hasAnnotatedQuery()) {
|
||||
|
||||
Query queryAnnotation = method.getQueryAnnotation().get();
|
||||
Query queryAnnotation = method.getQueryAnnotation().orElse(null);
|
||||
|
||||
this.isCountQuery = queryAnnotation.count();
|
||||
this.isExistsQuery = queryAnnotation.exists();
|
||||
|
||||
@@ -32,9 +32,9 @@ import org.springframework.data.repository.core.NamedQueries;
|
||||
import org.springframework.data.repository.core.RepositoryInformation;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
import org.springframework.data.repository.query.EvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -107,19 +107,20 @@ public class CassandraRepositoryFactory extends RepositoryFactorySupport {
|
||||
*/
|
||||
@Override
|
||||
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
|
||||
EvaluationContextProvider evaluationContextProvider) {
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
|
||||
return Optional.of(new CassandraQueryLookupStrategy(operations, evaluationContextProvider, mappingContext));
|
||||
}
|
||||
|
||||
private class CassandraQueryLookupStrategy implements QueryLookupStrategy {
|
||||
|
||||
private final EvaluationContextProvider evaluationContextProvider;
|
||||
private final QueryMethodEvaluationContextProvider evaluationContextProvider;
|
||||
|
||||
private final MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext;
|
||||
|
||||
private final CassandraOperations operations;
|
||||
|
||||
CassandraQueryLookupStrategy(CassandraOperations operations, EvaluationContextProvider evaluationContextProvider,
|
||||
CassandraQueryLookupStrategy(CassandraOperations operations, QueryMethodEvaluationContextProvider evaluationContextProvider,
|
||||
MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext) {
|
||||
|
||||
this.operations = operations;
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.springframework.data.repository.core.NamedQueries;
|
||||
import org.springframework.data.repository.core.RepositoryInformation;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.ReactiveRepositoryFactorySupport;
|
||||
import org.springframework.data.repository.query.EvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -90,7 +90,7 @@ public class ReactiveCassandraRepositoryFactory extends ReactiveRepositoryFactor
|
||||
*/
|
||||
@Override
|
||||
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
|
||||
EvaluationContextProvider evaluationContextProvider) {
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
return Optional.of(new CassandraQueryLookupStrategy(operations, evaluationContextProvider, mappingContext));
|
||||
}
|
||||
|
||||
@@ -113,12 +113,12 @@ public class ReactiveCassandraRepositoryFactory extends ReactiveRepositoryFactor
|
||||
*/
|
||||
private static class CassandraQueryLookupStrategy implements QueryLookupStrategy {
|
||||
|
||||
private final EvaluationContextProvider evaluationContextProvider;
|
||||
private final QueryMethodEvaluationContextProvider evaluationContextProvider;
|
||||
private final ReactiveCassandraOperations operations;
|
||||
private final MappingContext<? extends CassandraPersistentEntity<?>, ? extends CassandraPersistentProperty> mappingContext;
|
||||
|
||||
CassandraQueryLookupStrategy(ReactiveCassandraOperations operations,
|
||||
EvaluationContextProvider evaluationContextProvider,
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider,
|
||||
MappingContext<? extends CassandraPersistentEntity<?>, ? extends CassandraPersistentProperty> mappingContext) {
|
||||
|
||||
this.evaluationContextProvider = evaluationContextProvider;
|
||||
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
@@ -44,7 +45,7 @@ import org.springframework.data.cassandra.repository.support.SimpleReactiveCassa
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.repository.query.DefaultEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -107,7 +108,7 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac
|
||||
factory.setRepositoryBaseClass(SimpleReactiveCassandraRepository.class);
|
||||
factory.setBeanClassLoader(classLoader);
|
||||
factory.setBeanFactory(beanFactory);
|
||||
factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE);
|
||||
factory.setEvaluationContextProvider(QueryMethodEvaluationContextProvider.DEFAULT);
|
||||
|
||||
repository = factory.getRepository(UserRepository.class);
|
||||
groupRepostitory = factory.getRepository(GroupRepository.class);
|
||||
@@ -228,5 +229,6 @@ public class ReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspac
|
||||
interface GroupRepository extends ReactiveCassandraRepository<Group, GroupKey> {
|
||||
|
||||
Flux<Group> findByIdGroupnameAndIdHashPrefix(String groupname, String hashPrefix, Sort sort);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.AbstractRepositoryMetadata;
|
||||
import org.springframework.data.repository.query.ExtensionAwareEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -57,17 +57,17 @@ import com.datastax.driver.core.SimpleStatement;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReactiveStringBasedCassandraQueryUnitTests {
|
||||
|
||||
SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@Mock ReactiveCassandraOperations operations;
|
||||
@Mock ReactiveCqlOperations cqlOperations;
|
||||
@Mock ReactiveSession reactiveSession;
|
||||
@Mock Cluster cluster;
|
||||
@Mock Configuration configuration;
|
||||
@Mock private Cluster cluster;
|
||||
@Mock private Configuration configuration;
|
||||
@Mock private ReactiveCassandraOperations operations;
|
||||
@Mock private ReactiveCqlOperations cqlOperations;
|
||||
@Mock private ReactiveSession reactiveSession;
|
||||
|
||||
RepositoryMetadata metadata;
|
||||
MappingCassandraConverter converter;
|
||||
ProjectionFactory factory;
|
||||
private MappingCassandraConverter converter;
|
||||
private ProjectionFactory factory;
|
||||
private RepositoryMetadata metadata;
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -136,9 +136,10 @@ public class ReactiveStringBasedCassandraQueryUnitTests {
|
||||
new ReactiveCassandraQueryMethod(method, metadata, factory, converter.getMappingContext());
|
||||
|
||||
return new ReactiveStringBasedCassandraQuery(queryMethod, operations, PARSER,
|
||||
new ExtensionAwareEvaluationContextProvider());
|
||||
ExtensionAwareQueryMethodEvaluationContextProvider.DEFAULT);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private interface SampleRepository extends Repository<Person, String> {
|
||||
|
||||
@Query("SELECT * FROM person WHERE lastname=?0;")
|
||||
@@ -147,5 +148,6 @@ public class ReactiveStringBasedCassandraQueryUnitTests {
|
||||
|
||||
@Query("SELECT * FROM person WHERE lastname=?0;")
|
||||
Person findByLastname(QueryOptions queryOptions, String lastname);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -32,6 +32,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.core.convert.MappingCassandraConverter;
|
||||
import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
@@ -48,7 +49,7 @@ import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.AbstractRepositoryMetadata;
|
||||
import org.springframework.data.repository.query.ExtensionAwareEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.repository.query.QueryCreationException;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@@ -70,15 +71,15 @@ import com.datastax.driver.core.UserType;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class StringBasedCassandraQueryUnitTests {
|
||||
|
||||
SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@Mock CassandraOperations operations;
|
||||
@Mock UserTypeResolver userTypeResolver;
|
||||
@Mock UDTValue udtValue;
|
||||
@Mock private CassandraOperations operations;
|
||||
@Mock private UDTValue udtValue;
|
||||
@Mock private UserTypeResolver userTypeResolver;
|
||||
|
||||
RepositoryMetadata metadata;
|
||||
MappingCassandraConverter converter;
|
||||
ProjectionFactory factory;
|
||||
private RepositoryMetadata metadata;
|
||||
private MappingCassandraConverter converter;
|
||||
private ProjectionFactory factory;
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -381,9 +382,10 @@ public class StringBasedCassandraQueryUnitTests {
|
||||
new CassandraQueryMethod(method, metadata, factory, converter.getMappingContext());
|
||||
|
||||
return new StringBasedCassandraQuery(queryMethod, operations, PARSER,
|
||||
new ExtensionAwareEvaluationContextProvider());
|
||||
ExtensionAwareQueryMethodEvaluationContextProvider.DEFAULT);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private interface SampleRepository extends Repository<Person, String> {
|
||||
|
||||
@Query("SELECT * FROM person WHERE lastname = ?0;")
|
||||
@@ -434,10 +436,11 @@ public class StringBasedCassandraQueryUnitTests {
|
||||
|
||||
@ComposedQueryAnnotation
|
||||
Person findByComposedQueryAnnotation(String lastname);
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Query("SELECT * FROM person WHERE lastname = ?0;")
|
||||
@interface ComposedQueryAnnotation {
|
||||
}
|
||||
@interface ComposedQueryAnnotation { }
|
||||
|
||||
}
|
||||
|
||||
@@ -37,16 +37,17 @@ import org.springframework.data.cassandra.domain.User;
|
||||
import org.springframework.data.cassandra.repository.CassandraRepository;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.repository.query.DefaultEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SimpleCassandraRepository}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest
|
||||
implements BeanClassLoaderAware, BeanFactoryAware {
|
||||
@@ -62,16 +63,16 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
@Autowired private CassandraOperations operations;
|
||||
|
||||
CassandraRepositoryFactory factory;
|
||||
ClassLoader classLoader;
|
||||
BeanFactory beanFactory;
|
||||
UserRepostitory repository;
|
||||
private BeanFactory beanFactory;
|
||||
private CassandraRepositoryFactory factory;
|
||||
private ClassLoader classLoader;
|
||||
private UserRepostitory repository;
|
||||
|
||||
User dave, oliver, carter, boyd;
|
||||
private User dave, oliver, carter, boyd;
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader == null ? org.springframework.util.ClassUtils.getDefaultClassLoader() : classLoader;
|
||||
this.classLoader = classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +87,7 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC
|
||||
factory.setRepositoryBaseClass(SimpleCassandraRepository.class);
|
||||
factory.setBeanClassLoader(classLoader);
|
||||
factory.setBeanFactory(beanFactory);
|
||||
factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE);
|
||||
factory.setEvaluationContextProvider(ExtensionAwareQueryMethodEvaluationContextProvider.DEFAULT);
|
||||
|
||||
repository = factory.getRepository(UserRepostitory.class);
|
||||
|
||||
@@ -301,5 +302,6 @@ public class SimpleCassandraRepositoryIntegrationTests extends AbstractKeyspaceC
|
||||
assertThat(loaded).isEmpty();
|
||||
}
|
||||
|
||||
interface UserRepostitory extends CassandraRepository<User, String> {}
|
||||
interface UserRepostitory extends CassandraRepository<User, String> { }
|
||||
|
||||
}
|
||||
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -36,9 +37,9 @@ import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
import org.springframework.data.cassandra.domain.User;
|
||||
import org.springframework.data.cassandra.repository.ReactiveCassandraRepository;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTest;
|
||||
import org.springframework.data.repository.query.DefaultEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.ExtensionAwareQueryMethodEvaluationContextProvider;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link SimpleReactiveCassandraRepository}.
|
||||
@@ -46,7 +47,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest
|
||||
implements BeanClassLoaderAware, BeanFactoryAware {
|
||||
@@ -60,14 +61,15 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired private ReactiveCassandraOperations operations;
|
||||
@Autowired
|
||||
private ReactiveCassandraOperations operations;
|
||||
|
||||
ReactiveCassandraRepositoryFactory factory;
|
||||
ClassLoader classLoader;
|
||||
BeanFactory beanFactory;
|
||||
UserRepostitory repository;
|
||||
private BeanFactory beanFactory;
|
||||
private ClassLoader classLoader;
|
||||
private ReactiveCassandraRepositoryFactory factory;
|
||||
private UserRepostitory repository;
|
||||
|
||||
User dave, oliver, carter, boyd;
|
||||
private User dave, oliver, carter, boyd;
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
@@ -86,7 +88,7 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
factory.setRepositoryBaseClass(SimpleReactiveCassandraRepository.class);
|
||||
factory.setBeanClassLoader(classLoader);
|
||||
factory.setBeanFactory(beanFactory);
|
||||
factory.setEvaluationContextProvider(DefaultEvaluationContextProvider.INSTANCE);
|
||||
factory.setEvaluationContextProvider(ExtensionAwareQueryMethodEvaluationContextProvider.DEFAULT);
|
||||
|
||||
repository = factory.getRepository(UserRepostitory.class);
|
||||
|
||||
@@ -380,5 +382,6 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
StepVerifier.create(repository.findById(boyd.getId())).expectNextCount(0).verifyComplete();
|
||||
}
|
||||
|
||||
interface UserRepostitory extends ReactiveCassandraRepository<User, String> {}
|
||||
interface UserRepostitory extends ReactiveCassandraRepository<User, String> { }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user