Search in sources :

Example 71 with Column

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

the class ColumnTest method shouldCreateAnColumnInstance.

@Test
public void shouldCreateAnColumnInstance() {
    String name = "name";
    Column column = Column.of(name, DEFAULT_VALUE);
    assertNotNull(column);
    assertEquals(name, column.getName());
    assertEquals(DEFAULT_VALUE, column.getValue());
}
Also used : Column(jakarta.nosql.column.Column) Test(org.junit.jupiter.api.Test)

Example 72 with Column

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

the class DefaultColumnConditionTest method shouldCreateAnInstance.

@Test
public void shouldCreateAnInstance() {
    Column name = Column.of("name", "Otavio");
    ColumnCondition condition = DefaultColumnCondition.of(name, Condition.EQUALS);
    assertNotNull(condition);
    assertEquals(name, condition.getColumn());
    assertEquals(Condition.EQUALS, condition.getCondition());
}
Also used : Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 73 with Column

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

the class DefaultColumnConditionTest method shouldCreateAndCondition.

@Test
public void shouldCreateAndCondition() {
    Column age = Column.of("age", 26);
    Column name = Column.of("name", "Otavio");
    ColumnCondition condition1 = DefaultColumnCondition.of(name, Condition.EQUALS);
    ColumnCondition condition2 = DefaultColumnCondition.of(age, Condition.GREATER_THAN);
    ColumnCondition and = condition1.and(condition2);
    Column andColumn = and.getColumn();
    assertEquals(Condition.AND, and.getCondition());
    assertEquals(Condition.AND.getNameField(), andColumn.getName());
    assertThat(andColumn.getValue().get(new TypeReference<List<ColumnCondition>>() {
    }), Matchers.containsInAnyOrder(condition1, condition2));
}
Also used : Column(jakarta.nosql.column.Column) TypeReference(jakarta.nosql.TypeReference) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 74 with Column

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

the class DefaultColumnConditionTest method shouldCreateNegationCondition.

@Test
public void shouldCreateNegationCondition() {
    Column age = Column.of("age", 26);
    ColumnCondition condition = DefaultColumnCondition.of(age, Condition.GREATER_THAN);
    ColumnCondition negate = condition.negate();
    Column negateColumn = negate.getColumn();
    assertEquals(Condition.NOT, negate.getCondition());
    assertEquals(Condition.NOT.getNameField(), negateColumn.getName());
    assertEquals(DefaultColumnCondition.of(age, Condition.GREATER_THAN), negateColumn.getValue().get());
}
Also used : Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 75 with Column

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

the class DefaultColumnConditionTest method shouldCreateOrCondition.

@Test
public void shouldCreateOrCondition() {
    Column age = Column.of("age", 26);
    Column name = Column.of("name", "Otavio");
    ColumnCondition condition1 = DefaultColumnCondition.of(name, Condition.EQUALS);
    ColumnCondition condition2 = DefaultColumnCondition.of(age, Condition.GREATER_THAN);
    ColumnCondition and = condition1.or(condition2);
    Column andColumn = and.getColumn();
    assertEquals(Condition.OR, and.getCondition());
    assertEquals(Condition.OR.getNameField(), andColumn.getName());
    assertThat(andColumn.getValue().get(new TypeReference<List<ColumnCondition>>() {
    }), Matchers.containsInAnyOrder(condition1, condition2));
}
Also used : Column(jakarta.nosql.column.Column) TypeReference(jakarta.nosql.TypeReference) ColumnCondition(jakarta.nosql.column.ColumnCondition) 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