DATACMNS-854 - Polishing.

Simplified conditional expressions in DefaultRepositoryInformation. Reordered test method to reflect natural order of adding.

Original pull request: #162.
This commit is contained in:
Oliver Gierke
2016-05-18 12:53:53 +02:00
parent e0fc7deb05
commit 3a36ed55dd
2 changed files with 34 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2016 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.
@@ -94,22 +94,6 @@ public class DefaultRepositoryInformationUnitTests {
assertThat(information.getTargetClassMethod(source), is(expected));
}
/**
* @see DATACMNS-854
*/
@Test
public void discoversCustomlyImplementedCrudMethodWithGenerics() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class,
customImplementation.getClass());
Method source = FooRepositoryCustom.class.getMethod("exists", Object.class);
Method expected = customImplementation.getClass().getMethod("exists", Object.class);
assertThat(information.getTargetClassMethod(source), is(expected));
}
@Test
public void considersIntermediateMethodsAsFinderMethods() {
@@ -239,12 +223,30 @@ public class DefaultRepositoryInformationUnitTests {
}
}
private Method getMethodFrom(Class<?> type, String name) {
/**
* @see DATACMNS-854
*/
@Test
public void discoversCustomlyImplementedCrudMethodWithGenerics() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class,
customImplementation.getClass());
Method source = FooRepositoryCustom.class.getMethod("exists", Object.class);
Method expected = customImplementation.getClass().getMethod("exists", Object.class);
assertThat(information.getTargetClassMethod(source), is(expected));
}
private static Method getMethodFrom(Class<?> type, String name) {
for (Method method : type.getMethods()) {
if (method.getName().equals(name)) {
return method;
}
}
return null;
}
@@ -252,7 +254,6 @@ public class DefaultRepositoryInformationUnitTests {
@Retention(RetentionPolicy.RUNTIME)
@QueryAnnotation
@interface MyQuery {
}
interface FooRepository extends CrudRepository<User, Integer>, FooRepositoryCustom {