use of org.jnosql.diana.api.Condition 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.Condition 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.Condition 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.Condition 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.Condition in project jnosql-artemis by eclipse.
the class ColumnRepositoryAsyncProxyTest method shouldExecuteQuery.
@Test
public void shouldExecuteQuery() {
Consumer<List<Person>> callback = v -> {
};
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
ColumnQuery query = select().from("Person").where("name").eq("Ada").build();
personRepository.query(query, callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
ColumnQuery queryCaptor = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals(query, queryCaptor);
assertEquals(callback, consumerCaptor.getValue());
}
Aggregations