use of jakarta.nosql.document.Document in project jnosql-diana-driver by eclipse.
the class RavenDBDocumentCollectionManagerTest method shouldRunSingleResult.
@Test
public void shouldRunSingleResult() {
DocumentEntity entity = entityManager.insert(getEntity());
Optional<Document> id = entity.find("_id");
DocumentQuery query = select().from(COLLECTION_NAME).where("_id").eq(id.get().get()).build();
Optional<DocumentEntity> result = entityManager.singleResult(query);
assertTrue(result.isPresent());
assertEquals(entity, result.get());
}
use of jakarta.nosql.document.Document in project jnosql-diana-driver by eclipse.
the class RavenDBDocumentCollectionManagerTest method shouldFindDocument3.
@Test
public void shouldFindDocument3() {
DocumentEntity entity = entityManager.insert(getEntity());
Optional<Document> id = entity.find("_id");
DocumentQuery query = select().from(COLLECTION_NAME).where("name").eq("Poliana").or("city").eq("Salvador").and(id.get().getName()).eq(id.get().get()).build();
List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
assertFalse(entities.isEmpty());
assertThat(entities, contains(entity));
}
use of jakarta.nosql.document.Document 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.Document in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method getEntity.
private DocumentEntity getEntity() {
DocumentEntity entity = DocumentEntity.of(COLLECTION_NAME);
Map<String, Object> map = new HashMap<>();
map.put("name", "Poliana");
map.put("city", "Salvador");
map.put(ID, ThreadLocalRandom.current().nextLong(1, 10));
List<Document> documents = Documents.of(map);
documents.forEach(entity::add);
return entity;
}
use of jakarta.nosql.document.Document in project jnosql-diana by eclipse.
the class DocumentTest method shouldReturnGetType.
@Test
public void shouldReturnGetType() {
Value value = Value.of("text");
Document document = Document.of("name", value);
TypeReference<List<String>> typeReference = new TypeReference<List<String>>() {
};
assertEquals(value.get(typeReference), document.get(typeReference));
}
Aggregations