use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldFindTypeSupplier.
@Test
public void shouldFindTypeSupplier() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
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 DefaultDeleteQueryBuilderTest method shouldSelectWhereNameBetween.
@Test
public void shouldSelectWhereNameBetween() {
String columnFamily = "columnFamily";
Number valueA = 10;
Number valueB = 20;
ColumnDeleteQuery query = delete().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 DefaultValueTest method shouldConvertToSingletonSet.
@Test
public void shouldConvertToSingletonSet() {
Long number = 10L;
Value value = Value.of(number);
assertThat(value.get(new TypeReference<Set<String>>() {
}), containsInAnyOrder("10"));
assertThat(value.get(new TypeReference<List<Long>>() {
}), containsInAnyOrder(10L));
}
use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class DefaultValueTest method shouldConvertToSet.
@Test
public void shouldConvertToSet() {
Value value = Value.of(Arrays.asList(10, 20, 30));
assertThat(value.get(new TypeReference<Set<String>>() {
}), containsInAnyOrder("10", "20", "30"));
assertThat(value.get(new TypeReference<List<BigInteger>>() {
}), containsInAnyOrder(BigInteger.TEN, BigInteger.valueOf(20L), BigInteger.valueOf(30L)));
}
use of jakarta.nosql.TypeReference in project jnosql-diana by eclipse.
the class DefaultColumnEntityConverterTest method shouldConvertSubEntity.
@Test
public void shouldConvertSubEntity() {
ZipCode zipcode = new ZipCode();
zipcode.setZip("12321");
zipcode.setPlusFour("1234");
Address address = new Address();
address.setCity("Salvador");
address.setState("Bahia");
address.setStreet("Rua Engenheiro Jose Anasoh");
address.setZipCode(zipcode);
ColumnEntity columnEntity = converter.toColumn(address);
List<Column> columns = columnEntity.getColumns();
assertEquals("Address", columnEntity.getName());
assertEquals(4, columns.size());
List<Column> zip = columnEntity.find("zipCode").map(d -> d.get(new TypeReference<List<Column>>() {
})).orElse(Collections.emptyList());
assertEquals("Rua Engenheiro Jose Anasoh", getValue(columnEntity.find("street")));
assertEquals("Salvador", getValue(columnEntity.find("city")));
assertEquals("Bahia", getValue(columnEntity.find("state")));
assertEquals("12321", getValue(zip.stream().filter(d -> d.getName().equals("zip")).findFirst()));
assertEquals("1234", getValue(zip.stream().filter(d -> d.getName().equals("plusFour")).findFirst()));
}
Aggregations