use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldRemoveByName.
@Test
public void shouldRemoveByName() {
DocumentEntity entity = new DefaultDocumentEntity("name");
entity.add(Document.of("value", 32D));
assertTrue(entity.remove("value"));
assertTrue(entity.isEmpty());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldReturnErrorWhenFindDocumentIsNull.
@Test
public void shouldReturnErrorWhenFindDocumentIsNull() {
Assertions.assertThrows(NullPointerException.class, () -> {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
entity.find(null);
});
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldFindDocument.
@Test
public void shouldFindDocument() {
Document document = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(document));
Optional<Document> name = entity.find("name");
Optional<Document> notfound = entity.find("not_found");
assertTrue(name.isPresent());
assertFalse(notfound.isPresent());
assertEquals(document, name.get());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldAddAllDocuments.
@Test
public void shouldAddAllDocuments() {
DocumentEntity entity = new DefaultDocumentEntity("name");
entity.addAll(asList(Document.of("name", 12), Document.of("value", "value")));
assertFalse(entity.isEmpty());
assertEquals(2, entity.size());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana by eclipse.
the class DocumentEntityTest method shouldReturnErrorWhenAddDocumentsObjectWhenHasNullObject.
@Test
public void shouldReturnErrorWhenAddDocumentsObjectWhenHasNullObject() {
Assertions.assertThrows(NullPointerException.class, () -> {
DocumentEntity entity = new DefaultDocumentEntity("documentCollection");
entity.add("name", null);
});
}
Aggregations