use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testGetViewsPagination.
@Test
public void testGetViewsPagination() {
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).page(1).pageSize(1).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE2);
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDao method updateView.
public View updateView(final String id, final View view) {
MorphiaView morphiaView = new MorphiaView(view);
morphiaView.setId(id);
datastore.save(databaseCollection(), morphiaView);
return morphiaView;
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testCreateViewExistingName.
@Test
public void testCreateViewExistingName() {
MorphiaView view = prepareView();
datastore.save(viewDao.databaseCollection(), view);
MorphiaView view2 = prepareView();
view2.setCode(CODE2);
assertThatThrownBy(() -> viewDao.createView(view2)).isInstanceOf(DuplicateKeyException.class);
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testGetViewsNoReadRole.
@Test
public void testGetViewsNoReadRole() {
MorphiaView view = prepareView();
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
view.getPermissions().updateUserPermissions(userPermission);
datastore.save(viewDao.databaseCollection(), view);
MorphiaView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
view2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(viewDao.databaseCollection(), view2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<View> views = viewDao.getViews(query);
assertThat(views).isEmpty();
}
use of io.lumeer.storage.mongodb.model.MorphiaView in project engine by Lumeer.
the class MorphiaViewDaoTest method testUpdateViewPermissions.
@Test
public void testUpdateViewPermissions() {
MorphiaView view = prepareView();
String id = datastore.save(viewDao.databaseCollection(), view).getId().toString();
assertThat(id).isNotNull().isNotEmpty();
view.getPermissions().removeUserPermission(USER);
view.getPermissions().updateGroupPermissions(GROUP_PERMISSION);
viewDao.updateView(id, view);
MorphiaView storedView = datastore.get(viewDao.databaseCollection(), MorphiaView.class, new ObjectId(id));
assertThat(storedView).isNotNull();
assertThat(storedView.getPermissions().getUserPermissions()).isEmpty();
assertThat(storedView.getPermissions().getGroupPermissions()).containsExactly(GROUP_PERMISSION);
}
Aggregations