diff --git a/.travis.yml b/.travis.yml
index 0deb630a..a69d9b15 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,16 @@
language: java
jdk:
- - oraclejdk8
- oraclejdk7
+ - oraclejdk8
+script:
+ - cd spring-data-mock
+ - mvn test -B
after_success:
+ - cd spring-data-mock-parent
- mvn -P coverage clean cobertura:cobertura coveralls:report
- '[[ $TRAVIS_BRANCH == "master" && ( "x${TRAVIS_PULL_REQUEST}" == "xfalse" || "x${TRAVIS_PULL_REQUEST}" == "x" ) && ( "x$(echo $JAVA_HOME | grep -o 8)" == "x8" ) ]] && sudo apt-get install gnupg2'
- - '[[ $TRAVIS_BRANCH == "master" && ( "x${TRAVIS_PULL_REQUEST}" == "xfalse" || "x${TRAVIS_PULL_REQUEST}" == "x" ) && ( "x$(echo $JAVA_HOME | grep -o 8)" == "x8" ) ]] && bash deploy.sh eb1a6f34f056 key.asc.enc settings.xml'
+ - '[[ $TRAVIS_BRANCH == "master" && ( "x${TRAVIS_PULL_REQUEST}" == "xfalse" || "x${TRAVIS_PULL_REQUEST}" == "x" ) && ( "x$(echo $JAVA_HOME | grep -o 8)" == "x8" ) ]] && bash ../deployment/deploy.sh eb1a6f34f056 ../deployment/key.asc.enc ../deployment/settings.xml'
+# SUDO should be set to `false` except when deploying to OSSRH to trigger container infrastructure
sudo: true
env:
global:
diff --git a/deploy.sh b/deployment/deploy.sh
similarity index 100%
rename from deploy.sh
rename to deployment/deploy.sh
diff --git a/key.asc.enc b/deployment/key.asc.enc
similarity index 100%
rename from key.asc.enc
rename to deployment/key.asc.enc
diff --git a/settings.xml b/deployment/settings.xml
similarity index 100%
rename from settings.xml
rename to deployment/settings.xml
diff --git a/spring-data-mock-build/pom.xml b/spring-data-mock-build/pom.xml
new file mode 100644
index 00000000..0e4a0b34
--- /dev/null
+++ b/spring-data-mock-build/pom.xml
@@ -0,0 +1,84 @@
+
+
+
+
+ 4.0.0
+
+ com.mmnaseri.utils
+ spring-data-mock-build
+ 1.0.2
+ Spring Data Mock: Build Aggregator
+ This is the build module that will aggregate all reactors for the spring-data-mock project
+ https://mmnaseri.github.io/spring-data-mock
+ pom
+
+
+
+ MIT
+ http://mit-license.org
+
+
+
+
+
+ Milad Naseri
+ mmnaseri@programmer.net
+ http://www.mmnaseri.com
+
+ designer
+ developer
+
+
+
+
+
+ scm:git:git@github.com:mmnaseri/spring-data-mock.git
+ scm:git:git@github.com:mmnaseri/spring-data-mock.git
+ git@github.com:mmnaseri/spring-data-mock.git
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ ${target-jdk.version}
+
+
+
+
+
+
+ ../spring-data-mock/
+
+
+
+ UTF-8
+ 3.5.1
+ 1.7
+
+
+
diff --git a/pom.xml b/spring-data-mock/pom.xml
similarity index 99%
rename from pom.xml
rename to spring-data-mock/pom.xml
index e5d21f33..b96dd0a5 100644
--- a/pom.xml
+++ b/spring-data-mock/pom.xml
@@ -26,7 +26,7 @@
com.mmnaseri.utils
spring-data-mock
- 1.0.2
+ 1.0.3
Spring Data Mock
A framework for mocking Spring Data repositories
https://mmnaseri.github.io/spring-data-mock
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/DataStoreAware.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/DataStoreAware.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/DataStoreAware.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/DataStoreAware.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/IdPropertyResolver.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/IdPropertyResolver.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/IdPropertyResolver.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/IdPropertyResolver.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/Invocation.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Invocation.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/Invocation.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Invocation.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/InvocationMatcher.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/InvocationMatcher.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/InvocationMatcher.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/InvocationMatcher.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGenerator.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGenerator.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGenerator.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGenerator.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGeneratorAware.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGeneratorAware.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGeneratorAware.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/KeyGeneratorAware.java
diff --git a/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/MatchedOperator.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/MatchedOperator.java
new file mode 100644
index 00000000..115d3c48
--- /dev/null
+++ b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/MatchedOperator.java
@@ -0,0 +1,16 @@
+package com.mmnaseri.utils.spring.data.domain;
+
+/**
+ * Represents an operator that was picked because of a parse operation
+ *
+ * @author Mohammad Milad Naseri (m.m.naseri@gmail.com)
+ * @since 1.0 (4/17/16, 12:36 PM)
+ */
+public interface MatchedOperator extends Operator {
+
+ /**
+ * @return the suffix that was matched when looking up this operator
+ */
+ String getMatchedToken();
+
+}
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/Matcher.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Matcher.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/Matcher.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Matcher.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/Modifier.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Modifier.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/Modifier.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Modifier.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/Operator.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Operator.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/Operator.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Operator.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/OperatorContext.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/OperatorContext.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/OperatorContext.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/OperatorContext.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/Parameter.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Parameter.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/Parameter.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/Parameter.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryAware.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryAware.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryAware.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryAware.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadata.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadata.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadata.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadata.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataAware.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataAware.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataAware.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataAware.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataResolver.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataResolver.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataResolver.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/RepositoryMetadataResolver.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRandomKeyGenerator.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRandomKeyGenerator.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRandomKeyGenerator.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRandomKeyGenerator.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRepositoryMetadataResolver.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRepositoryMetadataResolver.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRepositoryMetadataResolver.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AbstractRepositoryMetadataResolver.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AnnotationRepositoryMetadataResolver.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AnnotationRepositoryMetadataResolver.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AnnotationRepositoryMetadataResolver.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AnnotationRepositoryMetadataResolver.java
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AssignableRepositoryMetadataResolver.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AssignableRepositoryMetadataResolver.java
similarity index 100%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AssignableRepositoryMetadataResolver.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/AssignableRepositoryMetadataResolver.java
diff --git a/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultOperatorContext.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultOperatorContext.java
new file mode 100644
index 00000000..56918ca0
--- /dev/null
+++ b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultOperatorContext.java
@@ -0,0 +1,87 @@
+package com.mmnaseri.utils.spring.data.domain.impl;
+
+import com.mmnaseri.utils.spring.data.domain.Operator;
+import com.mmnaseri.utils.spring.data.domain.OperatorContext;
+import com.mmnaseri.utils.spring.data.domain.impl.matchers.*;
+import com.mmnaseri.utils.spring.data.error.DuplicateOperatorException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+/**
+ * This class is used to store the operators used in the name of a query method. Operators are matched by
+ * the "suffixes" eagerly (meaning that "EqualTo" will precede over "To").
+ *
+ * @author Milad Naseri (mmnaseri@programmer.net)
+ * @since 1.0 (9/29/15)
+ */
+public class DefaultOperatorContext implements OperatorContext {
+
+ private static final Log log = LogFactory.getLog(DefaultOperatorContext.class);
+ private final Set operators;
+
+ public DefaultOperatorContext() {
+ this(true);
+ }
+
+ public DefaultOperatorContext(boolean registerDefaults) {
+ operators = new CopyOnWriteArraySet<>();
+ if (registerDefaults) {
+ log.info("Registering all the default operators");
+ operators.add(new ImmutableOperator("AFTER", 1, new IsGreaterThanMatcher(), "After", "IsAfter"));
+ operators.add(new ImmutableOperator("BEFORE", 1, new IsLessThanMatcher(), "Before", "IsBefore"));
+ operators.add(new ImmutableOperator("CONTAINING", 1, new ContainingMatcher(), "Containing", "IsContaining", "Contains"));
+ operators.add(new ImmutableOperator("BETWEEN", 2, new IsBetweenMatcher(), "Between", "IsBetween"));
+ operators.add(new ImmutableOperator("NOT_BETWEEN", 2, new IsNotBetweenMatcher(), "NotBetween", "IsNotBetween"));
+ operators.add(new ImmutableOperator("ENDING_WITH", 1, new EndingWithMatcher(), "EndingWith", "IsEndingWith", "EndsWith"));
+ operators.add(new ImmutableOperator("FALSE", 0, new IsFalseMatcher(), "False", "IsFalse"));
+ operators.add(new ImmutableOperator("GREATER_THAN", 1, new IsGreaterThanMatcher(), "GreaterThan", "IsGreaterThan"));
+ operators.add(new ImmutableOperator("GREATER_THAN_EQUALS", 1, new IsGreaterThanOrEqualToMatcher(), "GreaterThanEqual", "IsGreaterThanEqual"));
+ operators.add(new ImmutableOperator("IN", 1, new IsInMatcher(), "In", "IsIn"));
+ operators.add(new ImmutableOperator("IS", 1, new IsEqualToMatcher(), "Is", "EqualTo", "IsEqualTo", "Equals"));
+ operators.add(new ImmutableOperator("NOT_NULL", 0, new IsNotNullMatcher(), "NotNull", "IsNotNull"));
+ operators.add(new ImmutableOperator("NULL", 0, new IsNullMatcher(), "Null", "IsNull"));
+ operators.add(new ImmutableOperator("LESS_THAN", 1, new IsLessThanMatcher(), "LessThan", "IsLessThan"));
+ operators.add(new ImmutableOperator("LESS_THAN_EQUAL", 1, new IsLessThanOrEqualToMatcher(), "LessThanEqual", "IsLessThanEqual"));
+ operators.add(new ImmutableOperator("LIKE", 1, new IsLikeMatcher(), "Like", "IsLike"));
+ operators.add(new ImmutableOperator("NEAR", 1, null, "Near", "IsNear"));
+ operators.add(new ImmutableOperator("NOT", 1, new IsNotMatcher(), "IsNot", "Not", "IsNotEqualTo", "DoesNotEqual"));
+ operators.add(new ImmutableOperator("NOT_IN", 1, new IsNotInMatcher(), "NotIn", "IsNotIn"));
+ operators.add(new ImmutableOperator("NOT_LIKE", 1, new IsNotLikeMatcher(), "NotLike", "IsNotLike"));
+ operators.add(new ImmutableOperator("REGEX", 1, new RegexMatcher(), "Regex", "MatchesRegex", "Matches"));
+ operators.add(new ImmutableOperator("STARTING_WITH", 1, new StartingWithMatcher(), "StartingWith", "IsStartingWith", "StartsWith"));
+ operators.add(new ImmutableOperator("TRUE", 0, new IsTrueMatcher(), "True", "IsTrue"));
+ }
+ }
+
+ @Override
+ public void register(Operator operator) {
+ log.info("Registering operator " + operator.getName() + " which will respond to suffixes " + Arrays.toString(operator.getTokens()));
+ for (Operator item : operators) {
+ for (String token : item.getTokens()) {
+ for (String newToken : operator.getTokens()) {
+ if (newToken.equals(token)) {
+ throw new DuplicateOperatorException(item, token);
+ }
+ }
+ }
+ }
+ operators.add(operator);
+ }
+
+ @Override
+ public Operator getBySuffix(String suffix) {
+ for (Operator operator : operators) {
+ for (String token : operator.getTokens()) {
+ if (token.equals(suffix)) {
+ return operator;
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultRepositoryMetadataResolver.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultRepositoryMetadataResolver.java
similarity index 74%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultRepositoryMetadataResolver.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultRepositoryMetadataResolver.java
index d6117ba2..213f6132 100644
--- a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultRepositoryMetadataResolver.java
+++ b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DefaultRepositoryMetadataResolver.java
@@ -1,6 +1,8 @@
package com.mmnaseri.utils.spring.data.domain.impl;
import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.data.repository.RepositoryDefinition;
/**
@@ -18,14 +20,17 @@
*/
public class DefaultRepositoryMetadataResolver extends AbstractRepositoryMetadataResolver {
+ private static final Log log = LogFactory.getLog(DefaultRepositoryMetadataResolver.class);
private final AssignableRepositoryMetadataResolver assignableRepositoryMetadataResolver = new AssignableRepositoryMetadataResolver();
private final AnnotationRepositoryMetadataResolver annotationRepositoryMetadataResolver = new AnnotationRepositoryMetadataResolver();
@Override
protected RepositoryMetadata resolveFromInterface(Class> repositoryInterface) {
if (repositoryInterface.isAnnotationPresent(RepositoryDefinition.class)) {
+ log.info("Since the repository interface was annotated with @RepositoryDefinition we will try to resolve the metadata using the provided annotation");
return annotationRepositoryMetadataResolver.resolve(repositoryInterface);
}
+ log.info("Since no annotation was found on the repository, we will try to read the metadata from the generic type parameters derived from the Repository interface");
return assignableRepositoryMetadataResolver.resolve(repositoryInterface);
}
diff --git a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DescribedDataStoreOperation.java b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DescribedDataStoreOperation.java
similarity index 82%
rename from src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DescribedDataStoreOperation.java
rename to spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DescribedDataStoreOperation.java
index f91c3a11..70232ff6 100644
--- a/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DescribedDataStoreOperation.java
+++ b/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/domain/impl/DescribedDataStoreOperation.java
@@ -7,6 +7,8 @@
import com.mmnaseri.utils.spring.data.query.QueryDescriptor;
import com.mmnaseri.utils.spring.data.store.DataStore;
import com.mmnaseri.utils.spring.data.store.DataStoreOperation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.io.Serializable;
import java.util.List;
@@ -19,7 +21,8 @@
* @since 1.0 (9/29/15)
*/
public class DescribedDataStoreOperation implements DataStoreOperation