Search in sources :

Example 46 with Pagination

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));
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 47 with Pagination

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());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 48 with Pagination

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());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) ArrayList(java.util.ArrayList) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 49 with Pagination

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());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 50 with Pagination

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);
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Test(org.junit.jupiter.api.Test)

Aggregations

Pagination (jakarta.nosql.mapping.Pagination)99 Test (org.junit.jupiter.api.Test)96 Person (jakarta.nosql.tck.entities.Person)46 ColumnQuery (jakarta.nosql.column.ColumnQuery)27 DocumentQuery (jakarta.nosql.document.DocumentQuery)27 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)17 DocumentQueryPagination (jakarta.nosql.mapping.document.DocumentQueryPagination)17 Method (java.lang.reflect.Method)15 Optional (java.util.Optional)15 Stream (java.util.stream.Stream)15 ColumnCondition (jakarta.nosql.column.ColumnCondition)13 DocumentCondition (jakarta.nosql.document.DocumentCondition)13 List (java.util.List)7 Person (org.eclipse.jnosql.mapping.graph.model.Person)7 Vendor (jakarta.nosql.tck.entities.Vendor)4 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)3 DocumentTemplate (jakarta.nosql.mapping.document.DocumentTemplate)3 Value (jakarta.nosql.Value)2 ArrayList (java.util.ArrayList)2 Collections.singletonList (java.util.Collections.singletonList)2