Search in sources :

Example 1 with Column

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

the class ColumnEntityTest method shouldConvertToMap.

@Test
public void shouldConvertToMap() {
    Column column = Column.of("name", "name");
    ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
    Map<String, Object> result = entity.toMap();
    assertFalse(result.isEmpty());
    assertEquals(Integer.valueOf(1), Integer.valueOf(result.size()));
    assertEquals(column.getName(), result.keySet().stream().findAny().get());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 2 with Column

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

the class ColumnEntityTest method shouldNotFindValue.

@Test
public void shouldNotFindValue() {
    Column column = Column.of("name", "name");
    ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
    Optional<String> name = entity.find("not_found", String.class);
    Assertions.assertNotNull(name);
    Assertions.assertFalse(name.isPresent());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 3 with Column

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

the class ColumnEntityTest method shouldReturnsTheColumnNames.

@Test
public void shouldReturnsTheColumnNames() {
    List<Column> columns = asList(Column.of("name", 10), Column.of("name2", 11), Column.of("name3", 12), Column.of("name4", 13), Column.of("name5", 14), Column.of("name5", 16));
    ColumnEntity columnFamily = ColumnEntity.of("columnFamily", columns);
    assertThat(columnFamily.getColumnNames(), containsInAnyOrder("name", "name2", "name3", "name4", "name5"));
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 4 with Column

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

the class ColumnEntityTest method shouldAvoidDuplicatedColumn.

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

Example 5 with Column

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

the class ColumnEntityTest method shouldReturnFalseWhenDoesNotContainElement.

@Test
public void shouldReturnFalseWhenDoesNotContainElement() {
    List<Column> columns = asList(Column.of("name", 10), Column.of("name2", 11), Column.of("name3", 12), Column.of("name4", 13), Column.of("name5", 14), Column.of("name5", 16));
    ColumnEntity columnFamily = ColumnEntity.of("columnFamily", columns);
    assertFalse(columnFamily.contains("name6"));
    assertFalse(columnFamily.contains("name7"));
    assertFalse(columnFamily.contains("name8"));
    assertFalse(columnFamily.contains("name9"));
    assertFalse(columnFamily.contains("name10"));
}
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