Search in sources :

Example 41 with ColumnEntity

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

the class CassandraColumnFamilyManagerTest method shouldDeleteColumnFamily.

@Test
public void shouldDeleteColumnFamily() {
    entityManager.insert(getColumnFamily());
    ColumnEntity.of(COLUMN_FAMILY, singletonList(Columns.of("id", 10L)));
    ColumnQuery query = select().from(COLUMN_FAMILY).where("id").eq(10L).build();
    ColumnDeleteQuery deleteQuery = delete().from(COLUMN_FAMILY).where("id").eq(10L).build();
    entityManager.delete(deleteQuery);
    List<ColumnEntity> entities = entityManager.cql("select * from newKeySpace.newColumnFamily where id=10;");
    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 42 with ColumnEntity

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

the class CassandraColumnFamilyManagerTest method shouldFindById.

@Test
public void shouldFindById() {
    entityManager.insert(getColumnFamily());
    ColumnQuery query = select().from(COLUMN_FAMILY).where("id").eq(10L).build();
    List<ColumnEntity> columnEntity = entityManager.select(query);
    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));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Column(org.jnosql.diana.api.column.Column) Value(org.jnosql.diana.api.Value) Test(org.junit.jupiter.api.Test)

Example 43 with ColumnEntity

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

the class EntityUnit method toEntity.

public ColumnEntity toEntity() {
    ColumnEntity entity = ColumnEntity.of(columnFamily);
    entity.addAll(columns);
    entity.add(getKey(rowKey));
    return entity;
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity)

Example 44 with ColumnEntity

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

the class HBaseColumnFamilyManagerTest method createEntity.

private ColumnEntity createEntity() {
    ColumnEntity entity = ColumnEntity.of(FAMILY);
    entity.add(Column.of(ID_FIELD, "otaviojava"));
    entity.add(Column.of("age", 26));
    entity.add(Column.of("country", "Brazil"));
    return entity;
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity)

Example 45 with ColumnEntity

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

the class HBaseColumnFamilyManagerTest method shouldReturnErrorWhenKeyIsNotDefined.

@Test
public void shouldReturnErrorWhenKeyIsNotDefined() {
    ColumnEntity entity = ColumnEntity.of(FAMILY);
    entity.add(Column.of("id", "otaviojava"));
    entity.add(Column.of("age", 26));
    entity.add(Column.of("country", "Brazil"));
    assertThrows(DianaHBaseException.class, () -> columnFamilyManager.insert(entity));
}
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