Search in sources :

Example 26 with DocumentDeleteQuery

use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana 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(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 27 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldSelectWhereNameBetween.

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

Example 28 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldExecuteDelete.

@Test
public void shouldExecuteDelete() {
    DocumentTemplate template = Mockito.mock(DocumentTemplate.class);
    ArgumentCaptor<DocumentDeleteQuery> queryCaptor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
    mapperBuilder.deleteFrom(Person.class).delete(template);
    Mockito.verify(template).delete(queryCaptor.capture());
    DocumentDeleteQuery query = queryCaptor.getValue();
    DocumentDeleteQuery queryExpected = delete().from("Person").build();
    assertEquals(queryExpected, query);
}
Also used : DocumentTemplate(jakarta.nosql.mapping.document.DocumentTemplate) Person(jakarta.nosql.tck.entities.Person) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 29 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldUseAttributeConverter.

@Test
public void shouldUseAttributeConverter() {
    DocumentDeleteQuery query = mapperBuilder.deleteFrom(Worker.class).where("salary").eq(new Money("USD", BigDecimal.TEN)).build();
    DocumentDeleteQuery queryExpected = delete().from("Worker").where("money").eq("USD 10").build();
    assertEquals(queryExpected, query);
}
Also used : Money(jakarta.nosql.tck.entities.Money) Worker(jakarta.nosql.tck.entities.Worker) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 30 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldQueryBySubEntity.

@Test
public void shouldQueryBySubEntity() {
    DocumentDeleteQuery query = mapperBuilder.deleteFrom(Address.class).where("zipCode.zip").eq("01312321").build();
    DocumentDeleteQuery queryExpected = delete().from("Address").where("zipCode.zip").eq("01312321").build();
    assertEquals(queryExpected, query);
}
Also used : Address(jakarta.nosql.tck.entities.Address) 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