use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldSupportAnUDTElement.
@Test
public void shouldSupportAnUDTElement() {
ColumnEntity entity = ColumnEntity.of("users");
entity.add(Column.of("nickname", "Ioda"));
List<Column> columns = new ArrayList<>();
columns.add(Column.of("firstname", "Ioda"));
UDT udt = UDT.builder("fullname").withName("name").addUDT(columns).build();
entity.add(udt);
entityManager.insert(entity);
ColumnQuery query = select().from("users").where("nickname").eq("Ioda").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", "Ioda")));
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldFindAll.
@Test
public void shouldFindAll() {
ColumnEntity columnEntity = getColumnFamily();
entityManager.insert(columnEntity);
ColumnQuery query = select().from(columnEntity.getName()).build();
List<ColumnEntity> entities = entityManager.select(query);
assertFalse(entities.isEmpty());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldSupportDate.
@Test
public void shouldSupportDate() {
ColumnEntity entity = ColumnEntity.of("history");
entity.add(Column.of("name", "World war II"));
ZoneId defaultZoneId = ZoneId.systemDefault();
Date dateEnd = Date.from(java.time.LocalDate.of(1945, Month.SEPTEMBER, 2).atStartOfDay(defaultZoneId).toInstant());
Calendar dataStart = Calendar.getInstance();
entity.add(Column.of("dataStart", LocalDate.fromYearMonthDay(1939, 9, 1)));
entity.add(Column.of("dateEnd", dateEnd));
entityManager.insert(entity);
ColumnQuery query = select().from("history").where("name").eq("World war II").build();
ColumnEntity entity1 = entityManager.singleResult(query).get();
assertNotNull(entity1);
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldInsertColumns.
@Test
public void shouldInsertColumns() {
ColumnEntity columnEntity = getColumnFamily();
entityManager.insert(columnEntity);
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method getColumnFamily.
private ColumnEntity getColumnFamily() {
Map<String, Object> fields = new HashMap<>();
fields.put("name", "Cassandra");
fields.put("version", 3.2);
fields.put("options", asList(1, 2, 3));
List<Column> columns = Columns.of(fields);
ColumnEntity columnFamily = ColumnEntity.of(COLUMN_FAMILY, singletonList(Columns.of("id", 10L)));
columns.forEach(columnFamily::add);
return columnFamily;
}
Aggregations