Search in sources :

Example 91 with Column

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLt.

@Test
public void shouldSelectWhereNameLt() {
    String columnFamily = "columnFamily";
    Number value = 10;
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").lt(value).build();
    ColumnCondition columnCondition = query.getCondition().get();
    Column column = columnCondition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LESSER_THAN, columnCondition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(value, column.get());
}
Also used : Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 92 with Column

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String columnFamily = "columnFamily";
    Number valueA = 10;
    Number valueB = 20;
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").between(valueA, valueB).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", column.getName());
    assertThat(column.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : Column(jakarta.nosql.column.Column) TypeReference(jakarta.nosql.TypeReference) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 93 with Column

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameOr.

@Test
public void shouldSelectWhereNameOr() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").eq(name).or("age").gt(10).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
    });
    assertEquals(Condition.OR, condition.getCondition());
    assertThat(conditions, Matchers.containsInAnyOrder(ColumnCondition.eq(Column.of("name", name)), ColumnCondition.gt(Column.of("age", 10))));
}
Also used : Column(jakarta.nosql.column.Column) List(java.util.List) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 94 with Column

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameGte.

@Test
public void shouldSelectWhereNameGte() {
    String columnFamily = "columnFamily";
    Number value = 10;
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").gte(value).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.GREATER_EQUALS_THAN, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(value, column.get());
}
Also used : Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 95 with Column

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

the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameNot.

@Test
public void shouldSelectWhereNameNot() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnDeleteQuery query = delete().from(columnFamily).where("name").not().eq(name).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    ColumnCondition negate = column.get(ColumnCondition.class);
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.NOT, condition.getCondition());
    assertEquals(Condition.EQUALS, negate.getCondition());
    assertEquals("name", negate.getColumn().getName());
    assertEquals(name, negate.getColumn().get());
}
Also used : Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) 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