Search in sources :

Example 51 with ColumnEntity

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

Example 52 with ColumnEntity

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

the class HBaseColumnFamilyManagerTest method shouldSave.

@Test
public void shouldSave() {
    ColumnEntity entity = createEntity();
    columnFamilyManager.insert(entity);
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 53 with ColumnEntity

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

the class CassandraColumnFamilyManagerAsyncTest method shouldReturnErrorWhenInsertWithTTLNull.

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

Example 54 with ColumnEntity

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

the class CassandraColumnFamilyManagerAsyncTest method shouldReturnErrorWhenSaveWithCallbackNull.

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

Example 55 with ColumnEntity

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

the class CassandraColumnFamilyManagerAsyncTest method shouldInsertColumnsAsyncWithCallBack.

@Test
public void shouldInsertColumnsAsyncWithCallBack() {
    ColumnEntity columnEntity = getColumnFamily();
    AtomicBoolean callBack = new AtomicBoolean(false);
    columnEntityManager.insert(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)

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