use of jakarta.nosql.column.Column in project jnosql-diana by eclipse.
the class ColumnsTest method shouldCreateRecursiveMap.
@Test
public void shouldCreateRecursiveMap() {
List<List<Map<String, String>>> list = new ArrayList<>();
Map<String, String> map = singletonMap("mobile", "55 1234-4567");
list.add(singletonList(map));
List<Column> columns = Columns.of(singletonMap("contact", list));
assertEquals(1, columns.size());
Column column = columns.get(0);
assertEquals("contact", column.getName());
List<List<Column>> result = (List<List<Column>>) column.get();
assertEquals(Column.of("mobile", "55 1234-4567"), result.get(0).get(0));
}
use of jakarta.nosql.column.Column 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.Column 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());
}
use of jakarta.nosql.column.Column in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameGt.
@Test
public void shouldSelectWhereNameGt() {
String columnFamily = "columnFamily";
Number value = 10;
ColumnQuery query = select().from(columnFamily).where("name").gt(value).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.GREATER_THAN, condition.getCondition());
assertEquals("name", column.getName());
assertEquals(value, column.get());
}
use of jakarta.nosql.column.Column 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());
}
Aggregations