Search in sources :

Example 71 with DocumentQuery

use of jakarta.nosql.document.DocumentQuery 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)

Example 72 with DocumentQuery

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

the class ArangoDBDocumentCollectionManagerTest method shouldReadFromDifferentBaseDocumentUsingInstance.

@Test
public void shouldReadFromDifferentBaseDocumentUsingInstance() {
    entityManager.insert(getEntity());
    ArangoDB arangoDB = DefaultArangoDBDocumentCollectionManager.class.cast(entityManager).getArangoDB();
    arangoDB.db(DATABASE).collection(COLLECTION_NAME).insertDocument(new Person());
    DocumentQuery select = select().from(COLLECTION_NAME).build();
    List<DocumentEntity> entities = entityManager.select(select).collect(Collectors.toList());
    assertFalse(entities.isEmpty());
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) ArangoDB(com.arangodb.ArangoDB) DocumentEntity(jakarta.nosql.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Example 73 with DocumentQuery

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

the class QueryAQLConverterTest method shouldRunEqualsQuerySort2.

@Test
public void shouldRunEqualsQuerySort2() {
    DocumentQuery query = select().from("collection").where("name").eq("value").orderBy("name").asc().orderBy("age").desc().build();
    AQLQueryResult convert = QueryAQLConverter.select(query);
    String aql = convert.getQuery();
    Map<String, Object> values = convert.getValues();
    assertEquals("value", values.get("name"));
    assertEquals("FOR c IN collection FILTER  c.name == @name SORT  c.name ASC , c.age DESC RETURN c", aql);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 74 with DocumentQuery

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

the class QueryAQLConverterTest method shouldRunEqualsQuerySort.

@Test
public void shouldRunEqualsQuerySort() {
    DocumentQuery query = select().from("collection").where("name").eq("value").orderBy("name").asc().build();
    AQLQueryResult convert = QueryAQLConverter.select(query);
    String aql = convert.getQuery();
    Map<String, Object> values = convert.getValues();
    assertEquals("value", values.get("name"));
    assertEquals("FOR c IN collection FILTER  c.name == @name SORT  c.name ASC RETURN c", aql);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Test(org.junit.jupiter.api.Test)

Example 75 with DocumentQuery

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

the class QueryAQLConverterTest method shouldRunEqualsQueryLimit2.

@Test
public void shouldRunEqualsQueryLimit2() {
    DocumentQuery query = select().from("collection").where("name").eq("value").skip(1).limit(5).build();
    AQLQueryResult convert = QueryAQLConverter.select(query);
    String aql = convert.getQuery();
    Map<String, Object> values = convert.getValues();
    assertEquals("value", values.get("name"));
    assertEquals("FOR c IN collection FILTER  c.name == @name LIMIT 1, 5 RETURN c", aql);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) 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