use of jakarta.nosql.document.DocumentQuery 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.document.DocumentQuery 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.document.DocumentQuery 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.document.DocumentQuery in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyTest 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));
vendorRepository.findByPrefixesIn(singletonList("prefix"));
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());
}
use of jakarta.nosql.document.DocumentQuery in project jnosql-diana by eclipse.
the class DocumentRepositoryProxyTest method shouldFindByNameANDAgeOrderByAge.
@Test
public void shouldFindByNameANDAgeOrderByAge() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(Mockito.any(DocumentQuery.class))).thenReturn(Stream.of(ada));
Queue<Person> persons = personRepository.findByNameAndAgeOrderByAge("name", 20);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
verify(template).select(captor.capture());
assertThat(persons, Matchers.contains(ada));
}
Aggregations