Search in sources :

Example 61 with ColumnEntity

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

Example 62 with ColumnEntity

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

Example 63 with ColumnEntity

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

Example 64 with ColumnEntity

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;
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity)

Example 65 with ColumnEntity

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")));
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (jakarta.nosql.column.ColumnEntity)146 Test (org.junit.jupiter.api.Test)103 Column (jakarta.nosql.column.Column)39 ColumnQuery (jakarta.nosql.column.ColumnQuery)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 ValueSource (org.junit.jupiter.params.provider.ValueSource)23 Duration (java.time.Duration)13 ArrayList (java.util.ArrayList)13 List (java.util.List)13 Arrays.asList (java.util.Arrays.asList)11 Person (jakarta.nosql.tck.entities.Person)9 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Value (jakarta.nosql.Value)6 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)6 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)5 Actor (jakarta.nosql.tck.entities.Actor)5 Director (jakarta.nosql.tck.entities.Director)5 Movie (jakarta.nosql.tck.entities.Movie)5