use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class ViewServiceIT method testGetAllViews.
@Test
public void testGetAllViews() {
createView(CODE);
createView(CODE2);
Response response = client.target(VIEWS_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonView> views = response.readEntity(new GenericType<List<JsonView>>() {
});
assertThat(views).extracting(Resource::getCode).containsOnly(CODE, CODE2);
Permissions permissions1 = views.get(0).getPermissions();
assertThat(permissions1).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions1).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions1).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
Permissions permissions2 = views.get(1).getPermissions();
assertThat(permissions2).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions2).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions2).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class ViewService method getViews.
@GET
public List<JsonView> getViews(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize) {
Pagination pagination = new Pagination(page, pageSize);
List<View> views = viewFacade.getViews(pagination);
return JsonView.convert(views);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class ViewService method updateView.
@PUT
@Path("{viewCode}")
public Response updateView(@PathParam("viewCode") String code, JsonView view) {
View storedView = viewFacade.updateView(code, 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 testGetViewsGroupRole.
@Test
public void testGetViewsGroupRole() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(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);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testUpdateViewExistingName.
@Test
public void testUpdateViewExistingName() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(view2);
view2.setName(NAME);
assertThatThrownBy(() -> viewDao.updateView(view2.getId(), view2)).isInstanceOf(StorageException.class);
}
Aggregations