DATACMNS-1383 - Parameters now properly detects Pageable and Sort extensions.

One of the constructors of Pageable wasn't properly checking for assignability of Pageable parameters to detect them but was expecting Pageable itself being used under all circumstances. This has now been opened up by an assignability check.
This commit is contained in:
Oliver Gierke
2018-08-30 15:40:41 +02:00
parent fc633f623d
commit 1d4a53dc28
2 changed files with 27 additions and 3 deletions

View File

@@ -18,13 +18,14 @@ package org.springframework.data.repository.query;
import static org.assertj.core.api.Assertions.*;
import rx.Single;
import scala.collection.mutable.Publisher;
import java.lang.reflect.Method;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.test.util.ReflectionTestUtils;
@@ -180,6 +181,14 @@ public class ParametersUnitTests {
assertThat(parameters.getParameter(0).getType()).isAssignableFrom(Single.class);
}
@Test // DATACMNS-1383
public void acceptsCustomPageableParameter() throws Exception {
Parameters<?, Parameter> parameters = getParametersFor("customPageable", SomePageable.class);
assertThat(parameters.hasPageableParameter()).isTrue();
}
private Parameters<?, Parameter> getParametersFor(String methodName, Class<?>... parameterTypes)
throws SecurityException, NoSuchMethodException {
@@ -217,5 +226,9 @@ public class ParametersUnitTests {
void methodWithPublisher(Publisher<String> publisher);
void methodWithSingle(Single<String> single);
Page<Object> customPageable(SomePageable pageable);
}
interface SomePageable extends Pageable {}
}