Search in sources :

Example 46 with ColumnEntity

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()));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 47 with ColumnEntity

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;
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) ColumnFamilyManager(org.jnosql.diana.api.column.ColumnFamilyManager) Produces(javax.enterprise.inject.Produces)

Example 48 with ColumnEntity

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")));
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 49 with ColumnEntity

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;
}
Also used : ColumnEntity(org.jnosql.diana.api.column.ColumnEntity)

Example 50 with ColumnEntity

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());
}
Also used : ColumnQuery(org.jnosql.diana.api.column.ColumnQuery) ColumnEntity(org.jnosql.diana.api.column.ColumnEntity) ColumnDeleteQuery(org.jnosql.diana.api.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (org.jnosql.diana.api.column.ColumnEntity)88 Test (org.junit.jupiter.api.Test)76 ColumnQuery (org.jnosql.diana.api.column.ColumnQuery)26 Column (org.jnosql.diana.api.column.Column)22 Arrays.asList (java.util.Arrays.asList)17 List (java.util.List)17 Consumer (java.util.function.Consumer)14 Collections.singletonList (java.util.Collections.singletonList)13 ColumnDeleteQuery (org.jnosql.diana.api.column.ColumnDeleteQuery)13 Person (org.jnosql.artemis.model.Person)12 Duration (java.time.Duration)11 Collections.emptyList (java.util.Collections.emptyList)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 ColumnQueryBuilder.delete (org.jnosql.diana.api.column.query.ColumnQueryBuilder.delete)9 ColumnQueryBuilder.select (org.jnosql.diana.api.column.query.ColumnQueryBuilder.select)9 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ArrayList (java.util.ArrayList)8 Arrays (java.util.Arrays)8