use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameOr.
@Test
public void shouldSelectWhereNameOr() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnDeleteQuery query = delete().from(columnFamily).where("name").eq(name).or("age").gt(10).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.OR, condition.getCondition());
assertThat(conditions, Matchers.containsInAnyOrder(ColumnCondition.eq(Column.of("name", name)), ColumnCondition.gt(Column.of("age", 10))));
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery 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());
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery 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.ColumnDeleteQuery 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());
}
use of org.jnosql.diana.api.column.ColumnDeleteQuery in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerAsyncTest method shouldReturnErrorWhenCallBackIsNull.
@Test
public void shouldReturnErrorWhenCallBackIsNull() {
ColumnDeleteQuery query = delete().from(COLUMN_FAMILY).build();
assertThrows(NullPointerException.class, () -> {
columnEntityManager.delete(query, (Consumer<Void>) null);
});
}
Aggregations