Skip to content

Commit

Permalink
Merge pull request #75 from mmnaseri/release-v1.1.1#74
Browse files Browse the repository at this point in the history
Release v1.1.1#74
  • Loading branch information
mmnaseri authored Jun 11, 2016
2 parents 4d85d71 + 28d0367 commit cad27b2
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 58 deletions.
2 changes: 1 addition & 1 deletion spring-data-mock-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<groupId>com.mmnaseri.utils</groupId>
<artifactId>spring-data-mock-build</artifactId>
<version>1.1</version>
<version>1.1.1</version>
<name>Spring Data Mock: Build Aggregator</name>
<description>This is the build module that will aggregate all reactors for the spring-data-mock project</description>
<url>https://mmnaseri.github.io/spring-data-mock</url>
Expand Down
97 changes: 48 additions & 49 deletions spring-data-mock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<groupId>com.mmnaseri.utils</groupId>
<artifactId>spring-data-mock</artifactId>
<version>1.1</version>
<version>1.1.1</version>
<name>Spring Data Mock</name>
<description>A framework for mocking Spring Data repositories</description>
<url>https://mmnaseri.github.io/spring-data-mock</url>
Expand Down Expand Up @@ -80,85 +80,80 @@
</build>

<dependencies>
<!-- dependencies that are required for the runtime functionality of this framework-->
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
<!-- logging the workings of the framework -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
</dependency>
<dependency>
<!-- Required for supporting QueryDSL mocks -->
<groupId>com.querydsl</groupId>
<artifactId>querydsl-collections</artifactId>
<version>${querydsl.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<!-- Required by QueryDSL collections -->
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>${cglib.version}</version>
<scope>provided</scope>
</dependency>
<!-- dependencies that are required for testing the framework -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>${persistence-api.version}</version>
<scope>test</scope>
</dependency>
<!-- dependencies for adding support for various features of the spring data ecosystem -->
<dependency>
<!-- Spring Data Commons -->
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${spring-data-commons.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-gemfire</artifactId>
<version>${spring-data-gemfire.version}</version>
<!-- needed for adding support for Spring Data audit functionality -->
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- Spring Data support for JPA-->
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data-jpa.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
<!-- Support for QueryDSL supported repositories -->
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>${persistence-api.version}</version>
<!-- Support for Spring Data GemFire -->
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-gemfire</artifactId>
<version>${spring-data-gemfire.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -298,23 +293,27 @@
</profiles>

<properties>
<!-- build integrity -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<target-jdk.version>1.7</target-jdk.version>
<!-- requirements -->
<commons-logging.version>1.2</commons-logging.version>
<spring-data-commons.version>1.12.1.RELEASE</spring-data-commons.version>
<spring-data-gemfire.version>1.8.1.RELEASE</spring-data-gemfire.version>
<spring-data-jpa.version>1.10.1.RELEASE</spring-data-jpa.version>
<jackson-databind.version>2.7.4</jackson-databind.version>
<joda-time.version>2.9.4</joda-time.version>
<!-- test -->
<testng.version>6.9.10</testng.version>
<hamcrest.version>1.3</hamcrest.version>
<joda-time.version>2.9.4</joda-time.version>
<!-- deployment -->
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.0.0</maven-source-plugin.version>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version>
<cobertura-maven-plugin.version>2.7</cobertura-maven-plugin.version>
<!-- feature support -->
<spring-data-commons.version>1.12.1.RELEASE</spring-data-commons.version>
<spring-data-gemfire.version>1.8.1.RELEASE</spring-data-gemfire.version>
<spring-data-jpa.version>1.10.1.RELEASE</spring-data-jpa.version>
<querydsl.version>4.1.0</querydsl.version>
<cglib.version>3.2.2</cglib.version>
<persistence-api.version>1.0.2</persistence-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
import java.util.List;

/**
* Utilities for figuring out the specifics of the ID property
*
* @author Mohammad Milad Naseri ([email protected])
* @since 1.0 (6/8/16, 1:43 AM)
*/
final class IdPropertyResolverUtils {
@SuppressWarnings("WeakerAccess")
public final class IdPropertyResolverUtils {

private static final List<String> ID_ANNOTATIONS = new ArrayList<>();
private static final Log log = LogFactory.getLog(IdPropertyResolverUtils.class);
Expand All @@ -39,7 +42,7 @@ private IdPropertyResolverUtils() {
* @param idAnnotatedMethod the method that will return the ID (e.g. getter for the ID property)
* @return the name of the property, or {@literal null} if the method is {@literal null}
*/
static String getPropertyNameFromAnnotatedMethod(Class<?> entityType, Class<? extends Serializable> idType, Method idAnnotatedMethod) {
public static String getPropertyNameFromAnnotatedMethod(Class<?> entityType, Class<? extends Serializable> idType, Method idAnnotatedMethod) {
if (idAnnotatedMethod != null) {
final String name = PropertyUtils.getPropertyName(idAnnotatedMethod);
if (!idType.isAssignableFrom(idAnnotatedMethod.getReturnType())) {
Expand All @@ -57,7 +60,7 @@ static String getPropertyNameFromAnnotatedMethod(Class<?> entityType, Class<? ex
* @param element the element to be examined
* @return {@literal true} if the element has any of the ID annotations
*/
static boolean isAnnotated(AnnotatedElement element) {
public static boolean isAnnotated(AnnotatedElement element) {
final List<Class<? extends Annotation>> annotations = getIdAnnotations();
for (Class<? extends Annotation> annotation : annotations) {
if (AnnotationUtils.findAnnotation(element, annotation) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
public class DefaultTypeMappingContext implements TypeMappingContext {

private static final Log log = LogFactory.getLog(DefaultTypeMappingContext.class);
private static final String GEMFIRE_SUPPORT_CLASS = "org.springframework.data.gemfire.repository.GemfireRepository";
private static final String JPA_SUPPORT_CLASS = "org.springframework.data.jpa.repository.JpaRepository";
private static final String QUERYDSL_SUPPORT_CLASS = "org.springframework.data.querydsl.QueryDslPredicateExecutor";
private static final String QUERY_BY_EXAMPLE_SUPPORT_CLASS = "org.springframework.data.repository.query.QueryByExampleExecutor";
private static final String CGLIB_SUPPORT_CLASS = "net.sf.cglib.proxy.Callback";
private final TypeMappingContext parent;
private ConcurrentMap<Class<?>, List<Class<?>>> mappings = new ConcurrentHashMap<>();

Expand All @@ -45,20 +50,19 @@ public DefaultTypeMappingContext(boolean registerDefaults) {
this(null);
if (registerDefaults) {
log.info("Trying to register all the default type mappings");
final ClassLoader defaultClassLoader = ClassUtils.getDefaultClassLoader();
if (ClassUtils.isPresent("org.springframework.data.gemfire.repository.GemfireRepository", defaultClassLoader)) {
if (isClassPresent(GEMFIRE_SUPPORT_CLASS)) {
log.debug("We seem to have Gemfire in the classpath, so, we should register the supporting registry");
register(Object.class, DefaultGemfireRepository.class);
}
if (ClassUtils.isPresent("org.springframework.data.jpa.repository.JpaRepository", defaultClassLoader)) {
if (isClassPresent(JPA_SUPPORT_CLASS)) {
log.debug("JPA support is enabled in this project, so we need to support the methods");
register(Object.class, DefaultJpaRepository.class);
}
if (ClassUtils.isPresent("org.springframework.data.querydsl.QueryDslPredicateExecutor", defaultClassLoader)) {
if (isClassPresent(QUERYDSL_SUPPORT_CLASS) && isClassPresent(CGLIB_SUPPORT_CLASS)) {
log.debug("QueryDSL support is enabled. We will add the proper method implementations.");
register(Object.class, DefaultQueryDslPredicateExecutor.class);
}
if (ClassUtils.isPresent("org.springframework.data.repository.query.QueryByExampleExecutor", defaultClassLoader)) {
if (isClassPresent(QUERY_BY_EXAMPLE_SUPPORT_CLASS)) {
log.debug("Query by example is enabled. We will the proper method implementations.");
register(Object.class, DefaultQueryByExampleExecutor.class);
}
Expand All @@ -67,6 +71,10 @@ public DefaultTypeMappingContext(boolean registerDefaults) {
}
}

private boolean isClassPresent(String className) {
return ClassUtils.isPresent(className, ClassUtils.getDefaultClassLoader());
}

public DefaultTypeMappingContext(TypeMappingContext parent) {
this.parent = parent;
}
Expand Down

0 comments on commit cad27b2

Please sign in to comment.