Search in sources :

Example 56 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class CassandraColumnFamilyManagerTest method shouldSupportUDT.

@Test
public void shouldSupportUDT() {
    ColumnEntity entity = ColumnEntity.of("users");
    entity.add(Column.of("nickname", "ada"));
    List<Column> columns = new ArrayList<>();
    columns.add(Column.of("firstname", "Ada"));
    columns.add(Column.of("lastname", "Lovelace"));
    UDT udt = UDT.builder("fullname").withName("name").addUDT(columns).build();
    entity.add(udt);
    entityManager.insert(entity);
    ColumnQuery query = select().from("users").build();
    ColumnEntity columnEntity = entityManager.singleResult(query).get();
    Column column = columnEntity.find("name").get();
    udt = UDT.class.cast(column);
    List<Column> udtColumns = (List<Column>) udt.get();
    assertEquals("name", udt.getName());
    assertEquals("fullname", udt.getUserType());
    assertThat(udtColumns, Matchers.containsInAnyOrder(Column.of("firstname", "Ada"), Column.of("lastname", "Lovelace")));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Test(org.junit.jupiter.api.Test)

Example 57 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class CassandraColumnFamilyManagerTest method shouldInsertColumnsWithConsistencyLevel.

@Test
public void shouldInsertColumnsWithConsistencyLevel() {
    ColumnEntity columnEntity = getColumnFamily();
    entityManager.save(columnEntity, CONSISTENCY_LEVEL);
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 58 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.

the class HBaseColumnFamilyManagerTest method shouldFindInBatch.

@Test
public void shouldFindInBatch() {
    columnFamilyManager.insert(createEntity());
    columnFamilyManager.insert(createEntity2());
    ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
    List<ColumnEntity> entities = columnFamilyManager.select(query).collect(Collectors.toList());
    assertEquals(Integer.valueOf(2), Integer.valueOf(entities.size()));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 59 with ColumnEntity

use of jakarta.nosql.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(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 60 with ColumnEntity

use of jakarta.nosql.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(HBaseException.class, () -> columnFamilyManager.insert(entity));
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (jakarta.nosql.column.ColumnEntity)146 Test (org.junit.jupiter.api.Test)103 Column (jakarta.nosql.column.Column)39 ColumnQuery (jakarta.nosql.column.ColumnQuery)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 ValueSource (org.junit.jupiter.params.provider.ValueSource)23 Duration (java.time.Duration)13 ArrayList (java.util.ArrayList)13 List (java.util.List)13 Arrays.asList (java.util.Arrays.asList)11 Person (jakarta.nosql.tck.entities.Person)9 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Value (jakarta.nosql.Value)6 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)6 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)5 Actor (jakarta.nosql.tck.entities.Actor)5 Director (jakarta.nosql.tck.entities.Director)5 Movie (jakarta.nosql.tck.entities.Movie)5