use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectOrderDesc.
@Test
public void shouldSelectOrderDesc() {
String columnFamily = "columnFamily";
ColumnQuery query = select().from(columnFamily).orderBy("name").desc().build();
assertTrue(query.getColumns().isEmpty());
assertFalse(query.getCondition().isPresent());
assertEquals(columnFamily, query.getColumnFamily());
assertThat(query.getSorts(), contains(Sort.of("name", DESC)));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameNot.
@Test
public void shouldSelectWhereNameNot() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnQuery query = select().from(columnFamily).where("name").not().eq(name).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
ColumnCondition negate = column.get(ColumnCondition.class);
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.NOT, condition.getCondition());
assertEquals(Condition.EQUALS, negate.getCondition());
assertEquals("name", negate.getColumn().getName());
assertEquals(name, negate.getColumn().get());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectStart.
@Test
public void shouldSelectStart() {
String columnFamily = "columnFamily";
ColumnQuery query = select().from(columnFamily).start(10).build();
assertTrue(query.getColumns().isEmpty());
assertFalse(query.getCondition().isPresent());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(10L, query.getFirstResult());
}
use of org.jnosql.diana.api.column.ColumnQuery 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());
}
use of org.jnosql.diana.api.column.ColumnQuery 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());
}
Aggregations