use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldExecuteQueryPagination.
@Test
public void shouldExecuteQueryPagination() {
Pagination pagination = Pagination.page(2).size(2);
DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
mapperBuilder.selectFrom(Person.class).getResult(template, pagination);
Mockito.verify(template).select(queryCaptor.capture());
DocumentQuery query = queryCaptor.getValue();
assertEquals(pagination.getLimit(), query.getLimit());
assertEquals(pagination.getSkip(), query.getSkip());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldExecuteSingleQueryPagination.
@Test
public void shouldExecuteSingleQueryPagination() {
Pagination pagination = Pagination.page(2).size(2);
DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
ArgumentCaptor<DocumentQuery> queryCaptor = ArgumentCaptor.forClass(DocumentQuery.class);
mapperBuilder.selectFrom(Person.class).getSingleResult(template, pagination);
Mockito.verify(template).singleResult(queryCaptor.capture());
DocumentQuery query = queryCaptor.getValue();
assertEquals(pagination.getLimit(), query.getLimit());
assertEquals(pagination.getSkip(), query.getSkip());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentRepositoryProxySortTest method shouldFindAll.
@Test
public void shouldFindAll() {
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(Person.builder().build()));
Pagination pagination = getPagination();
personRepository.findAll(pagination, Sorts.sorts().asc("name"));
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).select(captor.capture());
DocumentQuery query = captor.getValue();
assertEquals("Person", query.getDocumentCollection());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
assertThat(query.getSorts(), Matchers.contains(Sort.asc("name")));
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DefaultDocumentQueryPaginationTest method shouldOverrideSkipLimit.
@Test
public void shouldOverrideSkipLimit() {
DocumentQuery query = select().from("column").build();
Pagination pagination = Pagination.page(1).size(2);
DocumentQueryPagination queryPagination = DocumentQueryPagination.of(query, pagination);
assertNotNull(queryPagination);
assertEquals(pagination.getLimit(), queryPagination.getLimit());
assertEquals(pagination.getSkip(), queryPagination.getSkip());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DefaultDocumentQueryPaginationTest method shouldNext.
@Test
public void shouldNext() {
DocumentQuery query = select().from("column").where("name").eq("Ada").build();
Pagination pagination = Pagination.page(1).size(2);
Pagination secondPage = pagination.next();
DocumentQueryPagination queryPagination = DocumentQueryPagination.of(query, pagination);
assertNotNull(queryPagination);
assertEquals(pagination.getLimit(), queryPagination.getLimit());
assertEquals(pagination.getSkip(), queryPagination.getSkip());
isQueryEquals(query, pagination, queryPagination);
DocumentQueryPagination next = queryPagination.next();
isQueryEquals(query, secondPage, next);
}
Aggregations