use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerTest method shouldFindDocumentGreaterThan.
@Test
public void shouldFindDocumentGreaterThan() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("type").eq("V").build();
entityManager.delete(deleteQuery);
Iterable<DocumentEntity> entitiesSaved = entityManager.insert(getEntitiesWithValues());
List<DocumentEntity> entities = StreamSupport.stream(entitiesSaved.spliterator(), false).collect(Collectors.toList());
DocumentQuery query = select().from(COLLECTION_NAME).where("age").gt(22).and("type").eq("V").build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertTrue(entitiesFound.size() == 2);
assertThat(entitiesFound, not(contains(entities.get(0))));
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerTest method shouldDeleteAll.
@Test
public void shouldDeleteAll() {
entityManager.insert(getEntity());
DocumentQuery query = select().from(COLLECTION_NAME).build();
List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
assertFalse(entities.isEmpty());
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).build();
entityManager.delete(deleteQuery);
entities = entityManager.select(query).collect(Collectors.toList());
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldQueryAnd.
@Test
public void shouldQueryAnd() {
DocumentEntity entity = getEntity();
entity.add(Document.of("age", 24));
entityManager.insert(entity);
DocumentQuery query = select().from(COLLECTION_NAME).where("name").eq("Poliana").and("age").gte(10).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("name").eq("Poliana").and("age").gte(10).build();
assertFalse(entityManager.select(query).collect(Collectors.toList()).isEmpty());
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).collect(Collectors.toList()).isEmpty());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldLiveDeleteCallback.
@Test
@Disabled
public void shouldLiveDeleteCallback() {
AtomicBoolean condition = new AtomicBoolean(false);
OrientDBLiveDeleteCallback<DocumentEntity> callback = d -> condition.set(true);
entityManager.insert(getEntity());
DocumentQuery query = select().from(COLLECTION_NAME).build();
entityManager.live(query, OrientDBLiveCallbackBuilder.builder().onDelete(callback).build());
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).build();
entityManager.delete(deleteQuery);
await().untilTrue(condition);
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldQueryIn.
@Test
public void shouldQueryIn() {
entityManager.insert(getEntities());
DocumentQuery query = select().from(COLLECTION_NAME).where("city").in(asList("Salvador", "Assis")).build();
assertTrue(entityManager.select(query).collect(Collectors.toList()).size() == 2);
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("city").in(asList("Salvador", "Assis", "Sao Paulo")).build();
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).collect(Collectors.toList()).isEmpty());
}
Aggregations