Search in sources :

Example 16 with DocumentEntity

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());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Example 17 with DocumentEntity

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);
    });
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Document(jakarta.nosql.document.Document) Test(org.junit.jupiter.api.Test)

Example 18 with DocumentEntity

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());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Document(jakarta.nosql.document.Document) Test(org.junit.jupiter.api.Test)

Example 19 with DocumentEntity

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());
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Example 20 with DocumentEntity

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);
    });
}
Also used : DocumentEntity(jakarta.nosql.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentEntity (jakarta.nosql.document.DocumentEntity)312 Test (org.junit.jupiter.api.Test)238 DocumentQuery (jakarta.nosql.document.DocumentQuery)131 Document (jakarta.nosql.document.Document)129 DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)62 List (java.util.List)54 Arrays.asList (java.util.Arrays.asList)51 ArrayList (java.util.ArrayList)46 Duration (java.time.Duration)31 HashMap (java.util.HashMap)30 Map (java.util.Map)27 Collectors (java.util.stream.Collectors)27 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)25 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 ValueSource (org.junit.jupiter.params.provider.ValueSource)23 TypeReference (jakarta.nosql.TypeReference)21 DocumentQuery.select (jakarta.nosql.document.DocumentQuery.select)21 Matchers.contains (org.hamcrest.Matchers.contains)21 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)21