use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByIn.
@Test
public void shouldFindByIn() {
Vendor vendor = new Vendor("vendor");
vendor.setPrefixes(Collections.singleton("prefix"));
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
Pagination pagination = getPagination();
vendorRepository.findByPrefixesIn(Collections.singletonList("prefix"), pagination);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).singleResult(captor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("vendors", query.getDocumentCollection());
assertEquals(IN, condition.getCondition());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByGreaterThan.
@Test
public void shouldFindByGreaterThan() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAgeGreaterThan(33, pagination);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).select(captor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(GREATER_THAN, condition.getCondition());
assertEquals(Document.of("age", 33), condition.getDocument());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByAgeLessThanEqual.
@Test
public void shouldFindByAgeLessThanEqual() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAgeLessThanEqual(33, pagination);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).select(captor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(LESSER_EQUALS_THAN, condition.getCondition());
assertEquals(Document.of("age", 33), condition.getDocument());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByNameANDAgeOrderByAge.
@Test
public void shouldFindByNameANDAgeOrderByAge() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
Queue<Person> persons = personRepository.findByNameAndAgeOrderByAge("name", 20, pagination);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).select(captor.capture());
assertThat(persons, Matchers.contains(ada));
DocumentQuery query = captor.getValue();
assertEquals("Person", query.getDocumentCollection());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DefaultDocumentMapperSelectBuilderTest method shouldCreateQueryWithPagination.
@Test
public void shouldCreateQueryWithPagination() {
Pagination pagination = Pagination.page(2).size(2);
DocumentMapperFrom columnFrom = mapperBuilder.selectFrom(Person.class);
DocumentQuery query = columnFrom.build(pagination);
assertEquals(pagination.getLimit(), query.getLimit());
assertEquals(pagination.getSkip(), query.getSkip());
}
Aggregations