use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyPaginationTest method shouldFindByNameANDAge.
@Test
public void shouldFindByNameANDAge() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
List<Person> persons = personRepository.findByNameAndAge("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 DocumentRepositoryProxyPaginationTest method shouldConvertFieldToTheType.
@Test
public void shouldConvertFieldToTheType() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAge("120", 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(EQUALS, condition.getCondition());
assertEquals(Document.of("age", 120), 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 shouldFindByStringWhenFieldIsSet.
@Test
public void shouldFindByStringWhenFieldIsSet() {
Vendor vendor = new Vendor("vendor");
vendor.setPrefixes(Collections.singleton("prefix"));
when(template.select(any(DocumentQuery.class))).thenReturn(Stream.of(vendor));
Pagination pagination = getPagination();
vendorRepository.findByPrefixes("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(EQUALS, condition.getCondition());
assertEquals(Document.of("prefixes", "prefix"), 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 ColumnRepositoryProxyPaginationTest method shouldFindByAgeLessThanEqual.
@Test
public void shouldFindByAgeLessThanEqual() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAgeLessThanEqual(33, pagination);
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(LESSER_EQUALS_THAN, condition.getCondition());
assertEquals(Column.of("age", 33), condition.getColumn());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
use of jakarta.nosql.mapping.Pagination in project jnosql-diana by eclipse.
the class ColumnRepositoryProxyPaginationTest method shouldFindByNameANDAge.
@Test
public void shouldFindByNameANDAge() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
List<Person> persons = personRepository.findByNameAndAge("name", 20, pagination);
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
assertThat(persons, Matchers.contains(ada));
ColumnQuery query = captor.getValue();
assertEquals("Person", query.getColumnFamily());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
Aggregations