use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldReturnListUDT.
@Test
public void shouldReturnListUDT() {
ColumnEntity entity = createEntityWithIterable();
entityManager.insert(entity);
ColumnQuery query = select().from("contacts").where("user").eq("otaviojava").build();
ColumnEntity columnEntity = entityManager.singleResult(query).get();
List<List<Column>> names = (List<List<Column>>) columnEntity.find("names").get().get();
assertEquals(3, names.size());
assertTrue(names.stream().allMatch(n -> n.size() == 2));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class QueryUtilsTest method shouldRunEqualsQuerySort.
@Test
public void shouldRunEqualsQuerySort() {
ColumnQuery query = select().from("collection").where("name").eq("value").orderBy("name").asc().build();
BuiltStatement select = QueryUtils.select(query, "keyspace");
String cql = select.toString();
assertEquals("value", select.getObject(0));
assertEquals("SELECT * FROM keyspace.collection WHERE name='value' ORDER BY name ASC;", cql);
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class QueryUtilsTest method shouldRunEqualsQueryLimit.
@Test
public void shouldRunEqualsQueryLimit() {
ColumnQuery query = select().from("collection").where("name").eq("value").limit(5).build();
BuiltStatement select = QueryUtils.select(query, "keyspace");
String cql = select.toString();
assertEquals("value", select.getObject(0));
assertEquals("SELECT * FROM keyspace.collection WHERE name='value' LIMIT 5;", cql);
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class QueryUtilsTest method shouldReturnErrorWhenUseNotOperator.
@Test
public void shouldReturnErrorWhenUseNotOperator() {
ColumnQuery query = select().from("collection").where("name").not().eq("value").build();
assertThrows(UnsupportedOperationException.class, () -> {
QueryUtils.select(query, "keyspace");
});
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class QueryUtilsTest method shouldReturnErrorWhenUseOr.
@Test
public void shouldReturnErrorWhenUseOr() {
ColumnQuery query = select().from("collection").where("name").eq("value").or("age").lte(10).build();
assertThrows(UnsupportedOperationException.class, () -> {
QueryUtils.select(query, "keyspace");
});
}
Aggregations