use of org.jnosql.diana.api.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);
assertEquals(Integer.valueOf(2), Integer.valueOf(entities.size()));
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class ManagerProducerProducer method getColumnFamilyManager.
@Produces
public ColumnFamilyManager getColumnFamilyManager() {
ColumnFamilyManager columnFamilyManager = Mockito.mock(ColumnFamilyManager.class);
ColumnEntity entity = ColumnEntity.of("person");
entity.add(Column.of("name", "Ada"));
entity.add(Column.of("age", 10));
entity.add(Column.of("salary", BigDecimal.TEN));
entity.add(Column.of("phones", singletonList("22342342")));
when(columnFamilyManager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
when(columnFamilyManager.update(Mockito.any(ColumnEntity.class))).thenReturn(entity);
return columnFamilyManager;
}
use of org.jnosql.diana.api.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);
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 org.jnosql.diana.api.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 org.jnosql.diana.api.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);
assertTrue(entities.isEmpty());
}
Aggregations