remove Pageable from parameter as is included in DocumentQuery (#178)
* remove Pageable from parameter as is included in DocumentQuery * refine test with shorter with buidler
This commit is contained in:
Родитель
256ec01f7d
Коммит
35c60ff866
|
@ -49,7 +49,7 @@ public interface DocumentDbOperations {
|
|||
|
||||
<T> Page<T> findAll(Pageable pageable, Class<T> domainClass, String collectionName);
|
||||
|
||||
<T> Page<T> paginationQuery(DocumentQuery query, Pageable pageable, Class<T> domainClass, String collectionName);
|
||||
<T> Page<T> paginationQuery(DocumentQuery query, Class<T> domainClass, String collectionName);
|
||||
|
||||
long count(String collectionName);
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ public class DocumentDbTemplate implements DocumentDbOperations, ApplicationCont
|
|||
private <T> boolean isCrossPartitionQuery(@NonNull DocumentQuery query, @NonNull Class<T> domainClass) {
|
||||
final Optional<String> partitionKeyName = getPartitionKeyField(domainClass);
|
||||
|
||||
if (!partitionKeyName.isPresent() || query == null) {
|
||||
if (!partitionKeyName.isPresent()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -503,16 +503,16 @@ public class DocumentDbTemplate implements DocumentDbOperations, ApplicationCont
|
|||
|
||||
@Override
|
||||
public <T> Page<T> findAll(Pageable pageable, Class<T> domainClass, String collectionName) {
|
||||
final DocumentQuery query = new DocumentQuery(Criteria.getInstance(CriteriaType.ALL));
|
||||
return paginationQuery(query, pageable, domainClass, collectionName);
|
||||
final DocumentQuery query = new DocumentQuery(Criteria.getInstance(CriteriaType.ALL)).with(pageable);
|
||||
return paginationQuery(query, domainClass, collectionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Page<T> paginationQuery(DocumentQuery query, Pageable pageable, Class<T> domainClass,
|
||||
String collectionName) {
|
||||
Assert.isTrue(pageable.getPageSize() > 0, "pageable should have page size larger than 0");
|
||||
public <T> Page<T> paginationQuery(DocumentQuery query, Class<T> domainClass, String collectionName) {
|
||||
Assert.isTrue(query.getPageable().getPageSize() > 0, "pageable should have page size larger than 0");
|
||||
Assert.hasText(collectionName, "collection should not be null, empty or only whitespaces");
|
||||
|
||||
final Pageable pageable = query.getPageable();
|
||||
final FeedOptions feedOptions = new FeedOptions();
|
||||
if (pageable instanceof DocumentDbPageRequest) {
|
||||
feedOptions.setRequestContinuation(((DocumentDbPageRequest) pageable).getRequestContinuation());
|
||||
|
|
|
@ -54,7 +54,9 @@ public class DocumentDbPageRequest extends PageRequest {
|
|||
|
||||
final DocumentDbPageRequest that = (DocumentDbPageRequest) obj;
|
||||
|
||||
return super.equals(that) && (requestContinuation != null ?
|
||||
requestContinuation.equals(that.requestContinuation) : that.requestContinuation == null);
|
||||
final boolean continuationTokenEquals = requestContinuation != null ?
|
||||
requestContinuation.equals(that.requestContinuation) : that.requestContinuation == null;
|
||||
|
||||
return continuationTokenEquals && super.equals(that);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,9 @@ public interface DocumentDbQueryExecution {
|
|||
"DocumentDbPageRequest, requestContinuation is required for non first page request");
|
||||
}
|
||||
|
||||
return operations.paginationQuery(query, pageable, type, collection);
|
||||
query.with(pageable);
|
||||
|
||||
return operations.paginationQuery(query, type, collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,10 +216,10 @@ public class DocumentDbTemplateIT {
|
|||
|
||||
final Criteria criteria = Criteria.getUnaryInstance(CriteriaType.IS_EQUAL, "firstName",
|
||||
Arrays.asList(TestConstants.FIRST_NAME));
|
||||
final DocumentQuery query = new DocumentQuery(criteria);
|
||||
final PageRequest pageRequest = new DocumentDbPageRequest(0, PAGE_SIZE_2, null);
|
||||
final DocumentQuery query = new DocumentQuery(criteria).with(pageRequest);
|
||||
|
||||
final Page<Person> page = dbTemplate.paginationQuery(query, pageRequest, Person.class, collectionName);
|
||||
final Page<Person> page = dbTemplate.paginationQuery(query, Person.class, collectionName);
|
||||
assertThat(page.getContent().size()).isEqualTo(1);
|
||||
validateLastPage(page, PAGE_SIZE_2);
|
||||
}
|
||||
|
|
|
@ -222,10 +222,10 @@ public class DocumentDbTemplatePartitionIT {
|
|||
|
||||
final Criteria criteria = Criteria.getUnaryInstance(CriteriaType.IS_EQUAL, "firstName",
|
||||
Arrays.asList(TestConstants.FIRST_NAME));
|
||||
final DocumentQuery query = new DocumentQuery(criteria);
|
||||
final PageRequest pageRequest = new DocumentDbPageRequest(0, PAGE_SIZE_2, null);
|
||||
final DocumentQuery query = new DocumentQuery(criteria).with(pageRequest);
|
||||
|
||||
final Page<Person> page = dbTemplate.paginationQuery(query, pageRequest, Person.class, collectionName);
|
||||
final Page<Person> page = dbTemplate.paginationQuery(query, Person.class, collectionName);
|
||||
assertThat(page.getContent().size()).isEqualTo(1);
|
||||
validateLastPage(page, PAGE_SIZE_2);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче