Search in sources :

Example 36 with DataDocument

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;
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) DataDocument(io.lumeer.engine.api.data.DataDocument) JsonDocument(io.lumeer.api.dto.JsonDocument) Document(io.lumeer.api.model.Document)

Example 37 with DataDocument

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;
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) DataDocument(io.lumeer.engine.api.data.DataDocument) JsonDocument(io.lumeer.api.dto.JsonDocument) Document(io.lumeer.api.model.Document) JsonDocument(io.lumeer.api.dto.JsonDocument)

Example 38 with DataDocument

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);
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 39 with DataDocument

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;
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) DataDocument(io.lumeer.engine.api.data.DataDocument) JsonDocument(io.lumeer.api.dto.JsonDocument) Document(io.lumeer.api.model.Document)

Example 40 with DataDocument

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);
}
Also used : Response(javax.ws.rs.core.Response) DataDocument(io.lumeer.engine.api.data.DataDocument) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonDocument(io.lumeer.api.dto.JsonDocument) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DataDocument (io.lumeer.engine.api.data.DataDocument)75 Test (org.junit.Test)42 Collection (io.lumeer.api.model.Collection)16 Document (io.lumeer.api.model.Document)16 JsonDocument (io.lumeer.api.dto.JsonDocument)14 Document (org.bson.Document)13 SoftAssertions (org.assertj.core.api.SoftAssertions)10 ReturnDocument (com.mongodb.client.model.ReturnDocument)9 JsonCollection (io.lumeer.api.dto.JsonCollection)9 DataFilter (io.lumeer.engine.api.data.DataFilter)9 ImportedCollection (io.lumeer.api.model.ImportedCollection)6 SearchQuery (io.lumeer.storage.api.query.SearchQuery)6 LocalDateTime (java.time.LocalDateTime)6 BsonDocument (org.bson.BsonDocument)6 LinkedList (java.util.LinkedList)5 FindOneAndUpdateOptions (com.mongodb.client.model.FindOneAndUpdateOptions)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Response (javax.ws.rs.core.Response)4 DataStorageStats (io.lumeer.engine.api.data.DataStorageStats)3