Search in sources :

Example 86 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectOrderDesc.

@Test
public void shouldSelectOrderDesc() {
    String columnFamily = "columnFamily";
    ColumnQuery query = select().from(columnFamily).orderBy("name").desc().build();
    assertTrue(query.getColumns().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(columnFamily, query.getColumnFamily());
    assertThat(query.getSorts(), contains(Sort.of("name", SortType.DESC)));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 87 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameOr.

@Test
public void shouldSelectWhereNameOr() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnQuery query = select().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, containsInAnyOrder(eq(Column.of("name", name)), ColumnCondition.gt(Column.of("age", 10))));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) List(java.util.List) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 88 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLte.

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

Example 89 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method checkQuery.

private void checkQuery(ArgumentCaptor<ColumnQuery> queryCaptor, String columnFamily) {
    ColumnQuery query = queryCaptor.getValue();
    assertTrue(query.getColumns().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(columnFamily, query.getColumnFamily());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery)

Example 90 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameGt.

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

Aggregations

ColumnQuery (jakarta.nosql.column.ColumnQuery)160 Test (org.junit.jupiter.api.Test)120 ColumnCondition (jakarta.nosql.column.ColumnCondition)64 Person (jakarta.nosql.tck.entities.Person)50 Column (jakarta.nosql.column.Column)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)30 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Pagination (jakarta.nosql.mapping.Pagination)27 ColumnEntity (jakarta.nosql.column.ColumnEntity)26 List (java.util.List)26 Collections.singletonList (java.util.Collections.singletonList)10 Value (jakarta.nosql.Value)8 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)8 Arrays.asList (java.util.Arrays.asList)8 Params (jakarta.nosql.Params)7 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)7 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)7 ColumnQueryParams (jakarta.nosql.column.ColumnQueryParams)7 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)6 SelectQuery (jakarta.nosql.query.SelectQuery)6