use of org.jnosql.diana.api.column.ColumnQuery 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));
}
use of org.jnosql.diana.api.column.ColumnQuery 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());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldFind.
@Test
public void shouldFind() {
columnFamilyManager.insert(createEntity());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
List<ColumnEntity> columnFamilyEntities = columnFamilyManager.select(query);
assertNotNull(columnFamilyEntities);
assertFalse(columnFamilyEntities.isEmpty());
ColumnEntity entity = columnFamilyEntities.get(0);
assertEquals(FAMILY, entity.getName());
assertThat(entity.getColumns(), containsInAnyOrder(Column.of(ID_FIELD, "otaviojava"), Column.of("age", "26"), Column.of("country", "Brazil")));
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldDeleteEntity.
@Test
public void shouldDeleteEntity() {
columnFamilyManager.insert(createEntity());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
ColumnDeleteQuery deleteQuery = delete().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
columnFamilyManager.delete(deleteQuery);
List<ColumnEntity> entities = columnFamilyManager.select(query);
assertTrue(entities.isEmpty());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldDeleteEntities.
@Test
public void shouldDeleteEntities() {
columnFamilyManager.insert(createEntity());
columnFamilyManager.insert(createEntity2());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
ColumnDeleteQuery deleteQuery = delete().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
columnFamilyManager.delete(deleteQuery);
List<ColumnEntity> entities = columnFamilyManager.select(query);
assertTrue(entities.isEmpty());
}
Aggregations