use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class DocumentQueryTest method beforeClass.
@BeforeAll
public static void beforeClass() throws InterruptedException {
configuration = CouchbaseDocumentTcConfiguration.getTcConfiguration();
CouhbaseDocumentCollectionManagerFactory managerFactory = configuration.get();
CouchbaseDocumentCollectionManager entityManager = managerFactory.get(CouchbaseUtil.BUCKET_NAME);
DocumentEntity entity = DocumentEntity.of("person", asList(Document.of("_id", "id"), Document.of("name", "name")));
DocumentEntity entity2 = DocumentEntity.of("person", asList(Document.of("_id", "id2"), Document.of("name", "name")));
DocumentEntity entity3 = DocumentEntity.of("person", asList(Document.of("_id", "id3"), Document.of("name", "name")));
DocumentEntity entity4 = DocumentEntity.of("person", asList(Document.of("_id", "id4"), Document.of("name", "name3")));
entityManager.insert(Arrays.asList(entity, entity2, entity3, entity4));
Thread.sleep(2_000L);
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class DefaultCouchDBDocumentCollectionManagerTest method shouldSelectEmptyResult.
@Test
public void shouldSelectEmptyResult() {
DocumentQuery query = select().from(COLLECTION_NAME).where("no_field").eq("not_found").build();
List<DocumentEntity> entities = entityManager.select(query).collect(Collectors.toList());
assertTrue(entities.isEmpty());
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class DefaultCouchDBDocumentCollectionManagerTest 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(CouchDBConstant.ID, "id");
List<Document> documents = Documents.of(map);
documents.forEach(entity::add);
return entity;
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class DefaultCouchDBDocumentCollectionManagerTest method shouldSaveSubDocument2.
@Test
public void shouldSaveSubDocument2() {
DocumentEntity entity = getEntity();
entity.add(Document.of("phones", asList(Document.of("mobile", "1231231"), Document.of("mobile2", "1231231"))));
DocumentEntity entitySaved = entityManager.insert(entity);
Document id = entitySaved.find("_id").get();
DocumentQuery query = select().from(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")));
}
use of jakarta.nosql.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class DefaultCouchDBDocumentCollectionManagerTest method shouldInsert.
@Test
public void shouldInsert() {
DocumentEntity entity = getEntity();
DocumentEntity documentEntity = entityManager.insert(entity);
assertEquals(entity, documentEntity);
}
Aggregations