use of io.lumeer.api.model.Document in project engine by Lumeer.
the class DocumentFacadeIT method testPatchDocumentData.
@Test
public void testPatchDocumentData() {
Document document = createDocument();
String id = document.getId();
Collection storedCollection = collectionDao.getCollectionById(collection.getId());
assertThat(storedCollection.getDocumentsCount()).isEqualTo(1);
assertThat(storedCollection.getAttributes()).extracting(Attribute::getFullName).containsOnly(KEY1, KEY2);
assertThat(findCollectionAttribute(storedCollection, KEY1).getUsageCount()).isEqualTo(1);
assertThat(findCollectionAttribute(storedCollection, KEY2).getUsageCount()).isEqualTo(1);
DataDocument data = new DataDocument(KEY1, VALUE2);
LocalDateTime beforeUpdateTime = LocalDateTime.now();
Document updatedDocument = documentFacade.patchDocumentData(collection.getId(), id, data);
assertThat(updatedDocument).isNotNull();
Document storedDocument = documentDao.getDocumentById(id);
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(storedDocument.getId()).isEqualTo(id);
assertions.assertThat(storedDocument.getCollectionId()).isEqualTo(collection.getId());
assertions.assertThat(storedDocument.getCreatedBy()).isEqualTo(USER);
assertions.assertThat(storedDocument.getCreationDate()).isBeforeOrEqualTo(beforeUpdateTime);
assertions.assertThat(storedDocument.getUpdatedBy()).isEqualTo(USER);
assertions.assertThat(storedDocument.getUpdateDate()).isAfterOrEqualTo(beforeUpdateTime).isBeforeOrEqualTo(LocalDateTime.now());
assertions.assertThat(storedDocument.getDataVersion()).isEqualTo(2);
assertions.assertThat(storedDocument.getData()).isNull();
assertions.assertAll();
DataDocument storedData = dataDao.getData(collection.getId(), id);
assertThat(storedData).isNotNull();
assertThat(storedData).containsEntry(KEY1, VALUE2);
assertThat(storedData).containsEntry(KEY2, VALUE2);
storedCollection = collectionDao.getCollectionById(collection.getId());
assertThat(storedCollection.getDocumentsCount()).isEqualTo(1);
assertThat(storedCollection.getAttributes()).extracting(Attribute::getFullName).containsOnly(KEY1, KEY2);
assertThat(findCollectionAttribute(storedCollection, KEY1).getUsageCount()).isEqualTo(1);
assertThat(findCollectionAttribute(storedCollection, KEY2).getUsageCount()).isEqualTo(1);
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class LinkInstanceFacadeIT method createDocument.
private Document createDocument(String collectionId) {
Document document = prepareDocument();
document.setCollectionId(collectionId);
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collectionId, storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class LinkInstanceServiceIT method createDocument.
private Document createDocument(String collectionId) {
Document document = prepareDocument();
document.setCollectionId(collectionId);
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collectionId, storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsByEmptyQuery.
@Test
public void testSearchDocumentsByEmptyQuery() {
String id1 = createDocument(collectionIds.get(0), "doc1").getId();
String id2 = createDocument(collectionIds.get(0), "doc2").getId();
String id3 = createDocument(collectionIds.get(1), "doc3").getId();
String id4 = createDocument(collectionIds.get(1), "doc4").getId();
String id5 = createDocument(collectionIds.get(2), "doc5").getId();
String id6 = createDocument(collectionIds.get(2), "doc6").getId();
List<Document> documents = searchFacade.searchDocuments(new JsonQuery());
assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id3, id4, id5, id6);
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class SearchFacadeIT method createDocument.
private Document createDocument(String collectionId, Object value) {
Document document = new JsonDocument(new DataDocument(DOCUMENT_KEY, value));
document.setCollectionId(collectionId);
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collectionId, storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
Aggregations