Search in sources :

Example 66 with ColumnEntity

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

the class CassandraColumnFamilyManagerTest method shouldSupportListUDTs.

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

Example 67 with ColumnEntity

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

the class CassandraColumnFamilyManagerTest method createEntityWithIterable.

private ColumnEntity createEntityWithIterable() {
    ColumnEntity entity = ColumnEntity.of("contacts");
    entity.add(Column.of("user", "otaviojava"));
    List<Iterable<Column>> columns = new ArrayList<>();
    columns.add(asList(Column.of("firstname", "Poliana"), Column.of("lastname", "Santana")));
    columns.add(asList(Column.of("firstname", "Ada"), Column.of("lastname", "Lovelace")));
    columns.add(asList(Column.of("firstname", "Maria"), Column.of("lastname", "Goncalves")));
    UDT udt = UDT.builder("fullname").withName("names").addUDTs(columns).build();
    entity.add(udt);
    return entity;
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) ArrayList(java.util.ArrayList)

Example 68 with ColumnEntity

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

the class CassandraColumnFamilyManagerTest method shouldInsertJustKey.

@Test
public void shouldInsertJustKey() {
    Column key = Columns.of("id", 10L);
    ColumnEntity columnEntity = ColumnEntity.of(COLUMN_FAMILY);
    columnEntity.add(key);
    entityManager.insert(columnEntity);
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Column(org.jnosql.diana.api.column.Column) Test(org.junit.jupiter.api.Test)

Example 69 with ColumnEntity

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

the class CassandraReturnQueryAsync method run.

@Override
public void run() {
    try {
        ResultSet resultSet = this.resultSet.get();
        List<ColumnEntity> entities = resultSet.all().stream().map(CassandraConverter::toDocumentEntity).collect(Collectors.toList());
        consumer.accept(entities);
    } catch (InterruptedException | ExecutionException e) {
        throw new ExecuteAsyncQueryException(e);
    }
}
Also used : ExecuteAsyncQueryException(org.jnosql.diana.api.ExecuteAsyncQueryException) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) ResultSet(com.datastax.driver.core.ResultSet) ExecutionException(java.util.concurrent.ExecutionException)

Example 70 with ColumnEntity

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

the class DefaultColumnTemplateAsyncTest method shouldUpdateIterable.

@Test
public void shouldUpdateIterable() {
    ColumnEntity entity = ColumnEntity.of("Person");
    entity.addAll(Stream.of(columns).collect(Collectors.toList()));
    subject.update(singletonList(this.person));
    verify(managerMock).update(captor.capture(), Mockito.any(Consumer.class));
    ColumnEntity value = captor.getValue();
    assertEquals(entity.getName(), value.getName());
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Consumer(java.util.function.Consumer) 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