use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class AbstractMapperQuery method ltImpl.
protected <T> void ltImpl(T value) {
requireNonNull(value, "value is required");
ColumnCondition newCondition = ColumnCondition.lt(Column.of(mapping.getColumnField(name), getValue(value)));
appendCondition(newCondition);
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class ColumnRepositoryProxySortTest method shouldFindByNameOrderByName2.
@Test
public void shouldFindByNameOrderByName2() {
when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of((Person.builder().build())));
Pagination pagination = getPagination();
personRepository.findByNameOrderByName("name", pagination, Sorts.sorts().desc("age").asc("phone"));
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(EQUALS, condition.getCondition());
assertEquals(Column.of("name", "name"), condition.getColumn());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
assertThat(query.getSorts(), Matchers.contains(Sort.asc("name"), Sort.desc("age"), Sort.asc("phone")));
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManager method select.
@Override
public Stream<ColumnEntity> select(ColumnQuery query) {
Objects.requireNonNull(query, "query is required");
ColumnCondition condition = query.getCondition().orElseThrow(() -> new IllegalArgumentException("Condition is required"));
checkedCondition(condition);
return Stream.of(findById(condition)).map(EntityUnit::new).filter(EntityUnit::isNotEmpty).map(EntityUnit::toEntity);
}
use of jakarta.nosql.column.ColumnCondition 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))));
}
use of jakarta.nosql.column.ColumnCondition 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());
}
Aggregations