use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testUpdateViewPermissions.
@Test
public void testUpdateViewPermissions() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
String id = view.getId();
assertThat(id).isNotNull().isNotEmpty();
view.getPermissions().removeUserPermission(USER);
view.getPermissions().updateGroupPermissions(GROUP_PERMISSION);
viewDao.updateView(id, view);
View storedView = viewDao.databaseCollection().find(MongoFilters.idFilter(id)).first();
assertThat(storedView).isNotNull();
assertThat(storedView.getPermissions().getUserPermissions()).isEmpty();
assertThat(storedView.getPermissions().getGroupPermissions()).containsExactly(GROUP_PERMISSION);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDao method updateView.
@Override
public View updateView(final String id, final View view) {
JsonView jsonView = new JsonView(view);
FindOneAndReplaceOptions options = new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER);
try {
View updatedView = databaseCollection().findOneAndReplace(idFilter(id), jsonView, options);
if (updatedView == null) {
throw new StorageException("View '" + view.getId() + "' has not been updated.");
}
return updatedView;
} catch (MongoException ex) {
throw new StorageException("Cannot update view: " + view, ex);
}
}
Aggregations