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")));
}
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);
}
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()));
}
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);
}
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));
}
Aggregations