Search in sources :

Example 91 with DocumentQuery

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

the class MangoQueryConverterTest method shouldSelectFromLteAge.

@ParameterizedTest
@JsonSource("select_from_lte_order.json")
public void shouldSelectFromLteAge(JsonObject expected) {
    DocumentQuery query = select().from("person").where("age").lte(10).build();
    JsonObject jsonObject = converter.apply(query);
    assertEquals(expected, jsonObject);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) JsonObject(javax.json.JsonObject) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 92 with DocumentQuery

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

the class MangoQueryConverterTest method shouldSelectFromOrAge.

@ParameterizedTest
@JsonSource("select_from_or_order.json")
public void shouldSelectFromOrAge(JsonObject expected) {
    DocumentQuery query = select().from("person").where("name").eq("Poliana").or("name").eq("Ada").build();
    JsonObject jsonObject = converter.apply(query);
    assertEquals(expected, jsonObject);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) JsonObject(javax.json.JsonObject) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 93 with DocumentQuery

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

the class ElasticsearchDocumentCollectionManagerTest method shouldFindAll.

@Test
public void shouldFindAll() throws InterruptedException {
    entityManager.insert(DocumentEntityGerator.getEntity());
    DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).build();
    SECONDS.sleep(1L);
    List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
    assertFalse(entities.isEmpty());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Example 94 with DocumentQuery

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

the class ElasticsearchDocumentCollectionManagerTest method shouldRemoveEntityById.

@Test
public void shouldRemoveEntityById() {
    DocumentEntity documentEntity = entityManager.insert(DocumentEntityGerator.getEntity());
    Document id = documentEntity.find("_id").get();
    DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    DocumentDeleteQuery deleteQuery = delete().from(DocumentEntityGerator.COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
    entityManager.delete(deleteQuery);
    assertTrue(entityManager.select(query).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 95 with DocumentQuery

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

the class ElasticsearchDocumentCollectionManagerTest method shouldRemoveEntityByName.

@Test
public void shouldRemoveEntityByName() throws InterruptedException {
    DocumentEntity documentEntity = entityManager.insert(DocumentEntityGerator.getEntity());
    Document name = documentEntity.find("name").get();
    DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
    DocumentDeleteQuery deleteQuery = delete().from(DocumentEntityGerator.COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
    SECONDS.sleep(1L);
    entityManager.delete(deleteQuery);
    SECONDS.sleep(1L);
    List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
    System.out.println(entities);
    assertTrue(entities.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

DocumentQuery (jakarta.nosql.document.DocumentQuery)292 Test (org.junit.jupiter.api.Test)234 DocumentEntity (jakarta.nosql.document.DocumentEntity)123 Document (jakarta.nosql.document.Document)98 DocumentCondition (jakarta.nosql.document.DocumentCondition)64 DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)55 Person (jakarta.nosql.tck.entities.Person)50 List (java.util.List)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)44 Arrays.asList (java.util.Arrays.asList)34 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Pagination (jakarta.nosql.mapping.Pagination)27 ArrayList (java.util.ArrayList)26 Collectors (java.util.stream.Collectors)19 DocumentQuery.select (jakarta.nosql.document.DocumentQuery.select)18 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)16 Matchers.contains (org.hamcrest.Matchers.contains)16 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)16 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)16 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)16