Search in sources :

Example 41 with ColumnCondition

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLt.

@Test
public void shouldSelectWhereNameLt() {
    String columnFamily = "columnFamily";
    Number value = 10;
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").lt(value).build();
    ColumnCondition columnCondition = query.getCondition().get();
    Column column = columnCondition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LESSER_THAN, columnCondition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(value, column.get());
}
Also used : Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) ColumnDeleteQuery(org.jnosql.diana.api.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 42 with ColumnCondition

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLike.

@Test
public void shouldSelectWhereNameLike() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnQuery query = select().from(columnFamily).where("name").like(name).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LIKE, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(name, column.get());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 43 with ColumnCondition

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLt.

@Test
public void shouldSelectWhereNameLt() {
    String columnFamily = "columnFamily";
    Number value = 10;
    ColumnQuery query = select().from(columnFamily).where("name").lt(value).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LESSER_THAN, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(value, column.get());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 44 with ColumnCondition

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String columnFamily = "columnFamily";
    Number valueA = 10;
    Number valueB = 20;
    ColumnQuery query = select().from(columnFamily).where("name").between(valueA, valueB).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", column.getName());
    assertThat(column.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) TypeReference(org.jnosql.diana.api.TypeReference) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 45 with ColumnCondition

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLte.

@Test
public void shouldSelectWhereNameLte() {
    String columnFamily = "columnFamily";
    Number value = 10;
    ColumnQuery query = select().from(columnFamily).where("name").lte(value).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LESSER_EQUALS_THAN, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(value, column.get());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Column(org.jnosql.diana.api.column.Column) ColumnCondition(org.jnosql.diana.api.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnCondition (org.jnosql.diana.api.column.ColumnCondition)69 Test (org.junit.jupiter.api.Test)46 Column (org.jnosql.diana.api.column.Column)29 ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)29 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)23 List (java.util.List)20 Person (org.jnosql.artemis.model.Person)13 Collections.singletonList (java.util.Collections.singletonList)7 Pagination (org.jnosql.artemis.Pagination)7 Condition (org.jnosql.diana.api.Condition)7 Sort (org.jnosql.diana.api.Sort)7 Proxy (java.lang.reflect.Proxy)6 Duration (java.time.Duration)6 Optional (java.util.Optional)6 Consumer (java.util.function.Consumer)6 Inject (javax.inject.Inject)6 CDIExtension (org.jnosql.artemis.CDIExtension)6 Converters (org.jnosql.artemis.Converters)6 DynamicQueryException (org.jnosql.artemis.DynamicQueryException)6 RepositoryAsync (org.jnosql.artemis.RepositoryAsync)6