Search in sources :

Example 61 with DocumentDeleteQuery

use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerAsyncTest method shouldRemoveEntityAsync.

@Test
public void shouldRemoveEntityAsync() {
    DocumentEntity documentEntity = entityManager.insert(getEntity());
    Document id = documentEntity.find(KEY_NAME).get();
    DocumentDeleteQuery query = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    entityManagerAsync.delete(query);
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Document(org.jnosql.diana.api.document.Document) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 62 with DocumentDeleteQuery

use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.

the class DefaultDocumentTemplateAsyncTest method shouldDeleteByEntity.

@Test
public void shouldDeleteByEntity() {
    subject.delete(Person.class, 10L);
    ArgumentCaptor<DocumentDeleteQuery> queryCaptor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
    verify(managerMock).delete(queryCaptor.capture());
    DocumentDeleteQuery query = queryCaptor.getValue();
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(DocumentCondition.eq(Document.of("_id", 10L)), query.getCondition().get());
}
Also used : DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 63 with DocumentDeleteQuery

use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.

the class DefaultDocumentTemplateAsyncTest method shouldDelete.

@Test
public void shouldDelete() {
    DocumentDeleteQuery query = delete().from("delete").build();
    subject.delete(query);
    verify(managerMock).delete(query);
}
Also used : DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 64 with DocumentDeleteQuery

use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.

the class DefaultDocumentTemplateTest method shouldDelete.

@Test
public void shouldDelete() {
    DocumentDeleteQuery query = delete().from("delete").build();
    subject.delete(query);
    verify(managerMock).delete(query);
}
Also used : DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 65 with DocumentDeleteQuery

use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-artemis by eclipse.

the class DefaultDocumentTemplateTest method shouldDeleteEntity.

@Test
public void shouldDeleteEntity() {
    subject.delete(Person.class, "10");
    ArgumentCaptor<DocumentDeleteQuery> queryCaptor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
    verify(managerMock).delete(queryCaptor.capture());
    DocumentDeleteQuery query = queryCaptor.getValue();
    DocumentCondition condition = query.getCondition().get();
    assertEquals("Person", query.getDocumentCollection());
    assertEquals(DocumentCondition.eq(Document.of("_id", 10L)), condition);
}
Also used : DocumentCondition(org.jnosql.diana.api.document.DocumentCondition) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)86 Test (org.junit.jupiter.api.Test)74 Document (org.jnosql.diana.api.document.Document)35 DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)31 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)31 DocumentCondition (org.jnosql.diana.api.document.DocumentCondition)20 List (java.util.List)15 Person (org.jnosql.artemis.model.Person)13 Duration (java.time.Duration)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 Optional (java.util.Optional)4 Consumer (java.util.function.Consumer)4 Collectors (java.util.stream.Collectors)4 DocumentQueryBuilder.delete (org.jnosql.diana.api.document.query.DocumentQueryBuilder.delete)4 DocumentQueryBuilder.select (org.jnosql.diana.api.document.query.DocumentQueryBuilder.select)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)4 Arrays (java.util.Arrays)3