Search in sources :

Example 86 with DocumentQuery

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

the class DefaultCouchDBDocumentCollectionManagerTest method shouldRemoveEntityByName.

@Test
public void shouldRemoveEntityByName() {
    DocumentEntity entity = getEntity();
    entity.remove(CouchDBConstant.ID);
    entity = entityManager.insert(entity);
    Document name = entity.find("name").get();
    DocumentQuery query = select().from(COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
    DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(name.getName()).eq(name.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 87 with DocumentQuery

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

the class MangoQueryConverterTest method shouldSelectFromLtAge.

@ParameterizedTest
@JsonSource("select_from_lt_order.json")
public void shouldSelectFromLtAge(JsonObject expected) {
    DocumentQuery query = select().from("person").where("age").lt(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 88 with DocumentQuery

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

the class MangoQueryConverterTest method shouldReturnSelectFieldsLimitSkip.

@ParameterizedTest
@JsonSource("select_fields_skip_start.json")
public void shouldReturnSelectFieldsLimitSkip(JsonObject expected) {
    DocumentQuery query = select("_id", "_rev").from("person").limit(10).skip(2).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 89 with DocumentQuery

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

the class MangoQueryConverterTest method shouldReturnSelectFromAllBookmark.

@ParameterizedTest
@JsonSource("select_all.json")
public void shouldReturnSelectFromAllBookmark(JsonObject expected) {
    DocumentQuery query = select().from("person").build();
    JsonObject jsonObject = converter.apply(CouchDBDocumentQuery.of(query));
    assertEquals(expected, jsonObject);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) JsonObject(javax.json.JsonObject) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 90 with DocumentQuery

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

the class MangoQueryConverterTest method shouldReturnSelectFromOrder.

@ParameterizedTest
@JsonSource("select_from_order.json")
public void shouldReturnSelectFromOrder(JsonObject expected) {
    DocumentQuery query = select().from("person").orderBy("year").asc().orderBy("name").desc().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)

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