use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.
the class ColumnQueryParserTest method shouldFindByNameWithPageSortArgumentAndIgnore.
@Test
public void shouldFindByNameWithPageSortArgumentAndIgnore() {
Pagination pagination = Pagination.of(2L, 10);
Sort sort = Sort.of("age", Sort.SortType.ASC);
ColumnQuery query = parser.parse("findByName", new Object[] { "name", pagination, sort, "ignore" }, classRepresentation, converters);
assertEquals("Person", query.getColumnFamily());
assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
assertEquals(Column.of("name", "name"), query.getCondition().get().getColumn());
assertEquals(pagination.getMaxResults(), query.getMaxResults());
assertEquals(pagination.getFirstResult(), query.getFirstResult());
assertEquals(sort, query.getSorts().get(0));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.
the class ColumnQueryParserTest method shouldFindByNameWithSortArgument.
@Test
public void shouldFindByNameWithSortArgument() {
Sort sort = Sort.of("age", Sort.SortType.ASC);
ColumnQuery query = parser.parse("findByName", new Object[] { "name", sort }, classRepresentation, converters);
assertEquals("Person", query.getColumnFamily());
assertEquals(Condition.EQUALS, query.getCondition().get().getCondition());
assertEquals(Column.of("name", "name"), query.getCondition().get().getColumn());
assertEquals(sort, query.getSorts().get(0));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.
the class ColumnQueryParserTest method shouldFindByNameOrAge.
@Test
public void shouldFindByNameOrAge() {
ColumnQuery query = parser.parse("findByNameOrAge", new Object[] { "name", 10 }, classRepresentation, converters);
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(Condition.OR, condition.getCondition());
List<ColumnCondition> conditions = condition.getColumn().get(new TypeReference<List<ColumnCondition>>() {
});
ColumnCondition condition1 = conditions.get(0);
assertEquals(Condition.EQUALS, condition1.getCondition());
assertEquals(Column.of("name", "name"), condition1.getColumn());
ColumnCondition condition2 = conditions.get(1);
assertEquals(Condition.EQUALS, condition2.getCondition());
assertEquals(Column.of("age", 10), condition2.getColumn());
}
use of org.jnosql.diana.api.column.ColumnQuery 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());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.
the class ColumnRepositoryAsyncProxyTest method shoudFindByNameSort.
@Test
public void shoudFindByNameSort() {
Consumer<List<Person>> callback = v -> {
};
Sort sort = Sort.of("age", Sort.SortType.ASC);
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
personRepository.findByName("name", sort, callback);
verify(template).select(captor.capture(), consumerCaptor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals(Column.of("name", "name"), condition.getColumn());
assertEquals(callback, consumerCaptor.getValue());
assertEquals(sort, query.getSorts().get(0));
}
Aggregations