use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultColumnConditionTest method shouldCreateOrCondition.
@Test
public void shouldCreateOrCondition() {
Column age = Column.of("age", 26);
Column name = Column.of("name", "Otavio");
ColumnCondition condition1 = DefaultColumnCondition.of(name, Condition.EQUALS);
ColumnCondition condition2 = DefaultColumnCondition.of(age, Condition.GREATER_THAN);
ColumnCondition and = condition1.or(condition2);
Column andColumn = and.getColumn();
assertEquals(Condition.OR, and.getCondition());
assertEquals(Condition.OR.getNameField(), andColumn.getName());
assertThat(andColumn.getValue().get(new TypeReference<List<ColumnCondition>>() {
}), Matchers.containsInAnyOrder(condition1, condition2));
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultColumnConditionTest method shouldAffirmDoubleNegate.
@Test
public void shouldAffirmDoubleNegate() {
ColumnCondition eq = ColumnCondition.eq(Column.of("name", "otavio"));
ColumnCondition affirm = eq.negate().negate();
assertEquals(eq.getCondition(), affirm.getCondition());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultColumnConditionTest method shouldOr.
@Test
public void shouldOr() {
ColumnCondition eq = ColumnCondition.eq(Column.of("name", "otavio"));
ColumnCondition gt = ColumnCondition.gt(Column.of("age", 10));
ColumnCondition lte = ColumnCondition.lte(Column.of("salary", 10_000.00));
ColumnCondition or = eq.or(gt);
List<ColumnCondition> conditions = or.getColumn().get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.OR, or.getCondition());
assertThat(conditions, Matchers.containsInAnyOrder(eq, gt));
ColumnCondition result = or.or(lte);
assertEquals(Condition.OR, result.getCondition());
assertThat(result.getColumn().get(new TypeReference<List<ColumnCondition>>() {
}), Matchers.containsInAnyOrder(eq, gt, lte));
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class BaseQueryBuilder method appendCondition.
protected void appendCondition(ColumnCondition newCondition) {
ColumnCondition columnCondition = getColumnCondition(newCondition);
if (nonNull(condition)) {
if (and) {
this.condition = condition.and(columnCondition);
} else {
this.condition = condition.or(columnCondition);
}
} else {
this.condition = columnCondition;
}
this.negate = false;
this.name = null;
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class BaseQueryBuilder method gteImpl.
protected <T> void gteImpl(T value) {
requireNonNull(value, "value is required");
ColumnCondition newCondition = ColumnCondition.gte(Column.of(name, value));
appendCondition(newCondition);
}
Aggregations