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);
}
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;
}
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;
}
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());
}
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);
}
Aggregations