use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-artemis by eclipse.
the class DefaultColumnEventPersistManagerTest method shouldFirePreQuery.
@Test
public void shouldFirePreQuery() {
ColumnQuery query = select().from("person").build();
subject.firePreQuery(query);
ArgumentCaptor<ColumnQueryExecute> captor = ArgumentCaptor.forClass(ColumnQueryExecute.class);
verify(columnQueryExecute).fire(captor.capture());
assertEquals(query, captor.getValue().getQuery());
}
use of org.jnosql.diana.api.column.ColumnQuery in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerAsyncTest method shouldUpdateColumnsAsyncWithCallBack.
@Test
public void shouldUpdateColumnsAsyncWithCallBack() {
ColumnEntity columnEntity = getColumnFamily();
AtomicBoolean callBack = new AtomicBoolean(false);
columnEntityManager.update(columnEntity, c -> callBack.set(true));
await().untilTrue(callBack);
ColumnQuery query = select().from(COLUMN_FAMILY).where("id").eq(10L).build();
AtomicReference<List<ColumnEntity>> entities = new AtomicReference<>(emptyList());
columnEntityManager.select(query, entities::set);
await().until(() -> entities.get().size(), not(equalTo(0)));
assertThat(entities.get(), contains(columnEntity));
}
use of org.jnosql.diana.api.column.ColumnQuery 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.ColumnQuery 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.ColumnQuery 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