Search in sources :

Example 11 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class MongoDataDaoTest method initDataDao.

@Before
public void initDataDao() {
    Collection collection = Mockito.mock(Collection.class);
    Mockito.when(collection.getId()).thenReturn(COLLECTION_ID);
    dataDao = new MongoDataDao();
    dataDao.setDatabase(database);
    dataDao.setDatastore(datastore);
    dataDao.createDataRepository(COLLECTION_ID);
}
Also used : MongoCollection(com.mongodb.client.MongoCollection) Collection(io.lumeer.api.model.Collection) Before(org.junit.Before)

Example 12 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testGetCollectionsSuggestionsDifferentUser.

@Test
public void testGetCollectionsSuggestionsDifferentUser() {
    createCollection(CODE, NAME, ATTRIBUTES);
    createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
    createCollection(CODE3, NAME_SUGGESTION, ATTRIBUTES);
    SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER2).text("TEST").build();
    List<Collection> collections = collectionDao.getCollections(suggestionQuery);
    assertThat(collections).isEmpty();
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 13 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testGetCollectionsSuggestions.

@Test
public void testGetCollectionsSuggestions() {
    createCollection(CODE, NAME, ATTRIBUTES);
    createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
    createCollection(CODE3, NAME_SUGGESTION, ATTRIBUTES);
    SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER).text("TEST").build();
    List<Collection> collections = collectionDao.getCollections(suggestionQuery);
    assertThat(collections).extracting(Resource::getCode).containsOnly(CODE, CODE3);
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 14 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testUpdateCollection.

@Test
public void testUpdateCollection() {
    String id = createCollection(CODE, NAME).getId();
    MorphiaCollection collection = prepareCollection(CODE2, NAME);
    Collection updatedCollection = collectionDao.updateCollection(id, collection);
    assertThat(updatedCollection).isNotNull();
    assertThat(updatedCollection.getCode()).isEqualTo(CODE2);
    Collection storedCollection = datastore.get(collectionDao.databaseCollection(), MorphiaCollection.class, new ObjectId(id));
    assertThat(storedCollection).isNotNull();
    assertThat(updatedCollection).isEqualTo(storedCollection);
}
Also used : MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) ObjectId(org.bson.types.ObjectId) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 15 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testGetCollectionsByFulltextAndCollectionIds.

@Test
public void testGetCollectionsByFulltextAndCollectionIds() {
    String id1 = createCollection(CODE, NAME, ATTRIBUTES).getId();
    String id2 = createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES).getId();
    String id3 = createCollection(CODE3, NAME3, ATTRIBUTES).getId();
    createCollection(CODE4, NAME_FULLTEXT2, ATTRIBUTES);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList(id1, id2, id3))).fulltext("fulltext").build();
    List<Collection> collections = collectionDao.getCollections(searchQuery);
    assertThat(collections).extracting(Resource::getId).containsOnly(id2, id3);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Aggregations

Collection (io.lumeer.api.model.Collection)77 Test (org.junit.Test)47 JsonCollection (io.lumeer.api.dto.JsonCollection)34 DataDocument (io.lumeer.engine.api.data.DataDocument)17 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)17 SearchQuery (io.lumeer.storage.api.query.SearchQuery)14 SoftAssertions (org.assertj.core.api.SoftAssertions)12 Document (io.lumeer.api.model.Document)8 ImportedCollection (io.lumeer.api.model.ImportedCollection)8 SuggestionQuery (io.lumeer.storage.api.query.SuggestionQuery)8 Response (javax.ws.rs.core.Response)8 JsonAttribute (io.lumeer.api.dto.JsonAttribute)7 Attribute (io.lumeer.api.model.Attribute)7 HashSet (java.util.HashSet)6 JsonQuery (io.lumeer.api.dto.JsonQuery)5 LocalDateTime (java.time.LocalDateTime)4 List (java.util.List)4 JsonDocument (io.lumeer.api.dto.JsonDocument)3 LinkType (io.lumeer.api.model.LinkType)3 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)3