Search in sources :

Example 76 with Column

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

the class DefaultColumnConditionTest method shouldReturnErrorWhenBetweenIsNotIterable.

@Test
public void shouldReturnErrorWhenBetweenIsNotIterable() {
    assertThrows(IllegalArgumentException.class, () -> {
        Column column = Column.of("age", 12);
        ColumnCondition.between(column);
    });
}
Also used : Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 77 with Column

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

the class DefaultColumnConditionTest method shouldReturnErrorWhenIterableHasMoreThanTwoElement2.

@Test
public void shouldReturnErrorWhenIterableHasMoreThanTwoElement2() {
    assertThrows(IllegalArgumentException.class, () -> {
        Column column = Column.of("age", Arrays.asList(12, 12, 12));
        ColumnCondition.between(column);
    });
}
Also used : Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 78 with Column

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

the class DefaultColumnEntity method toMap.

@Override
public Map<String, Object> toMap() {
    Map<String, Object> map = new HashMap<>();
    for (Map.Entry<String, Column> entry : columns.entrySet()) {
        Column column = entry.getValue();
        map.put(entry.getKey(), convert(column.get()));
    }
    return Collections.unmodifiableMap(map);
}
Also used : HashMap(java.util.HashMap) Column(jakarta.nosql.column.Column) HashMap(java.util.HashMap) Map(java.util.Map)

Example 79 with Column

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

the class ConditionQueryParser method getEntity.

protected ColumnEntity getEntity(ConditionQuerySupplier query, String columnFamily, Params params, ColumnObserverParser observer) {
    ColumnEntity entity = ColumnEntity.of(columnFamily);
    if (query.useJSONCondition()) {
        JSONQueryValue jsonValue = query.getValue().orElseThrow(() -> new QueryException("It is an invalid state of" + " either Update or Insert."));
        List<Column> columns = JsonObjects.getColumns(jsonValue.get());
        entity.addAll(columns);
        return entity;
    }
    query.getConditions().stream().map(c -> Conditions.getCondition(c, params, observer, columnFamily)).map(ColumnCondition::getColumn).forEach(entity::add);
    return entity;
}
Also used : QueryException(jakarta.nosql.QueryException) ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) JSONQueryValue(jakarta.nosql.query.JSONQueryValue)

Example 80 with Column

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

the class DefaultColumnCondition method or.

@Override
public ColumnCondition or(ColumnCondition condition) {
    validateReadOnly();
    requireNonNull(condition, "Condition is required");
    if (Condition.OR.equals(this.condition)) {
        Column newColumn = getConditions(condition, Condition.OR);
        return new DefaultColumnCondition(newColumn, Condition.OR);
    }
    return DefaultColumnCondition.or(this, condition);
}
Also used : Column(jakarta.nosql.column.Column)

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