Search in sources :

Example 96 with ColumnQuery

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

the class DefaultSelectQueryBuilderTest method shouldExecuteManager.

@Test
public void shouldExecuteManager() {
    ColumnFamilyManager manager = Mockito.mock(ColumnFamilyManager.class);
    ArgumentCaptor<ColumnQuery> queryCaptor = ArgumentCaptor.forClass(ColumnQuery.class);
    String columnFamily = "columnFamily";
    Stream<ColumnEntity> entities = select().from(columnFamily).getResult(manager);
    entities.collect(Collectors.toList());
    Mockito.verify(manager).select(queryCaptor.capture());
    checkQuery(queryCaptor, columnFamily);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Test(org.junit.jupiter.api.Test)

Example 97 with ColumnQuery

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

the class SelectQueryParser method prepare.

ColumnPreparedStatement prepare(String query, ColumnFamilyManager manager, ColumnObserverParser observer) {
    Params params = Params.newParams();
    SelectQuery selectQuery = selectQueryProvider.apply(query);
    ColumnQuery columnQuery = getColumnQuery(params, selectQuery, observer);
    return DefaultColumnPreparedStatement.select(columnQuery, params, query, manager);
}
Also used : SelectQuery(jakarta.nosql.query.SelectQuery) ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnQueryParams(jakarta.nosql.column.ColumnQueryParams) Params(jakarta.nosql.Params)

Example 98 with ColumnQuery

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

the class CassandraColumnFamilyManagerTest method shouldLimitResult.

@Test
public void shouldLimitResult() {
    getEntities().forEach(entityManager::insert);
    ColumnQuery query = select().from(Constants.COLUMN_FAMILY).where("id").in(Arrays.asList(1L, 2L, 3L)).limit(2).build();
    List<ColumnEntity> columnFamilyEntities = entityManager.select(query).collect(toList());
    assertEquals(Integer.valueOf(2), Integer.valueOf(columnFamilyEntities.size()));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 99 with ColumnQuery

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

the class CassandraColumnFamilyManagerTest method shouldFindByIdWithConsistenceLevel.

@Test
public void shouldFindByIdWithConsistenceLevel() {
    entityManager.insert(getColumnFamily());
    ColumnQuery query = select().from(Constants.COLUMN_FAMILY).where("id").eq(10L).build();
    List<ColumnEntity> columnEntity = entityManager.select(query, CONSISTENCY_LEVEL).collect(toList());
    assertFalse(columnEntity.isEmpty());
    List<Column> columns = columnEntity.get(0).getColumns();
    assertThat(columns.stream().map(Column::getName).collect(toList()), containsInAnyOrder("name", "version", "options", "id"));
    assertThat(columns.stream().map(Column::getValue).map(Value::get).collect(toList()), containsInAnyOrder("Cassandra", 3.2, asList(1, 2, 3), 10L));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Column(jakarta.nosql.column.Column) Value(jakarta.nosql.Value) Test(org.junit.jupiter.api.Test)

Example 100 with ColumnQuery

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

the class CassandraColumnFamilyManagerTest method shouldPaginate.

@Test
public void shouldPaginate() {
    for (long index = 1; index <= 10; index++) {
        ColumnEntity columnFamily = getColumnFamily();
        columnFamily.add("id", index);
        entityManager.insert(columnFamily);
    }
    ColumnQuery query = select().from(Constants.COLUMN_FAMILY).limit(4).skip(2).build();
    List<ColumnEntity> entities = entityManager.select(query).collect(toList());
    assertEquals(4, entities.size());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) 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