From 67a5cb63c5da8cbbc05291e5400b2169720546b8 Mon Sep 17 00:00:00 2001 From: roimenashe Date: Wed, 10 Mar 2021 13:52:12 +0200 Subject: [PATCH 1/2] Repository package cleanup. --- .../repository/AerospikeRepository.java | 9 ++-- ...spikeRepositoryConfigurationExtension.java | 5 +- .../config/EnableAerospikeRepositories.java | 24 +-------- .../EnableReactiveAerospikeRepositories.java | 12 ----- .../repository/query/AerospikeCriteria.java | 3 -- .../query/AerospikeParameterAccessor.java | 2 - .../query/AerospikePartTreeQuery.java | 11 ++-- .../query/AerospikeQueryCreator.java | 10 ++-- .../query/BaseAerospikePartTreeQuery.java | 6 +-- .../aerospike/repository/query/Criteria.java | 3 -- .../repository/query/CriteriaDefinition.java | 4 +- .../aerospike/repository/query/Query.java | 5 +- .../support/AerospikeRepositoryFactory.java | 52 +++++++------------ .../AerospikeRepositoryFactoryBean.java | 4 -- .../BaseAerospikeRepositoryFactoryBean.java | 1 - .../ReactiveAerospikeRepositoryFactory.java | 34 ++++-------- .../support/SimpleAerospikeRepository.java | 11 ++-- .../SimpleReactiveAerospikeRepository.java | 1 - 18 files changed, 56 insertions(+), 141 deletions(-) diff --git a/src/main/java/org/springframework/data/aerospike/repository/AerospikeRepository.java b/src/main/java/org/springframework/data/aerospike/repository/AerospikeRepository.java index 063629d09..9f58b4c6b 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/AerospikeRepository.java +++ b/src/main/java/org/springframework/data/aerospike/repository/AerospikeRepository.java @@ -29,19 +29,18 @@ */ public interface AerospikeRepository extends PagingAndSortingRepository { - void createIndex(Class domainType, String indexName, String binName, IndexType indexType); + void createIndex(Class domainType, String indexName, String binName, IndexType indexType); - void deleteIndex(Class domainType, String indexName); + void deleteIndex(Class domainType, String indexName); /** * Checks whether index by specified name exists in Aerospike. - * @param indexName + * @param indexName The Aerospike index name. * @return true if exists * @deprecated This operation is deprecated due to complications that are required for guaranteed index existence response. - *

If you need to conditionally create index \u2014 replace {@link #indexExists} with {@link #createIndex} and catch {@link IndexAlreadyExistsException}. + *

If you need to conditionally create index \u2014 replace this method (indexExists) with {@link #createIndex} and catch {@link IndexAlreadyExistsException}. *

More information can be found at: https://github.com/aerospike/aerospike-client-java/pull/149 */ @Deprecated boolean indexExists(String indexName); - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java index 8f26676e6..01f48db2b 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/BaseAerospikeRepositoryConfigurationExtension.java @@ -21,6 +21,7 @@ import org.springframework.data.aerospike.repository.query.AerospikeQueryCreator; import org.springframework.data.keyvalue.repository.config.KeyValueRepositoryConfigurationExtension; import org.springframework.data.keyvalue.repository.config.QueryCreatorType; +import org.springframework.data.keyvalue.repository.query.SpelQueryCreator; import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource; import java.util.Map; @@ -45,8 +46,8 @@ public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfi * Detects the query creator type to be used for the factory to set. Will lookup a {@link QueryCreatorType} annotation * on the {@code @Enable}-annotation or use {@link SpelQueryCreator} if not found. * - * @param config - * @return + * @param config The annotation repository configuration to get the query creator metadata from. + * @return Query creator class. */ private static Class getQueryCreatorType(AnnotationRepositoryConfigurationSource config) { diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java b/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java index 89e10a944..5e43e823b 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/EnableAerospikeRepositories.java @@ -15,23 +15,17 @@ */ package org.springframework.data.aerospike.repository.config; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - import org.springframework.beans.factory.FactoryBean; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Import; import org.springframework.data.aerospike.repository.support.AerospikeRepositoryFactoryBean; import org.springframework.data.aerospike.repository.support.SimpleAerospikeRepository; import org.springframework.data.keyvalue.core.KeyValueOperations; -import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactoryBean; import org.springframework.data.repository.query.QueryLookupStrategy; import org.springframework.data.repository.query.QueryLookupStrategy.Key; +import java.lang.annotation.*; + /** * Annotation to activate Aerospike repositories. If no base package is configured through either {@link #value()}, * {@link #basePackages()} or {@link #basePackageClasses()} it will trigger scanning of the package of annotated class. @@ -43,8 +37,6 @@ @Documented @Inherited @Import(AerospikeRepositoriesRegistrar.class) -//@QueryCreatorType(SpelQueryCreator.class) -//@QueryCreatorType(AerospikeQueryCreator.class) public @interface EnableAerospikeRepositories { /** @@ -81,47 +73,35 @@ * Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So * for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning * for {@code PersonRepositoryImpl}. - * - * @return */ String repositoryImplementationPostfix() default "Impl"; /** * Configures the location of where to find the Spring Data named queries properties file. - * - * @return */ String namedQueriesLocation() default ""; /** * Returns the key of the {@link QueryLookupStrategy} to be used for lookup queries for query methods. Defaults to * {@link Key#CREATE_IF_NOT_FOUND}. - * - * @return */ Key queryLookupStrategy() default Key.CREATE_IF_NOT_FOUND; /** * Returns the {@link FactoryBean} class to be used for each repository instance. * Defaults to {@link AerospikeRepositoryFactoryBean}. - * - * @return */ Class repositoryFactoryBeanClass() default AerospikeRepositoryFactoryBean.class; /** * Configure the repository base class to be used to create repository proxies for this particular configuration. * Defaults to {@link SimpleAerospikeRepository}. - * - * @return * @since 1.8 */ Class repositoryBaseClass() default SimpleAerospikeRepository.class; /** * Configures the name of the {@link KeyValueOperations} bean to be used with the repositories detected. - * - * @return */ String keyValueTemplateRef() default "aerospikeTemplate"; diff --git a/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java b/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java index a4cc276c5..a995c6ff7 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java +++ b/src/main/java/org/springframework/data/aerospike/repository/config/EnableReactiveAerospikeRepositories.java @@ -73,47 +73,35 @@ * Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So * for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning * for {@code PersonRepositoryImpl}. - * - * @return */ String repositoryImplementationPostfix() default "Impl"; /** * Configures the location of where to find the Spring Data named queries properties file. - * - * @return */ String namedQueriesLocation() default ""; /** * Returns the key of the {@link QueryLookupStrategy} to be used for lookup queries for query methods. Defaults to * {@link Key#CREATE_IF_NOT_FOUND}. - * - * @return */ Key queryLookupStrategy() default Key.CREATE_IF_NOT_FOUND; /** * Returns the {@link FactoryBean} class to be used for each repository instance. Defaults to * {@link ReactiveAerospikeRepositoryFactoryBean}. - * - * @return */ Class repositoryFactoryBeanClass() default ReactiveAerospikeRepositoryFactoryBean.class; /** * Configure the repository base class to be used to create repository proxies for this particular configuration. * Defaults to {@link SimpleReactiveAerospikeRepository}. - * - * @return * @since 1.8 */ Class repositoryBaseClass() default SimpleReactiveAerospikeRepository.class; /** * Configures the name of the {@link KeyValueOperations} bean to be used with the repositories detected. - * - * @return */ String keyValueTemplateRef() default "reactiveAerospikeTemplate"; diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeCriteria.java b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeCriteria.java index 58615e284..6f5097364 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeCriteria.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeCriteria.java @@ -20,10 +20,8 @@ import org.springframework.data.aerospike.query.Qualifier; /** - * * @author Michael Zhang * @author Jeff Boone - * */ public class AerospikeCriteria extends Qualifier implements CriteriaDefinition { @@ -64,5 +62,4 @@ public Qualifier getCriteriaObject() { public String getKey() { return this.getField(); } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeParameterAccessor.java b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeParameterAccessor.java index 3645caf04..9138b2264 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeParameterAccessor.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeParameterAccessor.java @@ -18,10 +18,8 @@ import org.springframework.data.repository.query.ParameterAccessor; /** - * * @author Peter Milne * @author Jean Mercier - * */ public interface AerospikeParameterAccessor extends ParameterAccessor { diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikePartTreeQuery.java b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikePartTreeQuery.java index 4f0bd3985..2751dff3a 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikePartTreeQuery.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikePartTreeQuery.java @@ -26,17 +26,17 @@ import java.util.stream.Stream; /** - * * @author Peter Milne * @author Jean Mercier - * */ public class AerospikePartTreeQuery extends BaseAerospikePartTreeQuery { private final AerospikeOperations aerospikeOperations; - public AerospikePartTreeQuery(QueryMethod queryMethod, QueryMethodEvaluationContextProvider evalContextProvider, - AerospikeOperations aerospikeOperations, Class> queryCreator) { + public AerospikePartTreeQuery(QueryMethod queryMethod, + QueryMethodEvaluationContextProvider evalContextProvider, + AerospikeOperations aerospikeOperations, + Class> queryCreator) { super(queryMethod, evalContextProvider, queryCreator); this.aerospikeOperations = aerospikeOperations; } @@ -51,10 +51,8 @@ public Object execute(Object[] parameters) { Query query = prepareQuery(parameters, accessor); if (queryMethod.isPageQuery() || queryMethod.isSliceQuery()) { - Stream result = findByQuery(query); long total = queryMethod.isSliceQuery() ? 0 : aerospikeOperations.count(query, queryMethod.getEntityInformation().getJavaType()); - //TODO: should return SliceImpl for slice query return new PageImpl(result.collect(Collectors.toList()), accessor.getPageable(), total); } else if (queryMethod.isStreamQuery()) { @@ -65,7 +63,6 @@ public Object execute(Object[] parameters) { Stream result = findByQuery(query); return result.findFirst().orElse(null); } - throw new UnsupportedOperationException("Query method " + queryMethod.getNamedQueryName() + " not supported."); } diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreator.java b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreator.java index 949e291da..b17dcb426 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreator.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreator.java @@ -108,7 +108,7 @@ private AerospikeCriteria create(Part part, AerospikePersistentProperty property throw new IllegalArgumentException("Unsupported keyword!"); } - //customization for collection/map query + // Customization for collection/map query TypeInformation propertyType = property.getTypeInformation(); if (propertyType.isCollectionLike()) { if (op == FilterOperation.CONTAINING) { @@ -132,9 +132,9 @@ private AerospikeCriteria create(Part part, AerospikePersistentProperty property } } - if(null == v2) - return new AerospikeCriteria(fieldName, op, ignoreCase==IgnoreCaseType.ALWAYS, Value.get(v1)); - + if (null == v2) { + return new AerospikeCriteria(fieldName, op, ignoreCase == IgnoreCaseType.ALWAYS, Value.get(v1)); + } return new AerospikeCriteria(fieldName, op, Value.get(v1), Value.get(v2)); } @@ -176,7 +176,7 @@ protected Query complete(AerospikeCriteria criteria, Sort sort) { } @SuppressWarnings("unused") - private boolean isSimpleComparisionPossible(Part part) { + private boolean isSimpleComparisonPossible(Part part) { switch (part.shouldIgnoreCase()) { case WHEN_POSSIBLE: return part.getProperty().getType() != String.class; diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/BaseAerospikePartTreeQuery.java b/src/main/java/org/springframework/data/aerospike/repository/query/BaseAerospikePartTreeQuery.java index b1d53d43f..9f33b84b7 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/BaseAerospikePartTreeQuery.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/BaseAerospikePartTreeQuery.java @@ -36,8 +36,8 @@ public abstract class BaseAerospikePartTreeQuery implements RepositoryQuery { private final Class> queryCreator; protected final QueryMethod queryMethod; - - public BaseAerospikePartTreeQuery(QueryMethod queryMethod, QueryMethodEvaluationContextProvider evalContextProvider, + public BaseAerospikePartTreeQuery(QueryMethod queryMethod, + QueryMethodEvaluationContextProvider evalContextProvider, Class> queryCreator) { this.queryMethod = queryMethod; this.evaluationContextProvider = evalContextProvider; @@ -81,7 +81,6 @@ protected Query prepareQuery(Object[] parameters, ParametersParameterAccessor ac return q; } - public Query createQuery(ParametersParameterAccessor accessor) { PartTree tree = new PartTree(queryMethod.getName(), queryMethod.getEntityInformation().getJavaType()); @@ -89,5 +88,4 @@ public Query createQuery(ParametersParameterAccessor accessor) { .getConstructorIfAvailable(queryCreator, PartTree.class, ParameterAccessor.class); return (Query) BeanUtils.instantiateClass(constructor, tree, accessor).createQuery(); } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/Criteria.java b/src/main/java/org/springframework/data/aerospike/repository/query/Criteria.java index 5ff776c06..34a8a1aef 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/Criteria.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/Criteria.java @@ -27,10 +27,8 @@ import java.util.List; /** - * * @author Peter Milne * @author Jean Mercier - * */ public class Criteria implements CriteriaDefinition { @@ -266,5 +264,4 @@ public Criteria geo_within(Object lng, Object lat, Object radius, String propert this.criteria.put(Qualifier.FilterOperation.GEO_WITHIN.name(), qualifier); return this; } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/CriteriaDefinition.java b/src/main/java/org/springframework/data/aerospike/repository/query/CriteriaDefinition.java index 91f41929d..9dc17d359 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/CriteriaDefinition.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/CriteriaDefinition.java @@ -19,10 +19,8 @@ import org.springframework.data.aerospike.query.Qualifier; /** - * * @author Peter Milne * @author Jean Mercier - * */ public interface CriteriaDefinition { @@ -38,7 +36,7 @@ public interface CriteriaDefinition { */ String getKey(); - public enum AerospikeMapCriteria{ + enum AerospikeMapCriteria{ KEY, VALUE } diff --git a/src/main/java/org/springframework/data/aerospike/repository/query/Query.java b/src/main/java/org/springframework/data/aerospike/repository/query/Query.java index eb7e0d9a2..750855609 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/query/Query.java +++ b/src/main/java/org/springframework/data/aerospike/repository/query/Query.java @@ -20,10 +20,8 @@ import org.springframework.data.keyvalue.core.query.KeyValueQuery; /** - * * @author Peter Milne * @author Jean Mercier - * */ public class Query { @@ -158,7 +156,7 @@ public Query with(Sort sort) { if (order.isIgnoreCase()) { throw new IllegalArgumentException(String.format( "Given sort contained an Order for %s with ignore case! " - + "Aerospike does not support sorting ignoreing case currently!", + + "Aerospike does not support sorting ignoring case currently!", order.getProperty())); } } @@ -171,5 +169,4 @@ public Query with(Sort sort) { return this; } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactory.java b/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactory.java index aca1a962d..4ca83f0b8 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactory.java +++ b/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactory.java @@ -15,11 +15,6 @@ */ package org.springframework.data.aerospike.repository.support; -import static org.springframework.data.querydsl.QuerydslUtils.QUERY_DSL_PRESENT; - -import java.lang.reflect.Method; -import java.util.Optional; - import org.springframework.data.aerospike.core.AerospikeOperations; import org.springframework.data.aerospike.mapping.AerospikePersistentEntity; import org.springframework.data.aerospike.mapping.AerospikePersistentProperty; @@ -29,7 +24,6 @@ import org.springframework.data.keyvalue.repository.support.QuerydslKeyValueRepository; import org.springframework.data.keyvalue.repository.support.SimpleKeyValueRepository; import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.mapping.MappingException; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.repository.core.EntityInformation; @@ -38,13 +32,19 @@ import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.PersistentEntityInformation; import org.springframework.data.repository.core.support.RepositoryFactorySupport; -import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; import org.springframework.data.repository.query.QueryLookupStrategy; import org.springframework.data.repository.query.QueryLookupStrategy.Key; import org.springframework.data.repository.query.QueryMethod; +import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; import org.springframework.data.repository.query.RepositoryQuery; import org.springframework.data.repository.query.parser.AbstractQueryCreator; import org.springframework.util.Assert; +import reactor.util.annotation.Nullable; + +import java.lang.reflect.Method; +import java.util.Optional; + +import static org.springframework.data.querydsl.QuerydslUtils.QUERY_DSL_PRESENT; /** * @author Peter Milne @@ -55,31 +55,21 @@ public class AerospikeRepositoryFactory extends RepositoryFactorySupport { private static final Class DEFAULT_QUERY_CREATOR = AerospikeQueryCreator.class; private final AerospikeOperations aerospikeOperations; - //private final MappingContext context; private final MappingContext, AerospikePersistentProperty> context; private final Class> queryCreator; - /** - * - */ public AerospikeRepositoryFactory(AerospikeOperations aerospikeOperations) { this(aerospikeOperations, DEFAULT_QUERY_CREATOR); } - /** - * @param aerospikeOperations - * @param queryCreator - */ @SuppressWarnings("unchecked") public AerospikeRepositoryFactory(AerospikeOperations aerospikeOperations, Class> queryCreator) { Assert.notNull(aerospikeOperations, "AerospikeOperations must not be null!"); Assert.notNull(queryCreator, "Query creator type must not be null!"); - this.queryCreator = queryCreator; this.aerospikeOperations = aerospikeOperations; this.context = (MappingContext, AerospikePersistentProperty>) aerospikeOperations.getMappingContext(); - } /* (non-Javadoc) @@ -89,7 +79,7 @@ public AerospikeRepositoryFactory(AerospikeOperations aerospikeOperations, @Override public EntityInformation getEntityInformation(Class domainClass) { AerospikePersistentEntity entity = context.getRequiredPersistentEntity(domainClass); - return new PersistentEntityInformation((AerospikePersistentEntity) entity); + return new PersistentEntityInformation<>((AerospikePersistentEntity) entity); } /* (non-Javadoc) @@ -114,7 +104,7 @@ protected Class getRepositoryBaseClass(RepositoryMetadata metadata) { * Returns whether the given repository interface requires a QueryDsl specific implementation to be chosen. * * @param repositoryInterface must not be {@literal null}. - * @return + * @return An indication if the given repository requires a QueryDsl implementation. */ private static boolean isQueryDslRepository(Class repositoryInterface) { return QUERY_DSL_PRESENT && QuerydslPredicateExecutor.class.isAssignableFrom(repositoryInterface); @@ -135,10 +125,9 @@ protected Optional getQueryLookupStrategy(Key key, QueryMet */ private static class AerospikeQueryLookupStrategy implements QueryLookupStrategy { - private QueryMethodEvaluationContextProvider evaluationContextProvider; - private AerospikeOperations aerospikeOperations; - - private Class> queryCreator; + private final QueryMethodEvaluationContextProvider evaluationContextProvider; + private final AerospikeOperations aerospikeOperations; + private final Class> queryCreator; /** * Creates a new {@link AerospikeQueryLookupStrategy} for the given {@link Key}, {@link QueryMethodEvaluationContextProvider}, @@ -146,18 +135,16 @@ private static class AerospikeQueryLookupStrategy implements QueryLookupStrategy *

* TODO: Key is not considered. Should it? * - * @param key + * @param key Currently unused, same behaviour in the built in spring's KeyValueQueryLookupStrategy implementation. * @param evaluationContextProvider must not be {@literal null}. - * @param aerospikeOperations must not be {@literal null}. - * @param queryCreator must not be {@literal null}. + * @param aerospikeOperations must not be {@literal null}. + * @param queryCreator must not be {@literal null}. */ - public AerospikeQueryLookupStrategy(Key key, QueryMethodEvaluationContextProvider evaluationContextProvider, + public AerospikeQueryLookupStrategy(@Nullable Key key, QueryMethodEvaluationContextProvider evaluationContextProvider, AerospikeOperations aerospikeOperations, Class> queryCreator) { - Assert.notNull(evaluationContextProvider, "QueryMethodEvaluationContextProvider must not be null!"); Assert.notNull(aerospikeOperations, "AerospikeOperations must not be null!"); Assert.notNull(queryCreator, "Query creator type must not be null!"); - this.evaluationContextProvider = evaluationContextProvider; this.aerospikeOperations = aerospikeOperations; this.queryCreator = queryCreator; @@ -168,11 +155,10 @@ public AerospikeQueryLookupStrategy(Key key, QueryMethodEvaluationContextProvide * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.repository.core.NamedQueries) */ @Override - public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory pfactory, - NamedQueries nquery) { - QueryMethod queryMethod = new QueryMethod(method, metadata, pfactory); + public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory projectionFactory, + NamedQueries namedQueries) { + QueryMethod queryMethod = new QueryMethod(method, metadata, projectionFactory); return new AerospikePartTreeQuery(queryMethod, evaluationContextProvider, this.aerospikeOperations, this.queryCreator); } } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryBean.java b/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryBean.java index 489f1e416..03411fe42 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryBean.java @@ -20,11 +20,8 @@ import org.springframework.data.repository.core.support.RepositoryFactorySupport; /** - * - * * @author Peter Milne * @author Jean Mercier - * */ public class AerospikeRepositoryFactoryBean, S, ID> extends BaseAerospikeRepositoryFactoryBean { @@ -50,5 +47,4 @@ protected RepositoryFactorySupport createRepositoryFactory() { public void setKeyValueOperations(AerospikeOperations operations) { this.operations = operations; } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/support/BaseAerospikeRepositoryFactoryBean.java b/src/main/java/org/springframework/data/aerospike/repository/support/BaseAerospikeRepositoryFactoryBean.java index 155ce5425..dc109a68b 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/support/BaseAerospikeRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/aerospike/repository/support/BaseAerospikeRepositoryFactoryBean.java @@ -51,5 +51,4 @@ public void setQueryCreator(Class> queryCre public void afterPropertiesSet() { super.afterPropertiesSet(); } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactory.java b/src/main/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactory.java index 4f7618052..005068d7b 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactory.java +++ b/src/main/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactory.java @@ -39,6 +39,7 @@ import org.springframework.data.repository.query.RepositoryQuery; import org.springframework.data.repository.query.parser.AbstractQueryCreator; import org.springframework.util.Assert; +import reactor.util.annotation.Nullable; import java.lang.reflect.Method; import java.util.Optional; @@ -56,27 +57,18 @@ public class ReactiveAerospikeRepositoryFactory extends ReactiveRepositoryFactor private final MappingContext, AerospikePersistentProperty> context; private final Class> queryCreator; - /** - * - */ public ReactiveAerospikeRepositoryFactory(ReactiveAerospikeOperations aerospikeOperations) { this(aerospikeOperations, DEFAULT_QUERY_CREATOR); } - /** - * @param aerospikeOperations - * @param queryCreator - */ @SuppressWarnings("unchecked") public ReactiveAerospikeRepositoryFactory(ReactiveAerospikeOperations aerospikeOperations, Class> queryCreator) { Assert.notNull(aerospikeOperations, "AerospikeOperations must not be null!"); Assert.notNull(queryCreator, "Query creator type must not be null!"); - this.queryCreator = queryCreator; this.aerospikeOperations = aerospikeOperations; this.context = (MappingContext, AerospikePersistentProperty>) aerospikeOperations.getMappingContext(); - } /* (non-Javadoc) @@ -86,7 +78,7 @@ public ReactiveAerospikeRepositoryFactory(ReactiveAerospikeOperations aerospikeO @Override public EntityInformation getEntityInformation(Class domainClass) { AerospikePersistentEntity entity = context.getRequiredPersistentEntity(domainClass); - return new PersistentEntityInformation((AerospikePersistentEntity) entity); + return new PersistentEntityInformation<>((AerospikePersistentEntity) entity); } /* (non-Javadoc) @@ -111,7 +103,7 @@ protected Class getRepositoryBaseClass(RepositoryMetadata metadata) { * Returns whether the given repository interface requires a QueryDsl specific implementation to be chosen. * * @param repositoryInterface must not be {@literal null}. - * @return + * @return An indication if the given repository requires a QueryDsl implementation. */ private static boolean isQueryDslRepository(Class repositoryInterface) { return QUERY_DSL_PRESENT && QuerydslPredicateExecutor.class.isAssignableFrom(repositoryInterface); @@ -132,28 +124,25 @@ protected Optional getQueryLookupStrategy(Key key, QueryMet */ private static class ReactiveAerospikeQueryLookupStrategy implements QueryLookupStrategy { - private QueryMethodEvaluationContextProvider evaluationContextProvider; - private ReactiveAerospikeOperations aerospikeOperations; - - private Class> queryCreator; + private final QueryMethodEvaluationContextProvider evaluationContextProvider; + private final ReactiveAerospikeOperations aerospikeOperations; + private final Class> queryCreator; /** * Creates a new {@link ReactiveAerospikeQueryLookupStrategy} for the given {@link Key}, {@link QueryMethodEvaluationContextProvider}, * {@link KeyValueOperations} and query creator type. *

* - * @param key + * @param key Currently unused, same behaviour in the built in spring's KeyValueQueryLookupStrategy implementation. * @param evaluationContextProvider must not be {@literal null}. * @param aerospikeOperations must not be {@literal null}. * @param queryCreator must not be {@literal null}. */ - public ReactiveAerospikeQueryLookupStrategy(Key key, QueryMethodEvaluationContextProvider evaluationContextProvider, + public ReactiveAerospikeQueryLookupStrategy(@Nullable Key key, QueryMethodEvaluationContextProvider evaluationContextProvider, ReactiveAerospikeOperations aerospikeOperations, Class> queryCreator) { - Assert.notNull(evaluationContextProvider, "QueryMethodEvaluationContextProvider must not be null!"); Assert.notNull(aerospikeOperations, "AerospikeOperations must not be null!"); Assert.notNull(queryCreator, "Query creator type must not be null!"); - this.evaluationContextProvider = evaluationContextProvider; this.aerospikeOperations = aerospikeOperations; this.queryCreator = queryCreator; @@ -164,11 +153,10 @@ public ReactiveAerospikeQueryLookupStrategy(Key key, QueryMethodEvaluationContex * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.repository.core.NamedQueries) */ @Override - public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory pfactory, - NamedQueries nquery) { - QueryMethod queryMethod = new QueryMethod(method, metadata, pfactory); + public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory projectionFactory, + NamedQueries namedQueries) { + QueryMethod queryMethod = new QueryMethod(method, metadata, projectionFactory); return new ReactiveAerospikePartTreeQuery(queryMethod, evaluationContextProvider, this.aerospikeOperations, this.queryCreator); } } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepository.java b/src/main/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepository.java index 22f1bb4da..41043df13 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepository.java +++ b/src/main/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepository.java @@ -35,7 +35,6 @@ public class SimpleAerospikeRepository implements AerospikeRepository entityInformation; - public SimpleAerospikeRepository(EntityInformation metadata, AerospikeOperations operations) { @@ -79,10 +78,9 @@ public Iterable findAll(Sort sort) { @Override public Page findAll(Pageable pageable) { - if (pageable == null) { List result = findAll(); - return new PageImpl(result, null, result.size()); + return new PageImpl<>(result, null, result.size()); } Class type = entityInformation.getJavaType(); @@ -91,7 +89,7 @@ public Page findAll(Pageable pageable) { Stream content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(), type); long totalCount = operations.count(setName); - return new PageImpl(content.collect(Collectors.toList()), pageable, totalCount); + return new PageImpl<>(content.collect(Collectors.toList()), pageable, totalCount); } @Override @@ -133,12 +131,12 @@ public void deleteAll() { } @Override - public void createIndex(Class domainType, String indexName, String binName, IndexType indexType) { + public void createIndex(Class domainType, String indexName, String binName, IndexType indexType) { operations.createIndex(domainType, indexName, binName, indexType); } @Override - public void deleteIndex(Class domainType, String indexName) { + public void deleteIndex(Class domainType, String indexName) { operations.deleteIndex(domainType, indexName); } @@ -146,5 +144,4 @@ public void deleteIndex(Class domainType, String indexName) { public boolean indexExists(String indexName) { return operations.indexExists(indexName); } - } diff --git a/src/main/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepository.java b/src/main/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepository.java index 172571bcc..3c67b8104 100644 --- a/src/main/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepository.java +++ b/src/main/java/org/springframework/data/aerospike/repository/support/SimpleReactiveAerospikeRepository.java @@ -144,5 +144,4 @@ public void createIndex(Class domainType, String indexName, String binName, I public void deleteIndex(Class domainType, String indexName) { operations.deleteIndex(domainType, indexName); } - } From 225f0c7688037c6a068dadda0e25b0f31c44c48c Mon Sep 17 00:00:00 2001 From: roimenashe Date: Wed, 10 Mar 2021 15:37:58 +0200 Subject: [PATCH 2/2] Repository tests package cleanup. --- .../CustomerRepositoriesIntegrationTests.java | 14 ++++---- .../IndexedPersonRepositoryQueryTests.java | 11 +----- .../PersonRepositoryQueryTests.java | 36 ++++++++----------- .../aerospike/repository/PersonTestData.java | 1 - .../query/AerospikeQueryCreatorUnitTests.java | 15 ++------ .../query/StubParameterAccessor.java | 15 +++----- ...AerospikeRepositoryDeleteRelatedTests.java | 6 ++-- ...eAerospikeRepositoryExistRelatedTests.java | 4 --- ...veAerospikeRepositoryFindRelatedTests.java | 4 +-- ...veAerospikeRepositorySaveRelatedTests.java | 5 --- .../AerospikeRepositoryFactoryTest.java | 11 ++---- ...eactiveAerospikeRepositoryFactoryTest.java | 8 ++--- .../SimpleAerospikeRepositoryTest.java | 2 +- 13 files changed, 38 insertions(+), 94 deletions(-) diff --git a/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java b/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java index 66a17af74..4d97a54d7 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/CustomerRepositoriesIntegrationTests.java @@ -1,21 +1,20 @@ -/******************************************************************************* - * Copyright (c) 2018 the original author or authors. +/* + * Copyright 2012-2019 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - *******************************************************************************/ + */ package org.springframework.data.aerospike.repository; - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.aerospike.BaseBlockingIntegrationTests; @@ -27,7 +26,6 @@ import static org.assertj.core.api.Assertions.assertThat; - /** * @author Oliver Gierke */ diff --git a/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java b/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java index d1c23c59f..51113d027 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/IndexedPersonRepositoryQueryTests.java @@ -25,15 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.alicia; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.boyd; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.carter; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.dave; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.donny; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.leroi; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.leroi2; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.oliver; -import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.stefan; +import static org.springframework.data.aerospike.repository.PersonTestData.Indexed.*; @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class IndexedPersonRepositoryQueryTests extends BaseBlockingIntegrationTests { @@ -240,5 +232,4 @@ public void findsPersonInAgeRangeAndNameCorrectly() { Iterable result = repository.findByAgeBetweenAndLastName(20, 26, "Moore"); assertThat(result).hasSize(1); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java b/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java index bfe044e7e..aa4f4e519 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/PersonRepositoryQueryTests.java @@ -24,16 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.springframework.data.aerospike.repository.PersonTestData.alicia; -import static org.springframework.data.aerospike.repository.PersonTestData.all; -import static org.springframework.data.aerospike.repository.PersonTestData.boyd; -import static org.springframework.data.aerospike.repository.PersonTestData.carter; -import static org.springframework.data.aerospike.repository.PersonTestData.dave; -import static org.springframework.data.aerospike.repository.PersonTestData.donny; -import static org.springframework.data.aerospike.repository.PersonTestData.leroi; -import static org.springframework.data.aerospike.repository.PersonTestData.leroi2; -import static org.springframework.data.aerospike.repository.PersonTestData.oliver; -import static org.springframework.data.aerospike.repository.PersonTestData.stefan; +import static org.springframework.data.aerospike.repository.PersonTestData.*; @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class PersonRepositoryQueryTests extends BaseBlockingIntegrationTests { @@ -166,7 +157,7 @@ public void findsByLastnameNot_forExistingResult() { @Test public void findByFirstnameNotIn_forEmptyResult() { - Set allFirstNames = all.stream().map(p -> p.getFirstName()).collect(Collectors.toSet()); + Set allFirstNames = all.stream().map(Person::getFirstName).collect(Collectors.toSet()); // Stream result = repository.findByFirstnameNotIn(allFirstNames); assertThatThrownBy(() -> repository.findByFirstNameNotIn(allFirstNames)) .isInstanceOf(IllegalArgumentException.class) @@ -340,14 +331,17 @@ public void findsPersonInAgeRangeAndNameCorrectly() { assertThat(result).hasSize(1); } -// @Ignore("Searching by association not Supported Yet!" )@Test -// public void findsPersonByShippingAddressesCorrectly() { -// -// Address address = new Address("Foo Street 1", "C0123", "Bar"); -// dave.setShippingAddresses(new HashSet

(asList(address))); -// -// repository.save(dave); -// Person person = repository.findByShippingAddresses(address); -// assertThat(repository.findByShippingAddresses(address), is(dave)); -// } + /* + @Ignore("Searching by association not Supported Yet!" ) + @Test + public void findsPersonByShippingAddressesCorrectly() { + + Address address = new Address("Foo Street 1", "C0123", "Bar"); + dave.setShippingAddresses(new HashSet
(asList(address))); + + repository.save(dave); + Person person = repository.findByShippingAddresses(address); + assertThat(repository.findByShippingAddresses(address), is(dave)); + } + */ } diff --git a/src/test/java/org/springframework/data/aerospike/repository/PersonTestData.java b/src/test/java/org/springframework/data/aerospike/repository/PersonTestData.java index fb5c61187..187a2c8d4 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/PersonTestData.java +++ b/src/test/java/org/springframework/data/aerospike/repository/PersonTestData.java @@ -40,5 +40,4 @@ public static class Indexed { public static List all = Arrays.asList(oliver, dave, donny, carter, boyd, stefan, leroi, leroi2, alicia); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java b/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java index ef47fd365..7b213e5ba 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/query/AerospikeQueryCreatorUnitTests.java @@ -1,25 +1,17 @@ -/** - * - */ package org.springframework.data.aerospike.repository.query; - -import java.lang.reflect.Method; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.data.aerospike.convert.AerospikeConverter; -import org.springframework.data.aerospike.sample.Person; import org.springframework.data.aerospike.mapping.AerospikeMappingContext; import org.springframework.data.aerospike.mapping.AerospikePersistentProperty; -import org.springframework.data.aerospike.repository.query.AerospikeQueryCreator; -import org.springframework.data.aerospike.repository.query.Query; -import org.springframework.data.aerospike.repository.query.StubParameterAccessor; +import org.springframework.data.aerospike.sample.Person; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.repository.query.parser.PartTree; +import java.lang.reflect.Method; /** * @author Peter Milne @@ -50,8 +42,7 @@ public void createsQueryCorrectly() { public void createQueryByInList(){ PartTree tree = new PartTree("findByFirstNameOrFriend", Person.class); - AerospikeQueryCreator creator = new AerospikeQueryCreator(tree, new StubParameterAccessor(converter, (Object[])new String[]{"Oliver", "Peter"}), context); + AerospikeQueryCreator creator = new AerospikeQueryCreator(tree, new StubParameterAccessor(converter, new String[]{"Oliver", "Peter"}), context); Query query = creator.createQuery(); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/query/StubParameterAccessor.java b/src/test/java/org/springframework/data/aerospike/repository/query/StubParameterAccessor.java index f8173ff30..34690564f 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/query/StubParameterAccessor.java +++ b/src/test/java/org/springframework/data/aerospike/repository/query/StubParameterAccessor.java @@ -15,27 +15,21 @@ */ package org.springframework.data.aerospike.repository.query; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; + import java.util.Arrays; import java.util.Iterator; import java.util.Optional; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Range; -import org.springframework.data.domain.Sort; -import org.springframework.data.geo.Distance; - /** - * - * * @author Peter Milne * @author Jean Mercier - * */ public class StubParameterAccessor implements AerospikeParameterAccessor { private final Object[] values; - - @SuppressWarnings("unchecked") + public StubParameterAccessor(Object... values) { this.values = values; } @@ -96,5 +90,4 @@ public Optional> getDynamicProjection() { public Class findDynamicProjection() { return null; } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java index bc69eede9..fa9d3aeeb 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryDeleteRelatedTests.java @@ -36,7 +36,6 @@ public void setUp() { StepVerifier.create(customerRepo.findById(customer2.getId())).expectNext(customer2).verifyComplete(); } - @Test public void deleteById_ShouldDeleteExistent() { StepVerifier.create(customerRepo.deleteById(customer2.getId()).subscribeOn(Schedulers.parallel())).verifyComplete(); @@ -50,6 +49,7 @@ public void deleteById_ShouldSkipNonexistent() { } @Test + @SuppressWarnings("ConstantConditions") public void deleteById_ShouldRejectsNullObject() { assertThatThrownBy(() -> customerRepo.deleteById((String) null).block()) .isInstanceOf(IllegalArgumentException.class); @@ -73,6 +73,7 @@ public void deleteByIdPublisher_ShouldSkipNonexistent() { } @Test + @SuppressWarnings("ConstantConditions") public void deleteByIdPublisher_ShouldRejectsNullObject() { assertThatThrownBy(() -> customerRepo.deleteById((Publisher) null).block()) .isInstanceOf(IllegalArgumentException.class); @@ -94,6 +95,7 @@ public void delete_ShouldSkipNonexistent() { } @Test + @SuppressWarnings("ConstantConditions") public void delete_ShouldRejectsNullObject() { assertThatThrownBy(() -> customerRepo.delete(null).block()) .isInstanceOf(IllegalArgumentException.class); @@ -126,7 +128,6 @@ public void deleteAllIterable_ShouldRejectsNullObject() { .isInstanceOf(IllegalArgumentException.class); } - @Test public void deleteAllPublisher_ShouldDeleteExistent() { customerRepo.deleteAll(Flux.just(customer1, customer2)).subscribeOn(Schedulers.parallel()).block(); @@ -144,5 +145,4 @@ public void deleteAllPublisher_ShouldSkipNonexistent() { StepVerifier.create(customerRepo.findById(customer1.getId())).expectNextCount(0).verifyComplete(); StepVerifier.create(customerRepo.findById(customer2.getId())).expectNextCount(0).verifyComplete(); } - } \ No newline at end of file diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java index 39319ca2b..04f08a42f 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryExistRelatedTests.java @@ -1,6 +1,5 @@ package org.springframework.data.aerospike.repository.reactive; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -11,7 +10,6 @@ import reactor.core.scheduler.Schedulers; import reactor.test.StepVerifier; - /** * @author Igor Ermolenko */ @@ -29,7 +27,6 @@ public void setUp() { StepVerifier.create(customerRepo.saveAll(Flux.just(customer1, customer2))).expectNextCount(2).verifyComplete(); } - @Test public void existsById_ShouldReturnTrueWhenExists() { StepVerifier.create(customerRepo.existsById(customer2.getId()).subscribeOn(Schedulers.parallel())) @@ -60,5 +57,4 @@ public void existsByIdPublisher_ShouldCheckOnlyFirstElement() { .subscribeOn(Schedulers.parallel())) .expectNext(true).verifyComplete(); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java index bef5dcdbd..cd6d1c101 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositoryFindRelatedTests.java @@ -1,6 +1,5 @@ package org.springframework.data.aerospike.repository.reactive; - import com.aerospike.client.query.IndexType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -23,17 +22,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.data.domain.Sort.Order.asc; - /** * @author Igor Ermolenko */ public class ReactiveAerospikeRepositoryFindRelatedTests extends BaseReactiveIntegrationTests { + @Autowired ReactiveCustomerRepository customerRepo; private Customer customer1, customer2, customer3, customer4; - @BeforeEach public void setUp() { StepVerifier.create(deleteAll()).verifyComplete(); diff --git a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java index ddabb57c6..95607a610 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/reactive/ReactiveAerospikeRepositorySaveRelatedTests.java @@ -1,6 +1,5 @@ package org.springframework.data.aerospike.repository.reactive; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -19,7 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat; - /** * @author Igor Ermolenko */ @@ -39,7 +37,6 @@ public void setUp() { customer3 = Customer.builder().id(nextId()).firstname("Bart").lastname("Simpson").age(15).build(); } - @Test public void saveEntityShouldInsertNewEntity() { StepVerifier.create(customerRepo.save(customer1).subscribeOn(Schedulers.parallel())).expectNext(customer1).verifyComplete(); @@ -132,12 +129,10 @@ public void shouldSaveObjectWithPersistenceConstructorThatHasAllFields() { }).verifyComplete(); } - private void assertCustomerExistsInRepo(Customer customer) { StepVerifier.create(customerRepo.findById(customer.getId())).consumeNextWith(actual -> { assertThat(actual.getFirstname()).isEqualTo(customer.getFirstname()); assertThat(actual.getLastname()).isEqualTo(customer.getLastname()); }).verifyComplete(); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java index 110455e1b..5d78018aa 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/AerospikeRepositoryFactoryTest.java @@ -40,11 +40,8 @@ import static org.mockito.Mockito.when; /** - * - * * @author Peter Milne * @author Jean Mercier - * */ @MockitoSettings(strictness = Strictness.LENIENT) @ExtendWith(MockitoExtension.class) @@ -74,13 +71,10 @@ public void getEntityInformationClassOfT() { assertThat(entityInformation).isInstanceOf(PersistentEntityInformation.class); } - @SuppressWarnings("unchecked") @Test public void getTargetRepositoryRepositoryInformation() { when(aerospikeRepositoryFactoryMock.getTargetRepository(repositoryInformation)).thenReturn(new Object()); - Person.class.getDeclaredConstructors(); - Object repository = aerospikeRepositoryFactoryMock.getTargetRepository(repositoryInformation); assertThat(repository).isNotNull(); } @@ -90,8 +84,7 @@ public void testGetRepositoryBaseClassRepositoryMetadata() { RepositoryMetadata metadata = mock(RepositoryMetadata.class); Mockito.>when(metadata.getRepositoryInterface()).thenReturn(SimpleKeyValueRepository.class); AerospikeRepositoryFactory factory = new AerospikeRepositoryFactory(aerospikeOperations); - Class repbaseClass = factory.getRepositoryBaseClass(metadata); - assertThat(repbaseClass.getSimpleName()).isEqualTo(SimpleKeyValueRepository.class.getSimpleName()); + Class repositoryBaseClass = factory.getRepositoryBaseClass(metadata); + assertThat(repositoryBaseClass.getSimpleName()).isEqualTo(SimpleKeyValueRepository.class.getSimpleName()); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java index 1b9a992c0..7fb4ebd95 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/ReactiveAerospikeRepositoryFactoryTest.java @@ -74,13 +74,10 @@ public void getEntityInformationClassOfT() { assertThat(entityInformation).isInstanceOf(PersistentEntityInformation.class); } - @SuppressWarnings("unchecked") @Test public void getTargetRepositoryRepositoryInformation() { when(aerospikeRepositoryFactoryMock.getTargetRepository(repositoryInformation)).thenReturn(new Object()); - Person.class.getDeclaredConstructors(); - Object repository = aerospikeRepositoryFactoryMock.getTargetRepository(repositoryInformation); assertThat(repository).isNotNull(); } @@ -91,9 +88,8 @@ public void getRepositoryBaseClassRepositoryMetadata() { Mockito.>when(metadata.getRepositoryInterface()).thenReturn(SimpleKeyValueRepository.class); ReactiveAerospikeRepositoryFactory factory = new ReactiveAerospikeRepositoryFactory(aerospikeOperations); - Class repbaseClass = factory.getRepositoryBaseClass(metadata); + Class repositoryBaseClass = factory.getRepositoryBaseClass(metadata); - assertThat(repbaseClass.getSimpleName()).isEqualTo(SimpleKeyValueRepository.class.getSimpleName()); + assertThat(repositoryBaseClass.getSimpleName()).isEqualTo(SimpleKeyValueRepository.class.getSimpleName()); } - } diff --git a/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java b/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java index 187ce46e1..9f98283d8 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java +++ b/src/test/java/org/springframework/data/aerospike/repository/support/SimpleAerospikeRepositoryTest.java @@ -165,7 +165,7 @@ public void deleteID() { } @Test - public void deleteIterableOfQextendsT() { + public void deleteIterableOfQExtendsT() { aerospikeRepository.deleteAll(testPersons); verify(operations, times(testPersons.size())).delete(any(Person.class));