@Test public void post_is_post() { PostRequest request = new PostRequest("api/issues/search"); assertThat(request.getMethod()).isEqualTo(WsRequest.Method.POST); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/restart">Further information about this action online (including a response example)</a> * @since 4.3 */ public void restart() { call( new PostRequest(path("restart")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/ce/cancel_all">Further information about this action online (including a response example)</a> * @since 5.2 */ public void cancelAll() { call( new PostRequest(path("cancel_all")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/ce/pause">Further information about this action online (including a response example)</a> * @since 7.2 */ public void pause() { call( new PostRequest(path("pause")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/system/migrate_db">Further information about this action online (including a response example)</a> * @since 5.2 */ public String migrateDb() { return call( new PostRequest(path("migrate_db")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/skip_onboarding_tutorial">Further information about this action online (including a response example)</a> * @since 6.5 */ public void skipOnboardingTutorial() { call( new PostRequest(path("skip_onboarding_tutorial")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/ce/resume">Further information about this action online (including a response example)</a> * @since 7.2 */ public void resume() { call( new PostRequest(path("resume")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/plugins/cancel_all">Further information about this action online (including a response example)</a> * @since 5.2 */ public void cancelAll() { call( new PostRequest(path("cancel_all")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/organizations/enable_support">Further information about this action online (including a response example)</a> * @since 6.3 */ public void enableSupport() { call( new PostRequest(path("enable_support")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/authentication/logout">Further information about this action online (including a response example)</a> * @since 6.3 */ public void logout() { call( new PostRequest(path("logout")) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/issues/delete_comment">Further information about this action online (including a response example)</a> * @since 3.6 */ public DeleteCommentResponse deleteComment(DeleteCommentRequest request) { return call( new PostRequest(path("delete_comment")) .setParam("comment", request.getComment()), DeleteCommentResponse.parser()); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/ce/cancel">Further information about this action online (including a response example)</a> * @since 5.2 */ public void cancel(CancelRequest request) { call( new PostRequest(path("cancel")) .setParam("id", request.getId()) .setMediaType(MediaTypes.JSON) ).content(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/roots/set_root">Further information about this action online (including a response example)</a> * @since 6.2 */ public void setRoot(SetRootRequest request) { call( new PostRequest(path("set_root")) .setParam("login", request.getLogin()) .setMediaType(MediaTypes.JSON) ).content(); }
@Test public void empty_parts_and_params_by_default() { PostRequest request = new PostRequest("api/issues/search"); assertThat(request.getParts()).isEmpty(); assertThat(request.getParams()).isEmpty(); }
/** * * This is part of the internal API. * This is a POST request. * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualityprofiles/copy">Further information about this action online (including a response example)</a> * @since 5.2 */ public CopyWsResponse copy(CopyRequest request) { return call( new PostRequest(path("copy")) .setParam("fromKey", request.getFromKey()) .setParam("toName", request.getToName()), CopyWsResponse.parser()); }
@Test public void add_part() throws IOException { PostRequest request = new PostRequest("api/issues/search"); File reportFile = temp.newFile(); request.setPart("report", new PostRequest.Part(MediaTypes.JSON, reportFile)); assertThat(request.getParts()).hasSize(1); PostRequest.Part part = request.getParts().get("report"); assertThat(part.getMediaType()).isEqualTo(MediaTypes.JSON); assertThat(part.getFile()).isSameAs(reportFile); } }
@Test public void add_header_to_POST_request() throws Exception { answerHelloWorld(); PostRequest request = new PostRequest("api/issues/search") .setHeader("X-Foo", "fooz") .setHeader("X-Bar", "barz"); underTest = HttpConnector.newBuilder().url(serverUrl).build(); underTest.call(request); RecordedRequest recordedRequest = server.takeRequest(); assertThat(recordedRequest.getHeader("X-Foo")).isEqualTo("fooz"); assertThat(recordedRequest.getHeader("X-Bar")).isEqualTo("barz"); }
@Test public void http_error() throws Exception { server.enqueue(new MockResponse().setResponseCode(404)); PostRequest request = new PostRequest("api/issues/search"); underTest = HttpConnector.newBuilder().url(serverUrl).build(); WsResponse wsResponse = underTest.call(request); assertThat(wsResponse.code()).isEqualTo(404); }
@Test public void override_timeout_on_post() { underTest = HttpConnector.newBuilder().url(serverUrl).build(); // Headers are not affected by setBodyDelay, let's throttle the answer server.enqueue(new MockResponse().throttleBody(1,100, TimeUnit.MILLISECONDS).setBody("Hello delayed")); expectedException.expect(IllegalStateException.class); expectedException.expectCause(IsInstanceOf.instanceOf(SocketTimeoutException.class)); WsResponse call = underTest.call(new PostRequest("/").setTimeOutInMs(5)); assertThat(call.content()).equals("Hello delayed"); }
@Test public void override_timeout_on_post_with_redirect() { underTest = HttpConnector.newBuilder().url(serverUrl).build(); server.enqueue(new MockResponse().setResponseCode(301).setHeader("Location:", "/redirect")); // Headers are not affected by setBodyDelay, let's throttle the answer server.enqueue(new MockResponse().throttleBody(1,100, TimeUnit.MILLISECONDS).setBody("Hello delayed")); expectedException.expect(IllegalStateException.class); expectedException.expectCause(IsInstanceOf.instanceOf(SocketTimeoutException.class)); WsResponse call = underTest.call(new PostRequest("/").setTimeOutInMs(5)); assertThat(call.content()).equals("Hello delayed"); }