use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLt.
@Test
public void shouldSelectWhereNameLt() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnQuery query = select().from(columnFamily).where("name").lt(value).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.LESSER_THAN, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultColumnConditionTest method shouldAnd.
@Test
public void shouldAnd() {
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 and = eq.and(gt);
List<ColumnCondition> conditions = and.getColumn().get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.AND, and.getCondition());
assertThat(conditions, Matchers.containsInAnyOrder(eq, gt));
ColumnCondition result = and.and(lte);
assertEquals(Condition.AND, 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 DefaultColumnConditionTest method shouldCreateAnInstance.
@Test
public void shouldCreateAnInstance() {
Column name = Column.of("name", "Otavio");
ColumnCondition condition = DefaultColumnCondition.of(name, Condition.EQUALS);
assertNotNull(condition);
assertEquals(name, condition.getColumn());
assertEquals(Condition.EQUALS, condition.getCondition());
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class DefaultColumnConditionTest method shouldCreateAndCondition.
@Test
public void shouldCreateAndCondition() {
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.and(condition2);
Column andColumn = and.getColumn();
assertEquals(Condition.AND, and.getCondition());
assertEquals(Condition.AND.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 shouldCreateNegationCondition.
@Test
public void shouldCreateNegationCondition() {
Column age = Column.of("age", 26);
ColumnCondition condition = DefaultColumnCondition.of(age, Condition.GREATER_THAN);
ColumnCondition negate = condition.negate();
Column negateColumn = negate.getColumn();
assertEquals(Condition.NOT, negate.getCondition());
assertEquals(Condition.NOT.getNameField(), negateColumn.getName());
assertEquals(DefaultColumnCondition.of(age, Condition.GREATER_THAN), negateColumn.getValue().get());
}
Aggregations