Search in sources :

Example 76 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class ColumnEntityTest method shouldConvertSubColumn.

@Test
public void shouldConvertSubColumn() {
    Column column = Column.of("name", "name");
    ColumnEntity entity = ColumnEntity.of("entity", singletonList(Column.of("sub", column)));
    Map<String, Object> result = entity.toMap();
    assertFalse(result.isEmpty());
    assertEquals(Integer.valueOf(1), Integer.valueOf(result.size()));
    Map<String, Object> map = (Map<String, Object>) result.get("sub");
    assertEquals("name", map.get("name"));
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Test(org.junit.jupiter.api.Test)

Example 77 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class ColumnEntityTest method shouldReturnOneColumn.

@Test
public void shouldReturnOneColumn() {
    ColumnEntity entity = ColumnEntity.of("entity");
    assertEquals(Integer.valueOf(0), Integer.valueOf(entity.size()));
    assertTrue(entity.isEmpty());
    entity.add(Column.of("name", "name"));
    entity.add(Column.of("name2", Value.of("name2")));
    assertFalse(entity.isEmpty());
    assertEquals(Integer.valueOf(2), Integer.valueOf(entity.size()));
    assertFalse(ColumnEntity.of("entity", singletonList(Column.of("name", "name"))).isEmpty());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 78 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class ColumnEntityTest method shouldAddANewColumn.

@Test
public void shouldAddANewColumn() {
    ColumnEntity entity = new DefaultColumnEntity("name");
    entity.add(Column.of("column", 12));
    assertFalse(entity.isEmpty());
    assertEquals(1, entity.size());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 79 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class ColumnEntityTest method shouldNotRemoveByName.

@Test
public void shouldNotRemoveByName() {
    ColumnEntity entity = new DefaultColumnEntity("name");
    entity.add(Column.of("value", 32D));
    assertFalse(entity.remove("value1"));
    assertFalse(entity.isEmpty());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 80 with ColumnEntity

use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.

the class ColumnEntityTest method shouldReturnErrorWhenFindColumnIsNull.

@Test
public void shouldReturnErrorWhenFindColumnIsNull() {
    Assertions.assertThrows(NullPointerException.class, () -> {
        Column column = Column.of("name", "name");
        ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
        entity.find(null);
    });
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) 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