use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentPageTest method shouldExecutePaginationAsQuery.
@Test
public void shouldExecutePaginationAsQuery() {
Pagination pagination = Pagination.page(1).size(1);
DocumentQueryPagination queryPagination = DocumentQueryPagination.of(select().from("person").build(), pagination);
DocumentQuery query = queryPagination;
List<Person> people = subject.<Person>select(query).collect(Collectors.toList());
assertEquals(0L, people.stream().map(Person::getId).findFirst().orElse(-0L));
queryPagination = queryPagination.next();
query = queryPagination;
people = subject.<Person>select(query).collect(Collectors.toList());
assertEquals(1L, people.stream().map(Person::getId).findFirst().orElse(-0L));
queryPagination = queryPagination.next();
query = queryPagination;
people = subject.<Person>select(query).collect(Collectors.toList());
assertEquals(2L, people.stream().map(Person::getId).findFirst().orElse(-0L));
queryPagination = queryPagination.next();
query = queryPagination;
people = subject.<Person>select(query).collect(Collectors.toList());
assertEquals(3L, people.stream().map(Person::getId).findFirst().orElse(-0L));
queryPagination = queryPagination.next();
query = queryPagination;
people = subject.<Person>select(query).collect(Collectors.toList());
assertEquals(4L, people.stream().map(Person::getId).findFirst().orElse(-0L));
queryPagination = queryPagination.next();
query = queryPagination;
people = subject.<Person>select(query).collect(Collectors.toList());
assertEquals(5L, people.stream().map(Person::getId).findFirst().orElse(-0L));
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentPageTest method shouldGetContent.
@Test
public void shouldGetContent() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = createPage(pagination);
List<Person> people = page.getContent().collect(Collectors.toList());
assertEquals(1, people.size());
assertEquals(0L, people.get(0).getId());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentPageTest method shouldCreateCollectionFromCollectionFactory.
@Test
public void shouldCreateCollectionFromCollectionFactory() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = createPage(pagination);
ArrayList<Person> people = page.getContent(ArrayList::new);
assertEquals(1, people.size());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentPageTest method shouldGetAsStream.
@Test
public void shouldGetAsStream() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = createPage(pagination);
Stream<Person> stream = page.get();
assertNotNull(stream);
assertEquals(1L, stream.count());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentPageTest method shouldExecuteQueryPagination.
@Test
public void shouldExecuteQueryPagination() {
Pagination pagination = Pagination.page(1).size(2);
DocumentQueryPagination query = DocumentQueryPagination.of(select().from("person").build(), pagination);
subject.select(query);
verify(managerMock).select(query);
}
Aggregations