Search in sources :

Example 1 with MorphiaCollection

use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testCreateCollectionExistingName.

@Test
public void testCreateCollectionExistingName() {
    createCollection(CODE, NAME);
    MorphiaCollection collection = prepareCollection(CODE2, NAME);
    assertThatThrownBy(() -> collectionDao.createCollection(collection)).isInstanceOf(DuplicateKeyException.class);
}
Also used : MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Test(org.junit.Test)

Example 2 with MorphiaCollection

use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method createCollection.

private MorphiaCollection createCollection(String code, String name) {
    MorphiaCollection collection = prepareCollection(code, name);
    datastore.insert(collectionDao.databaseCollection(), collection);
    return collection;
}
Also used : MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection)

Example 3 with MorphiaCollection

use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testCreateCollectionExistingCode.

@Test
public void testCreateCollectionExistingCode() {
    createCollection(CODE, NAME);
    MorphiaCollection collection = prepareCollection(CODE, NAME2);
    assertThatThrownBy(() -> collectionDao.createCollection(collection)).isInstanceOf(DuplicateKeyException.class);
}
Also used : MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Test(org.junit.Test)

Example 4 with MorphiaCollection

use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.

the class MorphiaCollectionDaoTest method testUpdateCollectionNotExisting.

@Test
@Ignore("Stored anyway with the current implementation")
public void testUpdateCollectionNotExisting() {
    MorphiaCollection collection = prepareCollection(CODE, NAME);
    assertThatThrownBy(() -> collectionDao.updateCollection(COLLECTION_ID, collection)).isInstanceOf(StorageException.class);
}
Also used : MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with MorphiaCollection

use of io.lumeer.storage.mongodb.model.MorphiaCollection 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)

Aggregations

MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)15 Test (org.junit.Test)10 Collection (io.lumeer.api.model.Collection)6 SearchQuery (io.lumeer.storage.api.query.SearchQuery)4 Permission (io.lumeer.api.model.Permission)2 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)2 ObjectId (org.bson.types.ObjectId)2 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)1 HashSet (java.util.HashSet)1 Ignore (org.junit.Ignore)1