Search in sources :

Example 6 with DocumentEntity

use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerTest method shouldRunAQL.

@Test
public void shouldRunAQL() {
    DocumentEntity entity = getEntity();
    DocumentEntity entitySaved = entityManager.insert(entity);
    String aql = "FOR a IN person FILTER a.name == @name RETURN a";
    List<DocumentEntity> entities = entityManager.aql(aql, singletonMap("name", "Poliana"));
    assertNotNull(entities);
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Example 7 with DocumentEntity

use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerTest method createSubdocumentList.

private DocumentEntity createSubdocumentList() {
    DocumentEntity entity = DocumentEntity.of("AppointmentBook");
    entity.add(Document.of("_id", "ids"));
    List<List<Document>> documents = new ArrayList<>();
    documents.add(asList(Document.of("name", "Ada"), Document.of("type", ContactType.EMAIL), Document.of("information", "ada@lovelace.com")));
    documents.add(asList(Document.of("name", "Ada"), Document.of("type", ContactType.MOBILE), Document.of("information", "11 1231231 123")));
    documents.add(asList(Document.of("name", "Ada"), Document.of("type", ContactType.PHONE), Document.of("information", "phone")));
    entity.add(Document.of("contacts", documents));
    return entity;
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Arrays.asList(java.util.Arrays.asList)

Example 8 with DocumentEntity

use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerTest method getEntity.

private DocumentEntity getEntity() {
    DocumentEntity entity = DocumentEntity.of(COLLECTION_NAME);
    Map<String, Object> map = new HashMap<>();
    map.put("name", "Poliana");
    map.put("city", "Salvador");
    entity.add(Document.of(KEY_NAME, random.nextLong()));
    List<Document> documents = Documents.of(map);
    documents.forEach(entity::add);
    return entity;
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) HashMap(java.util.HashMap) Document(org.jnosql.diana.api.document.Document)

Example 9 with DocumentEntity

use of org.jnosql.diana.api.document.DocumentEntity 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).isEmpty());
}
Also used : DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Document(org.jnosql.diana.api.document.Document) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 10 with DocumentEntity

use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.

the class ArangoDBDocumentCollectionManagerTest method shouldConvertFromListSubdocumentList.

@Test
public void shouldConvertFromListSubdocumentList() {
    DocumentEntity entity = createSubdocumentList();
    entityManager.insert(entity);
}
Also used : DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Test(org.junit.jupiter.api.Test)

Aggregations

DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)205 Test (org.junit.jupiter.api.Test)167 Document (org.jnosql.diana.api.document.Document)107 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)101 List (java.util.List)63 DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)47 Arrays.asList (java.util.Arrays.asList)38 ArrayList (java.util.ArrayList)36 AtomicReference (java.util.concurrent.atomic.AtomicReference)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)25 Duration (java.time.Duration)22 HashMap (java.util.HashMap)21 Consumer (java.util.function.Consumer)19 Arrays (java.util.Arrays)17 Collectors (java.util.stream.Collectors)17 DocumentQueryBuilder.select (org.jnosql.diana.api.document.query.DocumentQueryBuilder.select)17 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)16 Map (java.util.Map)15 Optional (java.util.Optional)15 BeforeEach (org.junit.jupiter.api.BeforeEach)15