Search in sources :

Example 1 with COLUMN_FAMILY

use of org.jnosql.diana.cassandra.column.Constants.COLUMN_FAMILY 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());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) EmbeddedCassandraServerHelper(org.cassandraunit.utils.EmbeddedCassandraServerHelper) TTransportException(org.apache.thrift.transport.TTransportException) Matchers.not(org.hamcrest.Matchers.not) ColumnDeleteQuery(org.jnosql.diana.api.column.ColumnDeleteQuery) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ColumnQueryBuilder.delete(org.jnosql.diana.api.column.query.ColumnQueryBuilder.delete) AtomicReference(java.util.concurrent.atomic.AtomicReference) ConsistencyLevel(com.datastax.driver.core.ConsistencyLevel) Collections.singletonList(java.util.Collections.singletonList) AfterAll(org.junit.jupiter.api.AfterAll) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Duration(java.time.Duration) Map(java.util.Map) Columns(org.jnosql.diana.api.column.Columns) Thread.sleep(java.lang.Thread.sleep) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) KEY_SPACE(org.jnosql.diana.cassandra.column.Constants.KEY_SPACE) ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Awaitility.await(org.awaitility.Awaitility.await) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Collections.emptyList(java.util.Collections.emptyList) IOException(java.io.IOException) COLUMN_FAMILY(org.jnosql.diana.cassandra.column.Constants.COLUMN_FAMILY) Column(org.jnosql.diana.api.column.Column) Test(org.junit.jupiter.api.Test) Consumer(java.util.function.Consumer) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) ColumnQueryBuilder.select(org.jnosql.diana.api.column.query.ColumnQueryBuilder.select) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) AtomicReference(java.util.concurrent.atomic.AtomicReference) ColumnDeleteQuery(org.jnosql.diana.api.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Aggregations

ConsistencyLevel (com.datastax.driver.core.ConsistencyLevel)1 IOException (java.io.IOException)1 Thread.sleep (java.lang.Thread.sleep)1 Duration (java.time.Duration)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Consumer (java.util.function.Consumer)1 TTransportException (org.apache.thrift.transport.TTransportException)1 Awaitility.await (org.awaitility.Awaitility.await)1 EmbeddedCassandraServerHelper (org.cassandraunit.utils.EmbeddedCassandraServerHelper)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Matchers.not (org.hamcrest.Matchers.not)1