Search in sources :

Example 61 with Column

use of jakarta.nosql.column.Column 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 62 with Column

use of jakarta.nosql.column.Column 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)

Example 63 with Column

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

the class ColumnEntityTest method shouldRemoveColumn.

@Test
public void shouldRemoveColumn() {
    Column column = Column.of("name", "name");
    ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
    assertTrue(entity.remove("name"));
    assertTrue(entity.isEmpty());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 64 with Column

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

the class ColumnEntityTest method shouldAddColumnAsNameAndValue.

@Test
public void shouldAddColumnAsNameAndValue() {
    ColumnEntity entity = new DefaultColumnEntity("columnFamily");
    entity.add("name", Value.of(10));
    assertEquals(1, entity.size());
    Optional<Column> name = entity.find("name");
    assertTrue(name.isPresent());
    assertEquals(10, name.get().get());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 65 with Column

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

the class ColumnEntityTest method shouldAvoidDuplicatedColumnWhenAddList.

@Test
public void shouldAvoidDuplicatedColumnWhenAddList() {
    List<Column> columns = asList(Column.of("name", 10), Column.of("name", 13));
    ColumnEntity entity = new DefaultColumnEntity("columnFamily");
    entity.addAll(columns);
    assertEquals(1, entity.size());
    assertEquals(1, ColumnEntity.of("columnFamily", columns).size());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Aggregations

Column (jakarta.nosql.column.Column)113 Test (org.junit.jupiter.api.Test)72 ColumnCondition (jakarta.nosql.column.ColumnCondition)57 ColumnEntity (jakarta.nosql.column.ColumnEntity)39 ColumnQuery (jakarta.nosql.column.ColumnQuery)35 List (java.util.List)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 ValueSource (org.junit.jupiter.params.provider.ValueSource)26 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)24 ArrayList (java.util.ArrayList)13 Value (jakarta.nosql.Value)10 TypeReference (jakarta.nosql.TypeReference)9 Arrays.asList (java.util.Arrays.asList)9 Collections.singletonList (java.util.Collections.singletonList)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)6 Optional (java.util.Optional)4 CqlSession (com.datastax.oss.driver.api.core.CqlSession)3 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)3