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);
}
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);
}
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()));
}
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));
}
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());
}
Aggregations