@Test public void define_close_action() throws Exception { WebService.Controller controller = tester.controller("api/action_plans"); WebService.Action action = controller.action("close"); assertThat(action).isNotNull(); assertThat(action.handler()).isInstanceOf(RailsHandler.class); assertThat(action.params()).hasSize(2); }
@Test public void define_remove_action() throws Exception { WebService.Controller controller = tester.controller("api/permissions"); WebService.Action action = controller.action("remove"); assertThat(action).isNotNull(); assertThat(action.handler()).isInstanceOf(RailsHandler.INSTANCE.getClass()); assertThat(action.params()).hasSize(5); }
@Test public void define_search_action() throws Exception { WebService.Controller controller = tester.controller("api/action_plans"); WebService.Action action = controller.action("search"); assertThat(action).isNotNull(); assertThat(action.handler()).isInstanceOf(RailsHandler.class); assertThat(action.responseExampleAsString()).isNotEmpty(); assertThat(action.params()).hasSize(2); }
@Test public void define_suggestions_action() throws Exception { WebService.Action action = controller.action("suggestions"); assertThat(action).isNotNull(); assertThat(action.isInternal()).isTrue(); assertThat(action.isPost()).isFalse(); assertThat(action.handler()).isInstanceOf(RailsHandler.class); assertThat(action.responseExampleAsString()).isNotEmpty(); assertThat(action.params()).hasSize(2); }
public void execute( InternalRequest request, ServletResponse response, String controllerPath, String actionKey) { try { WebService.Action action = getAction(controllerPath, actionKey); request.setAction(action); verifyRequest(action, request); action.handler().handle(request, response); } catch (IllegalArgumentException e) { // TODO replace by BadRequestException in Request#requiredParam() sendError(400, e.getMessage(), response); } catch (ServerException e) { // TODO support ServerException l10n messages sendError(e.httpCode(), e.getMessage(), response); } catch (Exception e) { // TODO implement Request.toString() LoggerFactory.getLogger(getClass()).error("Fail to process request " + request, e); sendError(500, e.getMessage(), response); } }