use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class RavenDBDocumentCollectionManagerTest method shouldRemoveEntity.
@Test
public void shouldRemoveEntity() throws InterruptedException {
DocumentEntity entity = getEntity();
DocumentEntity documentEntity = entityManager.insert(entity);
Optional<Document> id = documentEntity.find("_id");
DocumentQuery query = select().from(COLLECTION_NAME).where("_id").eq(id.get().get()).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("_id").eq(id.get().get()).build();
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 RavenDBDocumentCollectionManagerTest method shouldFindDocumentLesserEqualsThan.
@Test
public void shouldFindDocumentLesserEqualsThan() throws InterruptedException {
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").lte(23).and("type").eq("V").build();
Thread.sleep(TIME_LIMIT);
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
System.out.println(entitiesFound);
assertEquals(2, entitiesFound.size());
assertThat(entitiesFound, contains(entities.get(0), entities.get(2)));
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class RavenDBDocumentCollectionManagerTest method shouldFindDocumentGreaterEqualsThan.
@Test
public void shouldFindDocumentGreaterEqualsThan() throws InterruptedException {
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").gte(23).and("type").eq("V").build();
Thread.sleep(TIME_LIMIT);
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(2, entitiesFound.size());
assertThat(entitiesFound, not(contains(entities.get(0))));
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldFindNot.
@Test
public void shouldFindNot() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).build();
entityManager.delete(deleteQuery);
entityManager.insert(getEntitiesWithValues());
DocumentQuery query = select().from(COLLECTION_NAME).where("name").not().eq("Lucas").build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(2, entitiesFound.size());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldSelectWhereNameLike.
@Test
public void shouldSelectWhereNameLike() {
String documentCollection = "documentCollection";
String name = "Ada Lovelace";
DocumentDeleteQuery query = delete().from(documentCollection).where("name").like(name).build();
DocumentCondition condition = query.getCondition().get();
Document document = condition.getDocument();
assertTrue(query.getDocuments().isEmpty());
assertEquals(documentCollection, query.getDocumentCollection());
assertEquals(Condition.LIKE, condition.getCondition());
assertEquals("name", document.getName());
assertEquals(name, document.get());
}
Aggregations