@Test public void define_delete_action() { WebService.Action action = ws.getDef(); assertThat(action).isNotNull(); assertThat(action.isPost()).isTrue(); assertThat(action.handler()).isNotNull(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).hasSize(1); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("edit_comment"); assertThat(action.isPost()).isTrue(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(2); assertThat(action.responseExample()).isNotNull(); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("changelog"); assertThat(action.isPost()).isFalse(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(1); assertThat(action.responseExample()).isNotNull(); }
@Test public void verify_definition() { WebService.Action action = wsTester.getDef(); assertThat(action.key()).isEqualTo("search"); assertThat(action.isInternal()).isTrue(); assertThat(action.isPost()).isFalse(); assertThat(action.since()).isEqualTo("6.2"); assertThat(action.description()).isEqualTo("Search for root users.<br/>" + "Requires to be root."); assertThat(action.responseExample()).isNotNull(); assertThat(action.deprecatedKey()).isNull(); assertThat(action.deprecatedSince()).isNull(); assertThat(action.handler()).isSameAs(underTest); assertThat(action.params()).isEmpty(); }
private static void writeAction(JsonWriter writer, WebService.Action action, boolean includeInternals) { if (includeInternals || !action.isInternal()) { writer.beginObject(); writer.prop("key", action.key()); writer.prop("description", action.description()); writer.prop("since", action.since()); writer.prop("deprecatedSince", action.deprecatedSince()); writer.prop("internal", action.isInternal()); writer.prop("post", action.isPost()); writer.prop("hasResponseExample", action.responseExample() != null); writeChangelog(writer, action); writeParameters(writer, action, includeInternals); writer.endObject(); } }
@Test public void action_updatable_is_defined() { logInAsSystemAdministrator(); WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly("updates"); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isFalse(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNotNull(); }
@Test public void action_available_is_defined() { logInAsSystemAdministrator(); WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly("available"); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isFalse(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNotNull(); }
@Test public void action_cancel_all_is_defined() { WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly("cancel_all"); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isTrue(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).isEmpty(); }
@Test public void action_pending_is_defined() { logInAsSystemAdministrator(); WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly("pending"); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isFalse(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNotNull(); }
@Test public void action_updates_is_defined() { WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly("upgrades"); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isFalse(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNotNull(); assertThat(action.params()).isEmpty(); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("set_type"); assertThat(action.isPost()).isTrue(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(2); assertThat(action.responseExample()).isNotNull(); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("delete_comment"); assertThat(action.isPost()).isTrue(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(1); assertThat(action.responseExample()).isNotNull(); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("bulk_change"); assertThat(action.isPost()).isTrue(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(10); assertThat(action.responseExample()).isNotNull(); }
@Test public void verify_definition() { WebService.Action definition = underTest.getDef(); assertThat(definition.key()).isEqualTo("health"); assertThat(definition.isPost()).isFalse(); assertThat(definition.description()).isNotEmpty(); assertThat(definition.since()).isEqualTo("6.6"); assertThat(definition.isInternal()).isFalse(); assertThat(definition.responseExample()).isNotNull(); assertThat(definition.params()).isEmpty(); }
@Test public void verify_definition() { WebService.Action definition = underTest.getDef(); assertThat(definition.key()).isEqualTo("health"); assertThat(definition.isPost()).isFalse(); assertThat(definition.description()).isNotEmpty(); assertThat(definition.since()).isEqualTo("6.6"); assertThat(definition.isInternal()).isFalse(); assertThat(definition.responseExample()).isNotNull(); assertThat(definition.params()).isEmpty(); }
@Test public void test_definition() { WebService.Action action = tester.getDef(); assertThat(action.key()).isEqualTo("set_severity"); assertThat(action.isPost()).isTrue(); assertThat(action.isInternal()).isFalse(); assertThat(action.params()).hasSize(2); assertThat(action.responseExample()).isNotNull(); }
@Test public void action_installed_is_defined() { Action action = tester.getDef(); assertThat(action.isPost()).isFalse(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNotNull(); }
@Test public void test_example() { userSession.logIn().setSystemAdministrator(); when(workerCountProvider.get()).thenReturn(5); WsActionTester ws = new WsActionTester(new WorkerCountAction(userSession, workerCountProvider)); String response = ws.newRequest().execute().getInput(); assertJson(response).isSimilarTo(ws.getDef().responseExample()); } }
@Test public void action_status_is_defined() { WebService.Action action = underTest.getDef(); assertThat(action.isPost()).isFalse(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNotNull(); assertThat(action.params()).isEmpty(); }
@Test public void response_example() { MetricWs metricWs = new MetricWs(); metricWs.define(context); WebService.Action action = context.controller("api/metric").action("create"); assertThat(action.responseExampleFormat()).isEqualTo("txt"); assertThat(action.responseExample()).isNotNull(); assertThat(StringUtils.trim(action.responseExampleAsString())).isEqualTo("example of WS response"); }