use of org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnQueryDeleteParserTest method shouldDeleteByNameAndAAgeBetween.
@Test
public void shouldDeleteByNameAndAAgeBetween() {
ColumnDeleteQuery query = parser.parse("deleteByNameAndAgeBetween", new Object[] { "name", 10, 11 }, classRepresentation, converters);
assertEquals("Person", query.getColumnFamily());
ColumnCondition condition = query.getCondition().get();
assertEquals(Condition.AND, 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.BETWEEN, condition2.getCondition());
assertEquals(Column.of("age", Arrays.asList(10, 11)), condition2.getColumn());
}
use of org.jnosql.diana.api.column.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnQueryParserTest method shouldFindByNameAndAge.
@Test
public void shouldFindByNameAndAge() {
ColumnQuery query = parser.parse("findByNameAndAge", new Object[] { "name", 10 }, classRepresentation, converters);
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(Condition.AND, 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.ColumnCondition in project jnosql-artemis by eclipse.
the class ColumnQueryParserTest method shouldFindByNameAndAAgeBetween.
@Test
public void shouldFindByNameAndAAgeBetween() {
ColumnQuery query = parser.parse("findByNameAndAgeBetween", new Object[] { "name", 10, 11 }, classRepresentation, converters);
assertEquals("Person", query.getColumnFamily());
ColumnCondition condition = query.getCondition().get();
assertEquals(Condition.AND, 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.BETWEEN, condition2.getCondition());
assertEquals(Column.of("age", Arrays.asList(10, 11)), condition2.getColumn());
}
use of org.jnosql.diana.api.column.ColumnCondition 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.ColumnCondition 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