use of jakarta.nosql.mapping.Pagination 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));
}
use of jakarta.nosql.mapping.Pagination 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());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnPageTest method shouldReturnNPEWhenCollectionFactoryIsNull.
@Test
public void shouldReturnNPEWhenCollectionFactoryIsNull() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = createPage(pagination);
assertThrows(NullPointerException.class, () -> page.getContent(null));
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnPageTest method shouldExecuteQueryPagination.
@Test
public void shouldExecuteQueryPagination() {
Pagination pagination = Pagination.page(1).size(2);
ColumnQueryPagination query = ColumnQueryPagination.of(select().from("person").build(), pagination);
subject.select(query);
verify(managerMock).select(query);
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnRepositoryProxySortTest method shouldFindByNameOrderByName2.
@Test
public void shouldFindByNameOrderByName2() {
when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of((Person.builder().build())));
Pagination pagination = getPagination();
personRepository.findByNameOrderByName("name", pagination, Sorts.sorts().desc("age").asc("phone"));
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(EQUALS, condition.getCondition());
assertEquals(Column.of("name", "name"), condition.getColumn());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
assertThat(query.getSorts(), Matchers.contains(Sort.asc("name"), Sort.desc("age"), Sort.asc("phone")));
}
Aggregations