Search in sources :

Example 31 with DocumentDeleteQuery

use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperDeleteBuilderTest method shouldQueryByEmbeddable.

@Test
public void shouldQueryByEmbeddable() {
    DocumentDeleteQuery query = mapperBuilder.deleteFrom(Worker.class).where("job.city").eq("Salvador").build();
    DocumentDeleteQuery queryExpected = delete().from("Worker").where("city").eq("Salvador").build();
    assertEquals(queryExpected, query);
}
Also used : Worker(jakarta.nosql.tck.entities.Worker) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 32 with DocumentDeleteQuery

use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperDeleteBuilderTest method shouldSelectWhereNameGte.

@Test
public void shouldSelectWhereNameGte() {
    DocumentDeleteQuery query = mapperBuilder.deleteFrom(Person.class).where("id").gte(10).build();
    DocumentDeleteQuery queryExpected = delete().from("Person").where("_id").gte(10L).build();
    assertEquals(queryExpected, query);
}
Also used : Person(jakarta.nosql.tck.entities.Person) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 33 with DocumentDeleteQuery

use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.

the class DefaultDocumentMapperDeleteBuilderTest method shouldReturnDeleteFrom.

@Test
public void shouldReturnDeleteFrom() {
    DocumentMapperDeleteFrom documentFrom = mapperBuilder.deleteFrom(Person.class);
    DocumentDeleteQuery query = documentFrom.build();
    DocumentDeleteQuery queryExpected = delete().from("Person").build();
    assertEquals(queryExpected, query);
}
Also used : DocumentMapperDeleteFrom(jakarta.nosql.mapping.document.DocumentQueryMapper.DocumentMapperDeleteFrom) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 34 with DocumentDeleteQuery

use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerTest method shouldRemoveEntity.

@Test
public void shouldRemoveEntity() {
    DocumentEntity documentEntity = entityManager.insert(getEntity());
    Document id = documentEntity.find("_key").get();
    DocumentQuery select = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    entityManager.delete(deleteQuery);
    assertTrue(entityManager.select(select).collect(Collectors.toList()).isEmpty());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) Document(jakarta.nosql.document.Document) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 35 with DocumentDeleteQuery

use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerTest method shouldRemoveEntity2.

@Test
public void shouldRemoveEntity2() {
    DocumentEntity documentEntity = entityManager.insert(getEntity());
    Document id = documentEntity.find("name").get();
    DocumentQuery select = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    entityManager.delete(deleteQuery);
    assertTrue(entityManager.select(select).collect(Collectors.toList()).isEmpty());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) Document(jakarta.nosql.document.Document) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)114 Test (org.junit.jupiter.api.Test)79 DocumentEntity (jakarta.nosql.document.DocumentEntity)45 DocumentQuery (jakarta.nosql.document.DocumentQuery)43 Document (jakarta.nosql.document.Document)37 DocumentCondition (jakarta.nosql.document.DocumentCondition)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 ValueSource (org.junit.jupiter.params.provider.ValueSource)20 List (java.util.List)15 Person (jakarta.nosql.tck.entities.Person)12 Collectors (java.util.stream.Collectors)7 Params (jakarta.nosql.Params)5 DocumentDeleteQueryParams (jakarta.nosql.document.DocumentDeleteQueryParams)5 Duration (java.time.Duration)5 HashMap (java.util.HashMap)5 Optional (java.util.Optional)5 StreamSupport (java.util.stream.StreamSupport)5 DocumentCollectionManager (jakarta.nosql.document.DocumentCollectionManager)4 DocumentQuery.select (jakarta.nosql.document.DocumentQuery.select)4 Map (java.util.Map)4