DATACMNS-402 - Add support for sorting by a QueryDSL OrderSpecifier.
Previously we did only support ordering by a string or property path through Sort. In order to be able to express more type safe ordering expressions we introduce QSort as a subclass of Sort that is able to wrap QueryDSL OrderSpecifiers. To be able to separate the concerns of sorting via QueryDSL expressions better we introduce the AbstractPageRequest base class and QPageRequest as a special implementation that accepts a QSort or OrderSpecifiers for ordering. Original pull request: #59.
This commit is contained in:
committed by
Oliver Gierke
parent
9f65b57867
commit
f2ff84fb63
@@ -25,6 +25,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.data.domain.AbstractPageRequest;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -48,9 +49,9 @@ public abstract class PageableDefaultUnitTests {
|
||||
static final int PAGE_SIZE = 47;
|
||||
static final int PAGE_NUMBER = 23;
|
||||
|
||||
static final PageRequest REFERENCE_WITHOUT_SORT = new PageRequest(PAGE_NUMBER, PAGE_SIZE);
|
||||
static final PageRequest REFERENCE_WITH_SORT = new PageRequest(PAGE_NUMBER, PAGE_SIZE, SORT);
|
||||
static final PageRequest REFERENCE_WITH_SORT_FIELDS = new PageRequest(PAGE_NUMBER, PAGE_SIZE, new Sort(SORT_FIELDS));
|
||||
static final AbstractPageRequest REFERENCE_WITHOUT_SORT = new PageRequest(PAGE_NUMBER, PAGE_SIZE);
|
||||
static final AbstractPageRequest REFERENCE_WITH_SORT = new PageRequest(PAGE_NUMBER, PAGE_SIZE, SORT);
|
||||
static final AbstractPageRequest REFERENCE_WITH_SORT_FIELDS = new PageRequest(PAGE_NUMBER, PAGE_SIZE, new Sort(SORT_FIELDS));
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.AbstractPageRequest;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -110,7 +111,7 @@ public class PagedResourcesAssemblerUnitTests {
|
||||
resolver.setOneIndexedParameters(true);
|
||||
PagedResourcesAssembler<Person> assembler = new PagedResourcesAssembler<Person>(resolver, null);
|
||||
|
||||
PageRequest request = new PageRequest(0, 1);
|
||||
AbstractPageRequest request = new PageRequest(0, 1);
|
||||
Page<Person> page = new PageImpl<Person>(Collections.<Person> emptyList(), request, 0);
|
||||
|
||||
assembler.toResource(page);
|
||||
@@ -118,7 +119,7 @@ public class PagedResourcesAssemblerUnitTests {
|
||||
|
||||
private static Page<Person> createPage(int index) {
|
||||
|
||||
PageRequest request = new PageRequest(index, 1);
|
||||
AbstractPageRequest request = new PageRequest(index, 1);
|
||||
return new PageImpl<Person>(Arrays.asList(new Person()), request, 3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user