use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldFindAll.
@Test
public void shouldFindAll() throws InterruptedException {
entityManager.insert(DocumentEntityGerator.getEntity());
DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).build();
SECONDS.sleep(1L);
List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
assertFalse(entities.isEmpty());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldInsert.
@Test
public void shouldInsert() {
DocumentEntity entity = DocumentEntityGerator.getEntity();
DocumentEntity documentEntity = entityManager.insert(entity);
assertEquals(entity, documentEntity);
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldRemoveEntityById.
@Test
public void shouldRemoveEntityById() {
DocumentEntity documentEntity = entityManager.insert(DocumentEntityGerator.getEntity());
Document id = documentEntity.find("_id").get();
DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
DocumentDeleteQuery deleteQuery = delete().from(DocumentEntityGerator.COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).collect(Collectors.toList()).isEmpty());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldRemoveEntityByName.
@Test
public void shouldRemoveEntityByName() throws InterruptedException {
DocumentEntity documentEntity = entityManager.insert(DocumentEntityGerator.getEntity());
Document name = documentEntity.find("name").get();
DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
DocumentDeleteQuery deleteQuery = delete().from(DocumentEntityGerator.COLLECTION_NAME).where(name.getName()).eq(name.get()).build();
SECONDS.sleep(1L);
entityManager.delete(deleteQuery);
SECONDS.sleep(1L);
List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
System.out.println(entities);
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method shouldSaveSubDocument2.
@Test
public void shouldSaveSubDocument2() {
DocumentEntity entity = DocumentEntityGerator.getEntity();
entity.add(Document.of("phones", Arrays.asList(Document.of("mobile", "1231231"), Document.of("mobile2", "1231231"))));
DocumentEntity entitySaved = entityManager.insert(entity);
Document id = entitySaved.find("_id").get();
DocumentQuery query = select().from(DocumentEntityGerator.COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
DocumentEntity entityFound = entityManager.select(query).collect(Collectors.toList()).get(0);
Document subDocument = entityFound.find("phones").get();
List<Document> documents = subDocument.get(new TypeReference<List<Document>>() {
});
assertThat(documents, containsInAnyOrder(Document.of("mobile", "1231231"), Document.of("mobile2", "1231231")));
}
Aggregations