use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectNegate.
@Test
public void shouldSelectNegate() {
String columnFamily = "columnFamily";
ColumnQuery query = select().from(columnFamily).where("city").not().eq("Assis").and("name").not().eq("Lucas").build();
ColumnCondition condition = query.getCondition().orElseThrow(RuntimeException::new);
assertEquals(columnFamily, query.getColumnFamily());
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.AND, condition.getCondition());
assertThat(conditions, containsInAnyOrder(eq(Column.of("city", "Assis")).negate(), eq(Column.of("name", "Lucas")).negate()));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectColumns.
@Test
public void shouldSelectColumns() {
String columnFamily = "columnFamily";
ColumnQuery query = select("column", "column2").from(columnFamily).build();
assertThat(query.getColumns(), containsInAnyOrder("column", "column2"));
assertFalse(query.getCondition().isPresent());
assertEquals(columnFamily, query.getColumnFamily());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameAnd.
@Test
public void shouldSelectWhereNameAnd() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnQuery query = select().from(columnFamily).where("name").eq(name).and("age").gt(10).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.AND, condition.getCondition());
assertThat(conditions, containsInAnyOrder(eq(Column.of("name", name)), ColumnCondition.gt(Column.of("age", 10))));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameEq.
@Test
public void shouldSelectWhereNameEq() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnQuery query = select().from(columnFamily).where("name").eq(name).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.EQUALS, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(name, column.get());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameGt.
@Test
public void shouldSelectWhereNameGt() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnQuery query = select().from(columnFamily).where("name").gt(value).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.GREATER_THAN, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
Aggregations