use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldReturnsTheDocumentValues.
@Test
public void shouldReturnsTheDocumentValues() {
List<Document> documents = asList(Document.of("name", 10), Document.of("name2", 11), Document.of("name3", 12), Document.of("name4", 13), Document.of("name5", 14), Document.of("name5", 16));
DocumentEntity collection = DocumentEntity.of("documentCollection", documents);
assertThat(collection.getValues(), containsInAnyOrder(Value.of(10), Value.of(11), Value.of(12), Value.of(13), Value.of(16)));
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldAddANewDocument.
@Test
public void shouldAddANewDocument() {
DocumentEntity entity = new DefaultDocumentEntity("name");
entity.add(Document.of("document", 12));
assertFalse(entity.isEmpty());
assertEquals(1, entity.size());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldAddDocumentAsNameAndObject.
@Test
public void shouldAddDocumentAsNameAndObject() {
DocumentEntity entity = new DefaultDocumentEntity("documentCollection");
entity.add("name", 10);
assertEquals(1, entity.size());
Optional<Document> name = entity.find("name");
assertTrue(name.isPresent());
assertEquals(10, name.get().get());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldConvertToMap.
@Test
public void shouldConvertToMap() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Map<String, Object> result = entity.toMap();
assertFalse(result.isEmpty());
assertEquals(Integer.valueOf(1), Integer.valueOf(result.size()));
assertEquals(document.getName(), result.keySet().stream().findAny().get());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldFindValue.
@Test
public void shouldFindValue() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Optional<String> name = entity.find("name", String.class);
Assertions.assertNotNull(name);
Assertions.assertTrue(name.isPresent());
Assertions.assertEquals("name", name.orElse(""));
}
Aggregations