use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class ColumnEntityTest method shouldFindTypeSupplier.
@Test
public void shouldFindTypeSupplier() {
Column column = Column.of("name", "name");
ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
List<String> names = entity.find("name", new TypeReference<List<String>>() {
}).orElse(Collections.emptyList());
Assertions.assertNotNull(names);
Assertions.assertFalse(names.isEmpty());
MatcherAssert.assertThat(names, Matchers.contains("name"));
}
use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameBetween.
@Test
public void shouldSelectWhereNameBetween() {
String columnFamily = "columnFamily";
Number valueA = 10;
Number valueB = 20;
ColumnQuery query = select().from(columnFamily).where("name").between(valueA, valueB).build();
ColumnCondition condition = query.getCondition().get();
Column column = condition.getColumn();
assertTrue(query.getColumns().isEmpty());
assertEquals(columnFamily, query.getColumnFamily());
assertEquals(Condition.BETWEEN, condition.getCondition());
assertEquals("name", column.getName());
assertThat(column.get(new TypeReference<List<Number>>() {
}), Matchers.contains(10, 20));
}
use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class ColumnTest method shouldReturnGetType.
@Test
public void shouldReturnGetType() {
Value value = Value.of("text");
Column column = Column.of("name", value);
TypeReference<List<String>> typeReference = new TypeReference<List<String>>() {
};
assertEquals(value.get(typeReference), column.get(typeReference));
}
use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class DefaultDocumentConditionTest method shouldCreateOrCondition.
@Test
public void shouldCreateOrCondition() {
Document age = Document.of("age", 26);
Document name = Document.of("name", "Otavio");
DocumentCondition condition1 = DefaultDocumentCondition.of(name, Condition.EQUALS);
DocumentCondition condition2 = DefaultDocumentCondition.of(age, Condition.GREATER_THAN);
DocumentCondition and = condition1.or(condition2);
Document andDocument = and.getDocument();
assertEquals(Condition.OR, and.getCondition());
assertEquals(Condition.OR.getNameField(), andDocument.getName());
assertThat(andDocument.getValue().get(new TypeReference<List<DocumentCondition>>() {
}), Matchers.containsInAnyOrder(condition1, condition2));
}
use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class DefaultDocumentConditionTest method shouldAnd.
@Test
public void shouldAnd() {
DocumentCondition eq = DocumentCondition.eq(Document.of("name", "otavio"));
DocumentCondition gt = DocumentCondition.gt(Document.of("age", 10));
DocumentCondition lte = DocumentCondition.lte(Document.of("salary", 10_000.00));
DocumentCondition and = eq.and(gt);
List<DocumentCondition> conditions = and.getDocument().get(new TypeReference<List<DocumentCondition>>() {
});
assertEquals(Condition.AND, and.getCondition());
assertThat(conditions, Matchers.containsInAnyOrder(eq, gt));
DocumentCondition result = and.and(lte);
assertEquals(Condition.AND, result.getCondition());
assertThat(result.getDocument().get(new TypeReference<List<DocumentCondition>>() {
}), Matchers.containsInAnyOrder(eq, gt, lte));
}
Aggregations