use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerTest method shouldFindDocumentLike.
@Test
public void shouldFindDocumentLike() {
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("name").like("Lu").and("type").eq("V").build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertTrue(entitiesFound.size() == 2);
assertThat(entitiesFound, contains(entities.get(0), entities.get(2)));
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerTest method shouldFindDocumentGreaterEqualsThan.
@Test
public void shouldFindDocumentGreaterEqualsThan() {
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();
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 shouldFindDocumentSort.
@Test
public void shouldFindDocumentSort() {
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").orderBy("age").asc().build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(2, entitiesFound.size());
List<Integer> ages = entitiesFound.stream().map(e -> e.find("age").get().get(Integer.class)).collect(Collectors.toList());
assertThat(ages, contains(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());
assertEquals(2, entitiesFound.size());
assertThat(ages, contains(25, 23));
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerTest method shouldFindDocumentLimit.
@Test
public void shouldFindDocumentLimit() {
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").limit(1L).build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(1, entitiesFound.size());
assertThat(entitiesFound, not(contains(entities.get(0))));
query = select().from(COLLECTION_NAME).where("age").gt(22).and("type").eq("V").limit(2L).build();
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 MongoDBDocumentCollectionManagerTest method shouldFindDocumentLesserThan.
@Test
public void shouldFindDocumentLesserThan() {
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").lt(23).and("type").eq("V").build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertTrue(entitiesFound.size() == 1);
assertThat(entitiesFound, contains(entities.get(0)));
}
Aggregations