Search in sources :

Example 26 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class CassandraColumnFamilyManagerAsyncTest method shouldInsertColumnsAsync.

@Test
public void shouldInsertColumnsAsync() {
    ColumnEntity columnEntity = getColumnFamily();
    columnEntityManager.insert(columnEntity);
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 27 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class CassandraColumnFamilyManagerAsyncTest method getColumnFamily.

private ColumnEntity getColumnFamily() {
    Map<String, Object> fields = new HashMap<>();
    fields.put("name", "Cassandra");
    fields.put("version", 3.2);
    fields.put("options", asList(1, 2, 3));
    List<Column> columns = Columns.of(fields);
    ColumnEntity columnFamily = ColumnEntity.of(COLUMN_FAMILY, singletonList(Columns.of("id", 10L)));
    columns.forEach(columnFamily::add);
    return columnFamily;
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) HashMap(java.util.HashMap) Column(org.jnosql.diana.api.column.Column)

Example 28 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class CassandraColumnFamilyManagerAsyncTest method shouldUpdateColumnsAsync.

@Test
public void shouldUpdateColumnsAsync() {
    ColumnEntity columnEntity = getColumnFamily();
    columnEntityManager.update(columnEntity);
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 29 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity 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));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) 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) Test(org.junit.jupiter.api.Test)

Example 30 with ColumnEntity

use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class CassandraColumnFamilyManagerAsyncTest method shouldReturnErrorWhenInsertWithCallbackNull.

@Test
public void shouldReturnErrorWhenInsertWithCallbackNull() {
    ColumnEntity entity = ColumnEntity.of(COLUMN_FAMILY);
    assertThrows(NullPointerException.class, () -> {
        columnEntityManager.insert(entity, (Consumer<ColumnEntity>) null);
    });
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (org.jnosql.diana.api.column.ColumnEntity)88 Test (org.junit.jupiter.api.Test)76 ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)26 Column (org.jnosql.diana.api.column.Column)22 Arrays.asList (java.util.Arrays.asList)17 List (java.util.List)17 Consumer (java.util.function.Consumer)14 Collections.singletonList (java.util.Collections.singletonList)13 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)13 Person (org.jnosql.artemis.model.Person)12 Duration (java.time.Duration)11 Collections.emptyList (java.util.Collections.emptyList)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 ColumnQueryBuilder.delete (org.jnosql.diana.api.column.query.ColumnQueryBuilder.delete)9 ColumnQueryBuilder.select (org.jnosql.diana.api.column.query.ColumnQueryBuilder.select)9 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ArrayList (java.util.ArrayList)8 Arrays (java.util.Arrays)8