Search in sources :

Example 1 with MorphiaView

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

the class MorphiaViewDaoTest method prepareView.

private MorphiaView prepareView() {
    MorphiaView view = new MorphiaView();
    view.setCode(CODE);
    view.setName(NAME);
    view.setColor(COLOR);
    view.setIcon(ICON);
    view.setPermissions(new MorphiaPermissions(PERMISSIONS));
    view.setQuery(QUERY);
    view.setPerspective(PERSPECTIVE);
    view.setConfig(CONFIG);
    return view;
}
Also used : MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)

Example 2 with MorphiaView

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

the class MorphiaViewDaoTest method testUpdateViewExistingName.

@Test
public void testUpdateViewExistingName() {
    MorphiaView view = prepareView();
    datastore.save(viewDao.databaseCollection(), view);
    MorphiaView view2 = prepareView();
    view2.setCode(CODE2);
    view2.setName(NAME2);
    datastore.save(viewDao.databaseCollection(), view2);
    view2.setName(NAME);
    assertThatThrownBy(() -> viewDao.updateView(view2.getId(), view2)).isInstanceOf(DuplicateKeyException.class);
}
Also used : MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Test(org.junit.Test)

Example 3 with MorphiaView

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

the class MorphiaViewDaoTest method testGetViews.

@Test
public void testGetViews() {
    MorphiaView view = prepareView();
    datastore.save(viewDao.databaseCollection(), view);
    MorphiaView view2 = prepareView();
    view2.setCode(CODE2);
    view2.setName(NAME2);
    datastore.save(viewDao.databaseCollection(), view2);
    SearchQuery query = SearchQuery.createBuilder(USER).build();
    List<View> views = viewDao.getViews(query);
    assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE2);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) View(io.lumeer.api.model.View) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Test(org.junit.Test)

Example 4 with MorphiaView

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

the class MorphiaViewDaoTest method testGetViewsGroupRole.

@Test
public void testGetViewsGroupRole() {
    MorphiaView view = prepareView();
    datastore.save(viewDao.databaseCollection(), view);
    MorphiaView view2 = prepareView();
    view2.setCode(CODE2);
    view2.setName(NAME2);
    datastore.save(viewDao.databaseCollection(), view2);
    SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).build();
    List<View> views = viewDao.getViews(query);
    assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE2);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) View(io.lumeer.api.model.View) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Test(org.junit.Test)

Example 5 with MorphiaView

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

the class MorphiaViewDaoTest method createView.

private MorphiaView createView(String code, String name) {
    MorphiaView morphiaView = prepareView();
    morphiaView.setCode(code);
    morphiaView.setName(name);
    datastore.insert(viewDao.databaseCollection(), morphiaView);
    return morphiaView;
}
Also used : MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView)

Aggregations

MorphiaView (io.lumeer.storage.mongodb.model.MorphiaView)17 Test (org.junit.Test)11 View (io.lumeer.api.model.View)4 SearchQuery (io.lumeer.storage.api.query.SearchQuery)4 ObjectId (org.bson.types.ObjectId)3 ArrayList (java.util.ArrayList)2 FindOptions (org.mongodb.morphia.query.FindOptions)2 Permission (io.lumeer.api.model.Permission)1 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)1 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)1