use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerAsyncTest method shouldDeleteWithCallBack.
@Test
public void shouldDeleteWithCallBack() {
AtomicBoolean callback = new AtomicBoolean(false);
ColumnDeleteQuery deleteQuery = delete().from(COLUMN_FAMILY).where("id").eq(10L).build();
columnEntityManager.delete(deleteQuery, v -> callback.set(true));
await().untilTrue(callback);
ColumnQuery query = select().from(COLUMN_FAMILY).where("id").eq(10L).build();
AtomicReference<List<ColumnEntity>> entities = new AtomicReference<>(emptyList());
callback.set(false);
Consumer<List<ColumnEntity>> result = (l) -> {
callback.set(true);
entities.set(l);
};
columnEntityManager.select(query, result);
await().untilTrue(callback);
assertTrue(entities.get().isEmpty());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldInsertWithTtl.
@Test
public void shouldInsertWithTtl() throws InterruptedException {
ColumnEntity columnEntity = getColumnFamily();
entityManager.insert(columnEntity, Duration.ofSeconds(1L));
sleep(2_000L);
List<ColumnEntity> entities = entityManager.select(select().from(COLUMN_FAMILY).where("id").eq(10L).build());
assertTrue(entities.isEmpty());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldFindByIdWithConsistenceLevel.
@Test
public void shouldFindByIdWithConsistenceLevel() {
entityManager.insert(getColumnFamily());
ColumnQuery query = select().from(COLUMN_FAMILY).where("id").eq(10L).build();
List<ColumnEntity> columnEntity = entityManager.select(query, CONSISTENCY_LEVEL);
assertFalse(columnEntity.isEmpty());
List<Column> columns = columnEntity.get(0).getColumns();
assertThat(columns.stream().map(Column::getName).collect(toList()), containsInAnyOrder("name", "version", "options", "id"));
assertThat(columns.stream().map(Column::getValue).map(Value::get).collect(toList()), containsInAnyOrder("Cassandra", 3.2, asList(1, 2, 3), 10L));
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldInsertColumnsWithConsistencyLevel.
@Test
public void shouldInsertColumnsWithConsistencyLevel() {
ColumnEntity columnEntity = getColumnFamily();
entityManager.save(columnEntity, CONSISTENCY_LEVEL);
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldLimitResult.
@Test
public void shouldLimitResult() {
getEntities().forEach(entityManager::insert);
ColumnQuery query = select().from(COLUMN_FAMILY).where("id").in(Arrays.asList(1L, 2L, 3L)).limit(2).build();
List<ColumnEntity> columnFamilyEntities = entityManager.select(query);
assertEquals(Integer.valueOf(2), Integer.valueOf(columnFamilyEntities.size()));
}
Aggregations