Search in sources :

Example 6 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class MongoDataDaoTest method testGetDataByFulltextAttributeName.

@Test
@Ignore("Does not work at the moment")
public void testGetDataByFulltextAttributeName() {
    String id1 = createDocument(KEY1, VALUE1);
    String id2 = createDocument("fulltext", VALUE1);
    String id3 = createDocument(KEY1, VALUE1);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
    List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
    assertThat(data).extracting(DataDocument::getId).containsOnly(id2);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class MongoDataDaoTest method testGetDataByFulltextAttributeValue.

@Test
public void testGetDataByFulltextAttributeValue() {
    String id1 = createDocument(KEY1, VALUE1);
    String id2 = createDocument(KEY1, "fulltext");
    String id3 = createDocument(KEY1, "something fulltext");
    String id4 = createDocument(KEY1, VALUE1);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
    List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
    assertThat(data).extracting(DataDocument::getId).containsOnly(id2, id3);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) Test(org.junit.Test)

Example 8 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class MongoDataDaoTest method testPatchData.

@Test
public void testPatchData() {
    String id = createDocument();
    DataDocument data = new DataDocument().append(KEY1, VALUE2);
    dataDao.patchData(COLLECTION_ID, id, data);
    MongoCursor<Document> mongoCursor = dataCollection().find().iterator();
    assertThat(mongoCursor.hasNext()).isTrue();
    Document document = mongoCursor.next();
    assertThat(document).containsEntry(KEY1, VALUE2);
    assertThat(document).containsEntry(KEY2, VALUE2);
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Document(org.bson.Document) DataDocument(io.lumeer.engine.api.data.DataDocument) Test(org.junit.Test)

Example 9 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class MongoDataDaoTest method testUpdateData.

@Test
public void testUpdateData() {
    String id = createDocument();
    DataDocument data = new DataDocument().append(KEY1, VALUE2);
    dataDao.updateData(COLLECTION_ID, id, data);
    MongoCursor<Document> mongoCursor = dataCollection().find().iterator();
    assertThat(mongoCursor.hasNext()).isTrue();
    Document document = mongoCursor.next();
    assertThat(document).containsEntry(KEY1, VALUE2);
    assertThat(document).doesNotContainKey(KEY2);
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Document(org.bson.Document) DataDocument(io.lumeer.engine.api.data.DataDocument) Test(org.junit.Test)

Example 10 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class MongoDataDaoTest method testGetSingleDataRecord.

@Test
public void testGetSingleDataRecord() {
    String id = createDocument();
    DataDocument dataDocument = dataDao.getData(COLLECTION_ID, id);
    assertThat(dataDocument).containsEntry(KEY1, VALUE1);
    assertThat(dataDocument).containsEntry(KEY2, VALUE2);
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) 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