use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnPageTest method setUp.
@BeforeEach
public void setUp() {
managerMock = Mockito.mock(ColumnFamilyManager.class);
columnEventPersistManager = Mockito.mock(ColumnEventPersistManager.class);
captor = ArgumentCaptor.forClass(ColumnEntity.class);
Instance<ColumnFamilyManager> instance = Mockito.mock(Instance.class);
when(instance.get()).thenReturn(managerMock);
this.subject = new DefaultColumnTemplate(converter, instance, new DefaultColumnWorkflow(columnEventPersistManager, converter), columnEventPersistManager, classMappings, converters);
Pagination pagination = Pagination.page(1).size(1);
ColumnQueryPagination query = ColumnQueryPagination.of(select().from("person").build(), pagination);
for (int index = 0; index <= 10; index++) {
Column[] columns = new Column[] { Column.of("age", index), Column.of("name", "Ada " + index), Column.of("_id", (long) index) };
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
when(managerMock.select(query)).thenReturn(Stream.of(columnEntity));
query = query.next();
}
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnPageTest 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());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnPageTest method shouldRequestPageTwice.
@Test
public void shouldRequestPageTwice() {
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());
assertNotNull(page.getContent(ArrayList::new));
assertNotNull(page.getContent(HashSet::new));
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnPageTest method shouldCreatePagination.
@Test
public void shouldCreatePagination() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = createPage(pagination);
assertEquals(0L, page.get().map(Person::getId).findFirst().orElse(-0L));
Page<Person> nextPage = page.next();
assertEquals(pagination.next(), nextPage.getPagination());
assertEquals(1L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
nextPage = nextPage.next();
assertEquals(2L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
nextPage = nextPage.next();
assertEquals(3L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
nextPage = nextPage.next();
assertEquals(4L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
nextPage = nextPage.next();
assertEquals(5L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
nextPage = nextPage.next();
assertEquals(6L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
nextPage = nextPage.next();
assertEquals(7L, nextPage.get().map(Person::getId).findFirst().orElse(-0L));
}
Aggregations