Search in sources :

Example 86 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldSelectWhereNameLt.

@Test
public void shouldSelectWhereNameLt() {
    DocumentDeleteQuery query = mapperBuilder.deleteFrom(Person.class).where("id").lt(10).build();
    DocumentDeleteQuery queryExpected = delete().from("Person").where("_id").lt(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 87 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldSelectWhereNameAnd.

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

Example 88 with DocumentDeleteQuery

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

the class DefaultDocumentMapperDeleteBuilderTest method shouldSelectWhereNameOr.

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

Example 89 with DocumentDeleteQuery

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

the class RavenDBDocumentCollectionManagerTest method shouldFindDocumentLesserThan.

@Test
public void shouldFindDocumentLesserThan() {
    DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("type").eq("V").build();
    entityManager.delete(deleteQuery);
    Iterable<DocumentEntity> entitiesSaved = entityManager.insert(getEntitiesWithValues());
    List<DocumentEntity> entities = StreamSupport.stream(entitiesSaved.spliterator(), false).collect(Collectors.toList());
    DocumentQuery query = select().from(COLLECTION_NAME).where("age").lt(23).and("type").eq("V").build();
    List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
    assertEquals(1, entitiesFound.size());
    assertThat(entitiesFound, contains(entities.get(0)));
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) DocumentDeleteQuery(jakarta.nosql.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 90 with DocumentDeleteQuery

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

the class DocumentRepositoryProxyTest method shouldDeleteByName.

@Test
public void shouldDeleteByName() {
    ArgumentCaptor<DocumentDeleteQuery> captor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
    personRepository.deleteByName("Ada");
    verify(template).delete(captor.capture());
    DocumentDeleteQuery deleteQuery = captor.getValue();
    DocumentCondition condition = deleteQuery.getCondition().get();
    assertEquals("Person", deleteQuery.getDocumentCollection());
    assertEquals(Condition.EQUALS, condition.getCondition());
    assertEquals(Document.of("name", "Ada"), condition.getDocument());
}
Also used : DocumentCondition(jakarta.nosql.document.DocumentCondition) 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