use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldFind.
@Test
public void shouldFind() {
columnFamilyManager.insert(createEntity());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
List<ColumnEntity> columnFamilyEntities = columnFamilyManager.select(query).collect(Collectors.toList());
assertNotNull(columnFamilyEntities);
assertFalse(columnFamilyEntities.isEmpty());
ColumnEntity entity = columnFamilyEntities.get(0);
assertEquals(FAMILY, entity.getName());
assertThat(entity.getColumns(), containsInAnyOrder(Column.of(ID_FIELD, "otaviojava"), Column.of("age", "26"), Column.of("country", "Brazil")));
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldDeleteEntities.
@Test
public void shouldDeleteEntities() {
columnFamilyManager.insert(createEntity());
columnFamilyManager.insert(createEntity2());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
ColumnDeleteQuery deleteQuery = delete().from(FAMILY).where(ID_FIELD).eq("otaviojava").or(ID_FIELD).eq("poliana").build();
columnFamilyManager.delete(deleteQuery);
List<ColumnEntity> entities = columnFamilyManager.select(query).collect(Collectors.toList());
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method shouldDeleteEntity.
@Test
public void shouldDeleteEntity() {
columnFamilyManager.insert(createEntity());
ColumnQuery query = select().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
ColumnDeleteQuery deleteQuery = delete().from(FAMILY).where(ID_FIELD).eq("otaviojava").build();
columnFamilyManager.delete(deleteQuery);
List<ColumnEntity> entities = columnFamilyManager.select(query).collect(Collectors.toList());
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManagerTest method createEntity2.
private ColumnEntity createEntity2() {
ColumnEntity entity = ColumnEntity.of(FAMILY);
entity.add(Column.of(ID_FIELD, "poliana"));
entity.add(Column.of("age", 24));
entity.add(Column.of("country", "Brazil"));
return entity;
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class ColumnEntityTest method shouldConvertSubColumnListToMap2.
@Test
public void shouldConvertSubColumnListToMap2() {
ColumnEntity entity = ColumnEntity.of("entity");
entity.add(Column.of("_id", "id"));
List<List<Column>> columns = new ArrayList<>();
columns.add(asList(Column.of("name", "Ada"), Column.of("type", "type"), Column.of("information", "ada@lovelace.com")));
entity.add(Column.of("contacts", columns));
Map<String, Object> result = entity.toMap();
assertEquals("id", result.get("_id"));
List<List<Map<String, Object>>> contacts = (List<List<Map<String, Object>>>) result.get("contacts");
assertEquals(1, contacts.size());
List<Map<String, Object>> maps = contacts.get(0);
assertEquals(3, maps.size());
assertThat(maps, containsInAnyOrder(singletonMap("name", "Ada"), singletonMap("type", "type"), singletonMap("information", "ada@lovelace.com")));
}
Aggregations