use of io.lumeer.engine.api.data.DataDocument 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.engine.api.data.DataDocument 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;
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class GroovyExecutorTest method passingDataDocumentTest.
@Test
public void passingDataDocumentTest() {
final Map<String, Object> vars = new HashMap<>();
vars.put("dd", new DataDocument());
// verifies that we can pass our own objects in and out
GroovyExecutor.evaluateScript("dd.put('myDbl', 3.14157d)", vars);
assertThat(((DataDocument) vars.get("dd")).getDouble("myDbl")).isEqualTo(3.14157d);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class DocumentServiceIT method createDocument.
private Document createDocument() {
Document document = prepareDocument();
document.setCollectionId(collection.getId());
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collection.getId(), storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class DocumentServiceIT method testGetDocument.
@Test
@Ignore("Works manually but there is unexpected exception in tests")
public void testGetDocument() {
String id = createDocument().getId();
Response response = client.target(DOCUMENTS_URL_PREFIX).path(collection.getId()).path("documents").path(id).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
JsonDocument document = response.readEntity(JsonDocument.class);
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(document.getId()).isEqualTo(id);
assertions.assertThat(document.getCollectionId()).isNull();
assertions.assertThat(document.getCreatedBy()).isEqualTo(USER);
assertions.assertThat(document.getCreationDate()).isBeforeOrEqualTo(LocalDateTime.now());
assertions.assertThat(document.getUpdatedBy()).isNull();
assertions.assertThat(document.getUpdateDate()).isNull();
assertions.assertThat(document.getDataVersion()).isEqualTo(1);
assertions.assertAll();
DataDocument data = document.getData();
assertThat(data).isNotNull();
assertThat(data).containsEntry(KEY1, VALUE1);
assertThat(data).containsEntry(KEY2, VALUE2);
}
Aggregations