Search in sources :

Example 91 with Pagination

use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.

the class GraphPageTest method shouldPaginate.

@Test
public void shouldPaginate() {
    Pagination pagination = Pagination.page(1).size(1);
    Page<Person> page = template.getTraversalVertex().orderBy("name").desc().page(pagination);
    assertNotNull(page);
    List<Person> people = page.<Person>getContent().collect(Collectors.toList());
    Person first = template.getTraversalVertex().orderBy("name").desc().<Person>getResult().findFirst().get();
    assertEquals(pagination, page.getPagination());
    assertEquals(1, people.size());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) Person(org.eclipse.jnosql.mapping.graph.model.Person) Test(org.junit.jupiter.api.Test)

Example 92 with Pagination

use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.

the class GraphPageTest method shouldStream.

@Test
public void shouldStream() {
    Pagination pagination = Pagination.page(1).size(1);
    Page<Person> page = template.getTraversalVertex().orderBy("name").desc().page(pagination);
    assertNotNull(page);
    Stream<Person> people = page.get();
    assertEquals(pagination, page.getPagination());
    assertEquals(poliana.getName(), people.map(Person::getName).collect(joining()));
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) Person(org.eclipse.jnosql.mapping.graph.model.Person) Test(org.junit.jupiter.api.Test)

Example 93 with Pagination

use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.

the class DefaultColumnQueryPaginationTest method shouldCreateColumnQueryPagination.

@Test
public void shouldCreateColumnQueryPagination() {
    ColumnQuery query = select().from("column").build();
    Pagination pagination = Pagination.page(1).size(2);
    ColumnQueryPagination queryPagination = ColumnQueryPagination.of(query, pagination);
    assertNotNull(queryPagination);
    isQueryEquals(query, pagination, queryPagination);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Pagination(jakarta.nosql.mapping.Pagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) Test(org.junit.jupiter.api.Test)

Example 94 with Pagination

use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.

the class ColumnPageTest 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) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 95 with Pagination

use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.

the class ColumnPageTest 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) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ArrayList(java.util.ArrayList) Person(jakarta.nosql.tck.entities.Person) 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