io.vertx.ext.web.client.HttpRequest Java Examples
The following examples show how to use
io.vertx.ext.web.client.HttpRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_explode_object with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormExplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/explode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieObjectFormExplode("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #2
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_noexplode_string with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormNoexplodeString( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/noexplode/string"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieParam("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #3
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_noexplode_empty with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormNoexplodeEmpty( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/noexplode/empty"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieParam("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #4
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_form_explode_empty with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryFormExplodeEmpty( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/form/explode/empty"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryParam("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #5
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_noexplode_object with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormNoexplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/noexplode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieObjectForm("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #6
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_pipeDelimited_noexplode_object with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryPipeDelimitedNoexplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/pipeDelimited/noexplode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryObjectPipeDelimited("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #7
Source File: VertxJobsServiceTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Test void testGetScheduleTimeJobNotFound(@Mock HttpRequest<Buffer> request, @Mock HttpResponse<Buffer> response) { when(webClient.get(anyString())).thenReturn(request); AsyncResult<HttpResponse<Buffer>> asyncResult = mock(AsyncResult.class); when(asyncResult.succeeded()).thenReturn(true); when(asyncResult.result()).thenReturn(response); when(response.statusCode()).thenReturn(404); doAnswer(invocationOnMock -> { Handler<AsyncResult<HttpResponse<Buffer>>> handler = invocationOnMock.getArgument(0); executor.submit(() -> handler.handle(asyncResult)); return null; }).when(request).send(any()); assertThatThrownBy(() -> tested.getScheduledTime("123")) .hasCauseExactlyInstanceOf(JobNotFoundException.class); verify(webClient).get("/jobs/123"); }
Example #8
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call header_simple_explode_string with empty body. * @param color Parameter color inside header * @param handler The handler for the asynchronous request */ public void headerSimpleExplodeString( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/header/simple/explode/string"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addHeaderParam("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #9
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_spaceDelimited_noexplode_object with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void querySpaceDelimitedNoexplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/spaceDelimited/noexplode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryObjectSpaceDelimited("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #10
Source File: PrometheusBasedResourceLimitChecks.java From hono with Eclipse Public License 2.0 | 6 votes |
private HttpRequest<JsonObject> newQueryRequest(final String query) { final HttpRequest<JsonObject> request = client.get(config.getPort(), config.getHost(), QUERY_URI) .addQueryParam("query", query) .expect(ResponsePredicate.SC_OK) .as(BodyCodec.jsonObject()); if (config.getQueryTimeout() > 0) { // enables timeout for Prometheus queries via HTTP API request.timeout(config.getQueryTimeout()); } if (!Strings.isNullOrEmpty(config.getUsername()) && !Strings.isNullOrEmpty(config.getPassword())) { request.basicAuthentication(config.getUsername(), config.getPassword()); } return request; }
Example #11
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call header_simple_explode_object with empty body. * @param color Parameter color inside header * @param handler The handler for the asynchronous request */ public void headerSimpleExplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/header/simple/explode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addHeaderObjectSimpleExplode("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #12
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_form_explode_string with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryFormExplodeString( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/form/explode/string"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryParam("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #13
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_form_noexplode_array with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryFormNoexplodeArray( List<Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/form/noexplode/array"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryArrayForm("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #14
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_noexplode_empty with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormNoexplodeEmpty( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/noexplode/empty"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieParam("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #15
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_explode_string with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormExplodeString( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/explode/string"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieParam("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #16
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_explode_array with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormExplodeArray( List<Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/explode/array"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieArrayFormExplode("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #17
Source File: VertxJobsServiceTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Test void testScheduleProcessInstanceJob(@Mock HttpRequest<Buffer> request) { when(webClient.post(anyString())).thenReturn(request); ProcessInstanceJobDescription processInstanceJobDescription = ProcessInstanceJobDescription.of(123, ExactExpirationTime.now(), "processInstanceId", "processId"); tested.scheduleProcessInstanceJob(processInstanceJobDescription); verify(webClient).post("/jobs"); ArgumentCaptor<Job> jobArgumentCaptor = forClass(Job.class); verify(request).sendJson(jobArgumentCaptor.capture(), any(Handler.class)); Job job = jobArgumentCaptor.getValue(); assertThat(job.getId()).isEqualTo(processInstanceJobDescription.id()); assertThat(job.getExpirationTime()).isEqualTo(processInstanceJobDescription.expirationTime().get()); assertThat(job.getProcessInstanceId()).isEqualTo(processInstanceJobDescription.processInstanceId()); assertThat(job.getProcessId()).isEqualTo(processInstanceJobDescription.processId()); }
Example #18
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call header_simple_noexplode_array with empty body. * @param color Parameter color inside header * @param handler The handler for the asynchronous request */ public void headerSimpleNoexplodeArray( List<Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/header/simple/noexplode/array"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addHeaderArraySimple("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #19
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_form_explode_string with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryFormExplodeString( String color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/form/explode/string"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryParam("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #20
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_noexplode_array with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormNoexplodeArray( List<Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/noexplode/array"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieArrayForm("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #21
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_form_noexplode_object with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryFormNoexplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/form/noexplode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryObjectForm("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #22
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call path_multi_simple_label with empty body. * @param colorSimple Parameter color_simple inside path * @param colorLabel Parameter color_label inside path * @param handler The handler for the asynchronous request */ public void pathMultiSimpleLabel( String colorSimple, List<Object> colorLabel, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (colorSimple == null) throw new RuntimeException("Missing parameter colorSimple in path"); if (colorLabel == null) throw new RuntimeException("Missing parameter colorLabel in path"); // Generate the uri String uri = "/path/multi/{color_simple}{.color_label}/test"; uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template uri = uri.replace("{color_simple}", this.renderPathParam("color_simple", colorSimple)); uri = uri.replace("{color_label}", this.renderPathArrayLabel("color_label", colorLabel)); HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #23
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call cookie_form_noexplode_array with empty body. * @param color Parameter color inside cookie * @param handler The handler for the asynchronous request */ public void cookieFormNoexplodeArray( List<Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/cookie/form/noexplode/array"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.renderCookieArrayForm("color", color, requestCookies); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #24
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 6 votes |
/** * Call query_pipeDelimited_noexplode_object with empty body. * @param color Parameter color inside query * @param handler The handler for the asynchronous request */ public void queryPipeDelimitedNoexplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color"); // Generate the uri String uri = "/query/pipeDelimited/noexplode/object"; HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); if (color != null) this.addQueryObjectPipeDelimited("color", color, request); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #25
Source File: ApiWebTestBase.java From vertx-web with Apache License 2.0 | 5 votes |
public void testRequestWithForm(HttpMethod method, String path, FormType formType, MultiMap formMap, int statusCode, String statusMessage) throws Exception { CountDownLatch latch = new CountDownLatch(1); HttpRequest<Buffer> request = webClient .request(method, 8080, "localhost", path); request .putHeader("Content-Type", formType.headerValue) .sendForm(formMap, (ar) -> { assertEquals(statusCode, ar.result().statusCode()); assertEquals(statusMessage, ar.result().statusMessage()); latch.countDown(); }); awaitLatch(latch); }
Example #26
Source File: ApiWebTestBase.java From vertx-web with Apache License 2.0 | 5 votes |
public void testRequestWithMultipartForm(HttpMethod method, String path, MultipartForm formMap, int statusCode, String statusMessage) throws Exception { CountDownLatch latch = new CountDownLatch(1); HttpRequest<Buffer> request = webClient .request(method, 8080, "localhost", path); request .sendMultipartForm(formMap, (ar) -> { if (ar.failed()) fail(ar.cause()); assertEquals(statusCode, ar.result().statusCode()); assertEquals(statusMessage, ar.result().statusMessage()); latch.countDown(); }); awaitLatch(latch); }
Example #27
Source File: WebClientDatabindTest.java From vertx-web with Apache License 2.0 | 5 votes |
@Test public void testResponseBodyAsJsonMapped() throws Exception { JsonObject expected = new JsonObject().put("cheese", "Goat Cheese").put("wine", "Condrieu"); server.requestHandler(req -> req.response().end(expected.encode())); startServer(); HttpRequest<Buffer> get = webClient.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath"); get .as(BodyCodec.json(WineAndCheese.class)) .send(onSuccess(resp -> { assertEquals(200, resp.statusCode()); assertEquals(new WineAndCheese().setCheese("Goat Cheese").setWine("Condrieu"), resp.body()); testComplete(); })); await(); }
Example #28
Source File: ApiClient.java From vertx-web with Apache License 2.0 | 4 votes |
/** * Call path_label_explode_array with empty body. * @param color Parameter color inside path * @param handler The handler for the asynchronous request */ public void pathLabelExplodeArray( List<Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color in path"); // Generate the uri String uri = "/path/label/explode/array/{.color*}"; uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template uri = uri.replace("{color}", this.renderPathArrayLabelExplode("color", color)); HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #29
Source File: ParametersTestAPIClient.java From vertx-web with Apache License 2.0 | 4 votes |
/** * Call path_simple_explode_object with empty body. * @param color Parameter color inside path * @param handler The handler for the asynchronous request */ public void pathSimpleExplodeObject( Map<String, Object> color, Handler<AsyncResult<HttpResponse>> handler) { // Check required params if (color == null) throw new RuntimeException("Missing parameter color in path"); // Generate the uri String uri = "/path/simple/explode/object/{color*}"; uri = uri.replaceAll("\\{{1}([.;?*+]*([^\\{\\}.;?*+]+)[^\\}]*)\\}{1}", "{$2}"); //Remove * . ; ? from url template uri = uri.replace("{color}", this.renderPathObjectSimpleExplode("color", color)); HttpRequest request = client.get(uri); MultiMap requestCookies = MultiMap.caseInsensitiveMultiMap(); this.renderAndAttachCookieHeader(request, requestCookies); request.send(handler); }
Example #30
Source File: WebClientBase.java From vertx-web with Apache License 2.0 | 4 votes |
@Override public HttpRequest<Buffer> get(String requestURI) { return request(HttpMethod.GET, requestURI); }