use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerAsyncTest 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");
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 OrientDBDocumentCollectionManagerAsyncTest method shouldRemoveEntityAsyncWithoutCallback.
@Test
public void shouldRemoveEntityAsyncWithoutCallback() throws InterruptedException {
DocumentEntity entity = entityManager.insert(getEntity());
Document id = entity.find(OrientDBConverter.RID_FIELD).get();
DocumentQuery query = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
entityManagerAsync.delete(deleteQuery);
Thread.sleep(1000L);
assertTrue(entityManager.select(query).isEmpty());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerAsyncTest method shouldSaveAsync.
@Test
public void shouldSaveAsync() throws InterruptedException {
AtomicReference<DocumentEntity> entityAtomic = new AtomicReference<>();
entityManagerAsync.insert(getEntity(), entityAtomic::set);
await().until(entityAtomic::get, notNullValue(DocumentEntity.class));
DocumentEntity entity = entityAtomic.get();
Document id = entity.find("name").get();
DocumentQuery query = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
List<DocumentEntity> entities = entityManager.select(query);
assertFalse(entities.isEmpty());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerAsyncTest method shouldUpdateAsync.
@Test
public void shouldUpdateAsync() {
DocumentEntity entity = getEntity();
entityManager.insert(entity);
Document newField = Documents.of("newField", "10");
entity.add(newField);
entityManagerAsync.update(entity);
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerAsyncTest method shouldFindAsync.
@Test
public void shouldFindAsync() {
DocumentEntity entity = entityManager.insert(getEntity());
AtomicReference<List<DocumentEntity>> reference = new AtomicReference<>();
DocumentQuery query = select().from(COLLECTION_NAME).build();
entityManagerAsync.select(query, reference::set);
await().until(reference::get, notNullValue(List.class));
assertFalse(reference.get().isEmpty());
assertEquals(reference.get().get(0), entity);
}
Aggregations