DATACMNS-193 - Introduced isQueryMethod(…) on RepositoryInformation.

This commit is contained in:
Oliver Gierke
2012-07-16 10:02:44 +02:00
parent 4a51ce2b84
commit 4d326faa25
4 changed files with 41 additions and 6 deletions

View File

@@ -142,6 +142,21 @@ public class DefaultRepositoryInformationUnitTests {
assertThat(queryMethods, not(hasItem(intermediateMethod)));
}
/**
* @see DATACMNS-193
*/
@Test
public void detectsQueryMethodCorrectly() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, null);
Method queryMethod = getMethodFrom(ConcreteRepository.class, "findBySomethingDifferent");
assertThat(information.getQueryMethods(), hasItem(queryMethod));
assertThat(information.isQueryMethod(queryMethod), is(true));
}
private Method getMethodFrom(Class<?> type, String name) {
for (Method method : type.getMethods()) {
if (method.getName().equals(name)) {

View File

@@ -18,6 +18,7 @@ package org.springframework.data.repository.support;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Set;
import org.springframework.data.repository.core.RepositoryInformation;
import org.springframework.data.repository.core.RepositoryMetadata;
@@ -59,11 +60,15 @@ public final class DummyRepositoryInformation implements RepositoryInformation {
return false;
}
public Iterable<Method> getQueryMethods() {
public boolean isQueryMethod(Method method) {
return false;
}
public Set<Method> getQueryMethods() {
return Collections.emptySet();
}
public Method getTargetClassMethod(Method method) {
return method;
}
}
}