DATACMNS-193 - Introduced isQueryMethod(…) on RepositoryInformation.
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user