Search in sources :

Example 1 with DocumentQueryPagination

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

Example 2 with DocumentQueryPagination

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

Example 3 with DocumentQueryPagination

use of jakarta.nosql.mapping.document.DocumentQueryPagination 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 4 with DocumentQueryPagination

use of jakarta.nosql.mapping.document.DocumentQueryPagination 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)

Example 5 with DocumentQueryPagination

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

the class DocumentPageTest method shouldExecutePagination.

@Test
public void shouldExecutePagination() {
    Pagination pagination = Pagination.page(1).size(1);
    DocumentQueryPagination query = DocumentQueryPagination.of(select().from("person").build(), pagination);
    Page<Person> page = subject.select(query);
    verify(managerMock).select(query);
    assertNotNull(page);
    assertEquals(pagination, page.getPagination());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) DocumentQueryPagination(jakarta.nosql.mapping.document.DocumentQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Aggregations

Pagination (jakarta.nosql.mapping.Pagination)8 DocumentQueryPagination (jakarta.nosql.mapping.document.DocumentQueryPagination)8 Test (org.junit.jupiter.api.Test)7 DocumentQuery (jakarta.nosql.document.DocumentQuery)5 Person (jakarta.nosql.tck.entities.Person)3 Document (jakarta.nosql.document.Document)1 DocumentCollectionManager (jakarta.nosql.document.DocumentCollectionManager)1 DocumentEntity (jakarta.nosql.document.DocumentEntity)1 DocumentEventPersistManager (jakarta.nosql.mapping.document.DocumentEventPersistManager)1 DocumentTemplate (jakarta.nosql.mapping.document.DocumentTemplate)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1