use of jakarta.nosql.mapping.document.DocumentQueryPagination in project jnosql-diana by eclipse.
the class DocumentPageTest method setUp.
@BeforeEach
public void setUp() {
managerMock = Mockito.mock(DocumentCollectionManager.class);
columnEventPersistManager = Mockito.mock(DocumentEventPersistManager.class);
captor = ArgumentCaptor.forClass(DocumentEntity.class);
Instance<DocumentCollectionManager> instance = Mockito.mock(Instance.class);
when(instance.get()).thenReturn(managerMock);
this.subject = new DefaultDocumentTemplate(converter, instance, new DefaultDocumentWorkflow(columnEventPersistManager, converter), columnEventPersistManager, classMappings, converters);
Pagination pagination = Pagination.page(1).size(1);
DocumentQueryPagination query = DocumentQueryPagination.of(select().from("person").build(), pagination);
for (int index = 0; index <= 10; index++) {
Document[] columns = new Document[] { Document.of("age", index), Document.of("name", "Ada " + index), Document.of("_id", (long) index) };
DocumentEntity columnEntity = DocumentEntity.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.document.DocumentQueryPagination in project jnosql-diana by eclipse.
the class DefaultDocumentQueryPaginationTest method shouldCreateDocumentQueryPagination.
@Test
public void shouldCreateDocumentQueryPagination() {
DocumentQuery query = select().from("column").build();
Pagination pagination = Pagination.page(1).size(2);
DocumentQueryPagination queryPagination = DocumentQueryPagination.of(query, pagination);
assertNotNull(queryPagination);
isQueryEquals(query, pagination, queryPagination);
}
use of jakarta.nosql.mapping.document.DocumentQueryPagination in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldCreatePage.
@Test
public void shouldCreatePage() {
Pagination pagination = Pagination.page(2).size(2);
DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
ArgumentCaptor<DocumentQueryPagination> queryCaptor = ArgumentCaptor.forClass(DocumentQueryPagination.class);
Page<Person> page = mapperBuilder.selectFrom(Person.class).page(template, pagination);
Mockito.verify(template).select(queryCaptor.capture());
DocumentQuery query = queryCaptor.getValue();
assertEquals(pagination.getLimit(), query.getLimit());
assertEquals(pagination.getSkip(), query.getSkip());
}
Aggregations