use of org.jnosql.diana.api.Sort in project jnosql-diana-driver by eclipse.
the class QueryOSQLConverter method appendSort.
private static void appendSort(List<Sort> sorts, StringBuilder query) {
query.append(SORT);
String separator = SPACE;
for (Sort sort : sorts) {
query.append(separator).append(sort.getName()).append(SPACE).append(sort.getType());
separator = ", ";
}
}
use of org.jnosql.diana.api.Sort in project jnosql-diana-driver by eclipse.
the class QueryAQLConverter method sort.
private static void sort(List<Sort> sorts, StringBuilder aql, char entity) {
aql.append(SORT);
String separator = SEPARATOR;
for (Sort sort : sorts) {
aql.append(separator).append(entity).append('.').append(sort.getName()).append(SEPARATOR).append(sort.getType());
separator = " , ";
}
}
use of org.jnosql.diana.api.Sort in project jnosql-artemis by eclipse.
the class DocumentQueryParserTest method shouldFindByNameWithSortArgument.
@Test
public void shouldFindByNameWithSortArgument() {
Sort sort = Sort.of("age", Sort.SortType.ASC);
DocumentQuery query = parser.parse("findByName", new Object[] { "name", sort }, classRepresentation, converters);
assertEquals("Person", query.getDocumentCollection());
assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
assertEquals(Document.of("name", "name"), query.getCondition().get().getDocument());
assertEquals(sort, query.getSorts().get(0));
}
use of org.jnosql.diana.api.Sort in project jnosql-artemis by eclipse.
the class DocumentRepositoryAsyncProxyTest method shoudFindByNameSort.
@Test
public void shoudFindByNameSort() {
Consumer<List<Person>> callback = v -> {
};
Sort sort = Sort.of("age", Sort.SortType.ASC);
ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByName("name", sort, 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));
}
use of org.jnosql.diana.api.Sort 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());
}
Aggregations