use of io.lumeer.api.model.Document in project engine by Lumeer.
the class DocumentFacadeIT method testCreateDocument.
@Test
public void testCreateDocument() {
Collection storedCollection = collectionDao.getCollectionById(collection.getId());
assertThat(storedCollection.getDocumentsCount()).isEqualTo(0);
assertThat(storedCollection.getAttributes()).extracting(Attribute::getFullName).isEmpty();
Document document = prepareDocument();
LocalDateTime beforeTime = LocalDateTime.now();
String id = documentFacade.createDocument(collection.getId(), document).getId();
assertThat(id).isNotNull();
Document storedDocument = documentDao.getDocumentById(id);
assertThat(storedDocument).isNotNull();
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()).isAfterOrEqualTo(beforeTime).isBeforeOrEqualTo(LocalDateTime.now());
assertions.assertThat(storedDocument.getUpdatedBy()).isNull();
assertions.assertThat(storedDocument.getUpdateDate()).isNull();
assertions.assertThat(storedDocument.getDataVersion()).isEqualTo(1);
assertions.assertThat(storedDocument.getData()).isNull();
assertions.assertAll();
DataDocument storedData = dataDao.getData(collection.getId(), id);
assertThat(storedData).isNotNull();
assertThat(storedData).containsEntry(KEY1, VALUE1);
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 DocumentFacadeIT method testGetDocuments.
@Test
public void testGetDocuments() {
String id1 = createDocument().getId();
String id2 = createDocument().getId();
Pagination pagination = new Pagination(null, null);
List<Document> documents = documentFacade.getDocuments(collection.getId(), pagination);
assertThat(documents).extracting(Document::getId).containsOnly(id1, id2);
}
Aggregations