use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerAsyncTest method shouldUpdateIterableAsync.
@Test
public void shouldUpdateIterableAsync() throws InterruptedException {
Random random = new Random();
long id = random.nextLong();
AtomicBoolean condition = new AtomicBoolean(false);
AtomicReference<DocumentEntity> reference = new AtomicReference<>();
DocumentEntity entity = getEntity();
entity.add("_id", id);
entityManager.insert(entity, c -> {
condition.set(true);
reference.set(c);
});
await().untilTrue(condition);
entityManager.update(Collections.singletonList(entity));
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerAsyncTest method shouldRemoveEntity.
@Test
public void shouldRemoveEntity() {
AtomicReference<DocumentEntity> entityAtomic = new AtomicReference<>();
entityManager.insert(getEntity(), entityAtomic::set);
await().until(entityAtomic::get, notNullValue(DocumentEntity.class));
DocumentEntity entity = entityAtomic.get();
Document document = entity.find("name").get();
DocumentDeleteQuery deleteQuery = delete().from(entity.getName()).where(document.getName()).eq(document.get()).build();
entityManager.delete(deleteQuery);
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerAsyncTest method shouldUpdateAsync.
@Test
public void shouldUpdateAsync() throws InterruptedException {
Random random = new Random();
long id = random.nextLong();
AtomicBoolean condition = new AtomicBoolean(false);
AtomicReference<DocumentEntity> reference = new AtomicReference<>();
DocumentEntity entity = getEntity();
entity.add("_id", id);
entityManager.insert(entity, c -> {
condition.set(true);
reference.set(c);
});
await().untilTrue(condition);
entityManager.update(reference.get(), c -> condition.set(true));
assertTrue(condition.get());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerAsyncTest method shouldInsertAsync.
@Test
public void shouldInsertAsync() throws InterruptedException {
AtomicBoolean condition = new AtomicBoolean(false);
DocumentEntity entity = getEntity();
entityManager.insert(entity, c -> condition.set(true));
await().untilTrue(condition);
assertTrue(condition.get());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerAsyncTest 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;
}
Aggregations