use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class ViewService method createView.
@POST
public Response createView(JsonView view) {
View storedView = viewFacade.createView(view);
JsonView jsonView = new JsonView(storedView);
return Response.ok(jsonView).build();
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testUpdateViewCode.
@Test
public void testUpdateViewCode() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
String id = view.getId();
assertThat(id).isNotNull().isNotEmpty();
view.setCode(CODE2);
viewDao.updateView(id, view);
View storedView = viewDao.databaseCollection().find(MongoFilters.idFilter(id)).first();
assertThat(storedView).isNotNull();
assertThat(storedView.getCode()).isEqualTo(CODE2);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsNoReadRole.
@Test
public void testGetViewsNoReadRole() {
JsonView view = prepareView();
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
view.getPermissions().updateUserPermissions(userPermission);
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
view2.getPermissions().updateGroupPermissions(groupPermission);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<View> views = viewDao.getViews(query);
assertThat(views).isEmpty();
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testCreateViewExistingName.
@Test
public void testCreateViewExistingName() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
assertThatThrownBy(() -> viewDao.createView(view2)).isInstanceOf(StorageException.class);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewByCode.
@Test
public void testGetViewByCode() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
View storedView = viewDao.getViewByCode(CODE);
assertThat(storedView).isNotNull();
assertThat(storedView.getCode()).isEqualTo(view.getCode());
}
Aggregations