Search in sources :

Example 46 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.

the class QueryUtilsTest method shouldRunEqualsQuery.

@Test
public void shouldRunEqualsQuery() {
    ColumnQuery query = select().from("collection").where("name").eq("value").build();
    BuiltStatement select = QueryUtils.select(query, "keyspace");
    String cql = select.toString();
    assertEquals("value", select.getObject(0));
    assertEquals("SELECT * FROM keyspace.collection WHERE name='value';", cql);
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) BuiltStatement(com.datastax.driver.core.querybuilder.BuiltStatement) Test(org.junit.jupiter.api.Test)

Example 47 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.

the class QueryUtilsTest method shouldNegate.

@Test
public void shouldNegate() {
    ColumnQuery query = select().from("collection").where("city").eq("Assis").and("name").eq("Otavio").and("name").eq("Lucas").build();
    BuiltStatement select = QueryUtils.select(query, "keyspace");
    String cql = select.toString();
    assertEquals("Assis", select.getObject(0));
    assertEquals("Otavio", select.getObject(1));
    assertEquals("Lucas", select.getObject(2));
    assertEquals("SELECT * FROM keyspace.collection WHERE city='Assis' AND name='Otavio' AND name='Lucas';", cql);
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) BuiltStatement(com.datastax.driver.core.querybuilder.BuiltStatement) Test(org.junit.jupiter.api.Test)

Example 48 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.

the class QueryUtilsTest method shouldRunEqualsQuerySort2.

@Test
public void shouldRunEqualsQuerySort2() {
    ColumnQuery query = select().from("collection").where("name").eq("value").orderBy("name").asc().orderBy("age").desc().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,age DESC;", cql);
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) BuiltStatement(com.datastax.driver.core.querybuilder.BuiltStatement) Test(org.junit.jupiter.api.Test)

Example 49 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.

the class QueryUtilsTest method shouldRunEqualsQueryAnd.

@Test
public void shouldRunEqualsQueryAnd() {
    ColumnQuery query = select().from("collection").where("name").eq("value").and("age").lte(10).build();
    BuiltStatement select = QueryUtils.select(query, "keyspace");
    String cql = select.toString();
    assertEquals("value", select.getObject(0));
    assertEquals("SELECT * FROM keyspace.collection WHERE name='value' AND age<=10;", cql);
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) BuiltStatement(com.datastax.driver.core.querybuilder.BuiltStatement) Test(org.junit.jupiter.api.Test)

Example 50 with ColumnQuery

use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.

the class HBaseColumnFamilyManagerTest method shouldFindInBatch.

@Test
public void shouldFindInBatch() {
    columnFamilyManager.insert(createEntity());
    columnFamilyManager.insert(createEntity2());
    ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
    List<ColumnEntity> entities = columnFamilyManager.select(query);
    assertEquals(Integer.valueOf(2), Integer.valueOf(entities.size()));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)117 Test (org.junit.jupiter.api.Test)113 Person (org.jnosql.artemis.model.Person)37 ColumnCondition (org.jnosql.diana.api.column.ColumnCondition)35 Column (org.jnosql.diana.api.column.Column)29 List (java.util.List)26 ColumnEntity (org.jnosql.diana.api.column.ColumnEntity)26 Collections.singletonList (java.util.Collections.singletonList)20 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)19 Arrays.asList (java.util.Arrays.asList)15 Duration (java.time.Duration)14 ColumnQueryBuilder.delete (org.jnosql.diana.api.column.query.ColumnQueryBuilder.delete)14 ColumnQueryBuilder.select (org.jnosql.diana.api.column.query.ColumnQueryBuilder.select)14 BeforeEach (org.junit.jupiter.api.BeforeEach)14 Optional (java.util.Optional)13 Consumer (java.util.function.Consumer)13 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)13 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)13 Inject (javax.inject.Inject)12 CDIExtension (org.jnosql.artemis.CDIExtension)12