use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldFindDocumentLike.
@Test
public void shouldFindDocumentLike() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).build();
entityManager.delete(deleteQuery);
Iterable<DocumentEntity> entities = entityManager.insert(getEntitiesWithValues());
DocumentQuery query = select().from(COLLECTION_NAME).where("name").like("Lu*").and("type").eq("V").build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(2, entitiesFound.size());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldFindDocumentIn.
@Test
public void shouldFindDocumentIn() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).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("location").in(asList("BR", "US")).and("type").eq("V").build();
assertEquals(3, entityManager.select(query).collect(Collectors.toList()).size());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldRemoveEntity.
@Test
public void shouldRemoveEntity() {
DocumentEntity documentEntity = entityManager.insert(getEntity());
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 DefaultSolrDocumentCollectionManagerTest method shouldFindDocumentSort.
@Test
public void shouldFindDocumentSort() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).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").orderBy("age").asc().build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
List<Integer> ages = entitiesFound.stream().map(e -> e.find("age").get().get(Integer.class)).collect(Collectors.toList());
assertThat(ages, contains(22, 23, 25));
query = select().from(COLLECTION_NAME).where("age").gt(22).and("type").eq("V").orderBy("age").desc().build();
entitiesFound = entityManager.select(query).collect(Collectors.toList());
ages = entitiesFound.stream().map(e -> e.find("age").get().get(Integer.class)).collect(Collectors.toList());
assertThat(ages, contains(25, 23, 22));
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldFindDocumentGreaterEqualsThan.
@Test
public void shouldFindDocumentGreaterEqualsThan() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).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();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(2, entitiesFound.size());
assertThat(entitiesFound, not(contains(entities.get(0))));
}
Aggregations