use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shoudFindByName.
@Test
public void shoudFindByName() {
Consumer<List<Person>> callback = v -> {
};
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByName("name", callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Document.of("name", "name"), condition.getDocument());
assertEquals(callback, consumerCaptor.getValue());
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shoudFindByNameSortPagination.
@Test
public void shoudFindByNameSortPagination() {
Consumer<List<Person>> callback = v -> {
};
Sort sort = Sort.of("age", Sort.SortType.ASC);
Pagination pagination = Pagination.of(10, 20);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByName("name", sort, pagination, callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Document.of("name", "name"), condition.getDocument());
assertEquals(callback, consumerCaptor.getValue());
assertEquals(sort, query.getSorts().get(0));
assertEquals(pagination.getFirstResult(), query.getFirstResult());
assertEquals(pagination.getMaxResults(), query.getMaxResults());
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shouldExecuteQuery.
@Test
public void shouldExecuteQuery() {
Consumer<List<Person>> callback = v -> {
};
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
DocumentQuery query = select().from("Person").where("name").eq("Ada").build();
personRepository.query(query, callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
DocumentQuery queryCaptor = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals(query, queryCaptor);
assertEquals(callback, consumerCaptor.getValue());
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shouldFindByNameOrderByAgeDesc.
@Test
public void shouldFindByNameOrderByAgeDesc() {
Consumer<List<Person>> callback = v -> {
};
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByNameOrderByAgeDesc("name", callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
DocumentQuery query = captor.getValue();
DocumentCondition condition = query.getCondition().get();
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Document.of("name", "name"), condition.getDocument());
assertEquals(callback, consumerCaptor.getValue());
assertEquals(Sort.of("age", Sort.SortType.DESC), query.getSorts().get(0));
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class AbstractMapperQuery method gteImpl.
protected void gteImpl(Number value) {
requireNonNull(value, "value is required");
DocumentCondition newCondition = DocumentCondition.gte(Document.of(representation.getColumnField(name), getValue(value)));
appendCondition(newCondition);
}
Aggregations