Search in sources :

Example 1 with JsonView

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();
}
Also used : JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) POST(javax.ws.rs.POST)

Example 2 with JsonView

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);
}
Also used : JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 3 with JsonView

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();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) Permission(io.lumeer.api.model.Permission) JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 4 with JsonView

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);
}
Also used : JsonView(io.lumeer.api.dto.JsonView) Test(org.junit.Test)

Example 5 with JsonView

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());
}
Also used : JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Aggregations

JsonView (io.lumeer.api.dto.JsonView)22 View (io.lumeer.api.model.View)14 Test (org.junit.Test)14 SearchQuery (io.lumeer.storage.api.query.SearchQuery)4 JsonQuery (io.lumeer.api.dto.JsonQuery)3 MongoException (com.mongodb.MongoException)2 JsonPermissions (io.lumeer.api.dto.JsonPermissions)2 Permission (io.lumeer.api.model.Permission)2 StorageException (io.lumeer.storage.api.exception.StorageException)2 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)2 FindOneAndReplaceOptions (com.mongodb.client.model.FindOneAndReplaceOptions)1 JsonPermission (io.lumeer.api.dto.JsonPermission)1 Organization (io.lumeer.api.model.Organization)1 Pagination (io.lumeer.api.model.Pagination)1 Permissions (io.lumeer.api.model.Permissions)1 Project (io.lumeer.api.model.Project)1 Resource (io.lumeer.api.model.Resource)1 Role (io.lumeer.api.model.Role)1 User (io.lumeer.api.model.User)1 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)1