MapLayerGroupsHandler extends RestActionHandler { public void handleDelete(ActionParameters params) throws ActionException { params.requireAdminUser(); final int groupId = params.getRequiredParamInt(PARAM_ID); final Object deleteLayers = params.getHttpParam(PARAM_DELETE_LAYERS); final MaplayerGroup maplayerGroup = oskariMapLayerGroupService.find(groupId); if (deleteLayers != null) { handleDelete(params, maplayerGroup, deleteLayers); } else { handleDeleteLegacy(params, maplayerGroup); } }  void setOskariMapLayerGroupService(final OskariMapLayerGroupService service); void setLinkService(OskariLayerGroupLinkService linkService); void init(); void handleGet(ActionParameters params); void handlePut(ActionParameters params); void handlePost(ActionParameters params); void handleDelete(ActionParameters params);  }
@Test(expected = ActionDeniedException.class) public void testHandleDeleteGuest() throws Exception { ActionParameters params = createActionParams(createDummyLocale()); handler.handleDelete(params); fail("Should have thrown denied exception"); }
@Test(expected = ActionDeniedException.class) public void testHandleDeleteLoggedIn() throws Exception { ActionParameters params = createActionParams(createDummyLocale(), getLoggedInUser()); handler.handleDelete(params); fail("Should have thrown denied exception"); }
@Test public void testHandleDeleteAdmin() throws Exception { Map<String, String> map = buildParams().put(ActionConstants.PARAM_ID, 1).done(); ActionParameters params = createActionParams(map, getAdminUser()); handler.handleDelete(params); verifyResponseContent(ResourceHelper.readJSONResource("MapLayerGroupsHandlerTest-find-expected.json", this)); }