Search in sources :

Example 16 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollectionsPagination.

@Test
public void testGetCollectionsPagination() {
    createCollection(CODE, NAME);
    createCollection(CODE2, NAME2);
    createCollection(CODE3, NAME3);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).page(1).pageSize(1).build();
    List<Collection> collections = collectionDao.getCollections(searchQuery);
    assertThat(collections).extracting(Resource::getCode).containsOnly(CODE2);
}
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)

Example 17 with Collection

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

the class MorphiaCollectionDaoTest method testDeleteCollection.

@Test
public void testDeleteCollection() {
    String id = createCollection(CODE, NAME).getId();
    collectionDao.deleteCollection(id);
    Collection storedCollection = datastore.get(collectionDao.databaseCollection(), MorphiaCollection.class, new ObjectId(id));
    assertThat(storedCollection).isNull();
}
Also used : ObjectId(org.bson.types.ObjectId) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 18 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollections.

@Test
public void testGetCollections() {
    MorphiaCollection collection = prepareCollection(CODE, NAME);
    datastore.save(collectionDao.databaseCollection(), collection);
    MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
    datastore.save(collectionDao.databaseCollection(), collection2);
    SearchQuery query = SearchQuery.createBuilder(USER).build();
    List<Collection> views = collectionDao.getCollections(query);
    assertThat(views).extracting(Collection::getCode).containsOnly(CODE, CODE2);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 19 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollectionsByIds.

@Test
public void testGetCollectionsByIds() {
    MorphiaCollection collection = prepareCollection(CODE, NAME);
    String id = collectionDao.createCollection(collection).getId();
    MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
    String id2 = collectionDao.createCollection(collection2).getId();
    MorphiaCollection collection3 = prepareCollection(CODE3, NAME3);
    String id3 = collectionDao.createCollection(collection3).getId();
    MorphiaCollection collection4 = prepareCollection(CODE4, NAME4);
    String id4 = collectionDao.createCollection(collection4).getId();
    List<Collection> collections = collectionDao.getCollectionsByIds(Arrays.asList(id, id3));
    assertThat(collections).hasSize(2).extracting("id").containsOnlyElementsOf(Arrays.asList(id, id3));
    collections = collectionDao.getCollectionsByIds(Arrays.asList(id, id2, id4));
    assertThat(collections).hasSize(3).extracting("id").containsOnlyElementsOf(Arrays.asList(id, id2, id4));
}
Also used : MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 20 with Collection

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

the class CollectionFacadeIT method testDeleteCollectionAttribute.

@Test
public void testDeleteCollectionAttribute() {
    JsonAttribute attribute = new JsonAttribute(ATTRIBUTE_NAME, ATTRIBUTE_FULLNAME, ATTRIBUTE_CONSTRAINTS, ATTRIBUTE_COUNT);
    Collection collection = createCollection(CODE, attribute);
    assertThat(collection.getAttributes()).isNotEmpty();
    collectionFacade.deleteCollectionAttribute(collection.getId(), ATTRIBUTE_FULLNAME);
    collection = collectionDao.getCollectionByCode(CODE);
    assertThat(collection).isNotNull();
    assertThat(collection.getAttributes()).isEmpty();
}
Also used : JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) JsonAttribute(io.lumeer.api.dto.JsonAttribute) 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