use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerAsyncTest method shouldRemoveEntityAsync.
@Test
public void shouldRemoveEntityAsync() throws InterruptedException {
DocumentEntity documentEntity = entityManager.insert(getEntity());
Document id = documentEntity.find("name").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(1_000L);
assertTrue(entityManager.select(query).isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldRemoveEntityById.
@Test
public void shouldRemoveEntityById() {
DocumentEntity documentEntity = entityManager.insert(getEntity());
Document id = documentEntity.find("_id").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();
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldRemoveEntityByName.
@Test
public void shouldRemoveEntityByName() throws InterruptedException {
DocumentEntity documentEntity = entityManager.insert(getEntity());
Document name = documentEntity.find("name").get();
DocumentQuery query = select().from(COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
TimeUnit.SECONDS.sleep(1L);
entityManager.delete(deleteQuery);
TimeUnit.SECONDS.sleep(1L);
List<DocumentEntity> entities = entityManager.select(query);
System.out.println(entities);
assertTrue(entities.isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerAsyncTest method shouldRemoveEntityAsync.
@Test
public void shouldRemoveEntityAsync() throws InterruptedException {
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();
assertNotNull(entity);
assertNotNull(document);
String collection = entity.getName();
DocumentDeleteQuery deleteQuery = delete().from(collection).where("name").eq(document.get()).build();
AtomicBoolean condition = new AtomicBoolean(false);
entityManager.delete(deleteQuery, c -> condition.set(true));
await().untilTrue(condition);
AtomicBoolean selectCondition = new AtomicBoolean(false);
AtomicReference<List<DocumentEntity>> reference = new AtomicReference<>();
DocumentQuery selectQuery = select().from(collection).where("name").eq(document.get()).build();
entityManager.select(selectQuery, c -> {
selectCondition.set(true);
reference.set(c);
});
await().untilTrue(selectCondition);
assertTrue(reference.get().isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class CouchbaseDocumentCollectionManagerAsyncTest method shouldRemoveEntityAsync.
@Test
public void shouldRemoveEntityAsync() {
DocumentEntity documentEntity = entityManager.insert(getEntity());
Document id = documentEntity.find("name").get();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
entityManagerAsync.delete(deleteQuery);
}
Aggregations