Search in sources :

Example 1 with ColumnQueryPagination

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

the class DefaultColumnMapperSelectBuilderTest method shouldCreatePage.

@Test
public void shouldCreatePage() {
    Pagination pagination = Pagination.page(2).size(2);
    ColumnTemplate template = Mockito.mock(ColumnTemplate.class);
    ArgumentCaptor<ColumnQueryPagination> queryCaptor = ArgumentCaptor.forClass(ColumnQueryPagination.class);
    Page<Person> page = mapperBuilder.selectFrom(Person.class).page(template, pagination);
    Mockito.verify(template).select(queryCaptor.capture());
    ColumnQuery query = queryCaptor.getValue();
    assertEquals(pagination.getLimit(), query.getLimit());
    assertEquals(pagination.getSkip(), query.getSkip());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnTemplate(jakarta.nosql.mapping.column.ColumnTemplate) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 2 with ColumnQueryPagination

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

the class DefaultColumnQueryPaginationTest method shouldNext.

@Test
public void shouldNext() {
    ColumnQuery query = select().from("column").where("name").eq("Ada").build();
    Pagination pagination = Pagination.page(1).size(2);
    Pagination secondPage = pagination.next();
    ColumnQueryPagination queryPagination = ColumnQueryPagination.of(query, pagination);
    assertNotNull(queryPagination);
    assertEquals(pagination.getLimit(), queryPagination.getLimit());
    assertEquals(pagination.getSkip(), queryPagination.getSkip());
    isQueryEquals(query, pagination, queryPagination);
    ColumnQueryPagination next = queryPagination.next();
    isQueryEquals(query, secondPage, next);
}
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 3 with ColumnQueryPagination

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

the class DefaultColumnQueryPaginationTest method shouldOverrideSkipLimit.

@Test
public void shouldOverrideSkipLimit() {
    ColumnQuery query = select().from("column").build();
    Pagination pagination = Pagination.page(1).size(2);
    ColumnQueryPagination queryPagination = ColumnQueryPagination.of(query, pagination);
    assertNotNull(queryPagination);
    assertEquals(pagination.getLimit(), queryPagination.getLimit());
    assertEquals(pagination.getSkip(), queryPagination.getSkip());
}
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 4 with ColumnQueryPagination

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

the class ColumnPageTest method shouldExecutePaginationAsQuery.

@Test
public void shouldExecutePaginationAsQuery() {
    Pagination pagination = Pagination.page(1).size(1);
    ColumnQueryPagination queryPagination = ColumnQueryPagination.of(select().from("person").build(), pagination);
    ColumnQuery 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) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQuery(jakarta.nosql.column.ColumnQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 5 with ColumnQueryPagination

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

the class ColumnPageTest method shouldExecutePagination.

@Test
public void shouldExecutePagination() {
    Pagination pagination = Pagination.page(1).size(1);
    ColumnQueryPagination query = ColumnQueryPagination.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) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Aggregations

Pagination (jakarta.nosql.mapping.Pagination)8 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)8 Test (org.junit.jupiter.api.Test)7 ColumnQuery (jakarta.nosql.column.ColumnQuery)5 Person (jakarta.nosql.tck.entities.Person)3 Column (jakarta.nosql.column.Column)1 ColumnEntity (jakarta.nosql.column.ColumnEntity)1 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)1 ColumnEventPersistManager (jakarta.nosql.mapping.column.ColumnEventPersistManager)1 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1