use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameNot.
@Test
public void shouldSelectWhereNameNot() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnQuery query = select().from(columnFamily).where("name").not().eq(name).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
ColumnCondition negate = column.get(ColumnCondition.class);
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.NOT, condition.getCondition());
assertEquals(Condition.EQUALS, negate.getCondition());
assertEquals("name", negate.getColumn().getName());
assertEquals(name, negate.getColumn().get());
}
use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameAnd.
@Test
public void shouldSelectWhereNameAnd() {
String columnFamily = "columnFamily";
String name = "Ada Lovelace";
ColumnQuery query = select().from(columnFamily).where("name").eq(name).and("age").gt(10).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.AND, condition.getCondition());
assertThat(conditions, containsInAnyOrder(eq(Column.of("name", name)), ColumnCondition.gt(Column.of("age", 10))));
}
use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectNegate.
@Test
public void shouldSelectNegate() {
String columnFamily = "columnFamily";
ColumnQuery query = select().from(columnFamily).where("city").not().eq("Assis").and("name").not().eq("Lucas").build();
ColumnCondition condition = query.getCondition().orElseThrow(RuntimeException::new);
assertEquals(columnFamily, query.getColumnFamily());
Column column = condition.getColumn();
List<ColumnCondition> conditions = column.get(new TypeReference<List<ColumnCondition>>() {
});
assertEquals(Condition.AND, condition.getCondition());
assertThat(conditions, containsInAnyOrder(eq(Column.of("city", "Assis")).negate(), eq(Column.of("name", "Lucas")).negate()));
}
use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameGte.
@Test
public void shouldSelectWhereNameGte() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnQuery query = select().from(columnFamily).where("name").gte(value).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.GREATER_EQUALS_THAN, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
use of jakarta.nosql.column.ColumnQuery 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());
}
Aggregations