Search in sources :

Example 16 with MultiMap

use of io.vertx.reactivex.core.MultiMap in project knotx by Cognifide.

the class SampleApplicationHeadersTest method testGetRequest.

private void testGetRequest(TestContext context, String url) {
    HttpClient client = Vertx.newInstance(vertx.vertx()).createHttpClient();
    Async async = context.async();
    client.getNow(KNOTX_SERVER_PORT, KNOTX_SERVER_ADDRESS, url, resp -> {
        MultiMap headers = resp.headers();
        headers.names().forEach(name -> {
            context.assertEquals(resp.statusCode(), 200, "Wrong status code received.");
            context.assertTrue(expectedHeaders.contains(name), "Header " + name + " is not expected.");
            context.assertEquals(expectedHeaders.get(name), headers.get(name), "Wrong value of " + name + " header.");
        });
        async.complete();
    });
}
Also used : MultiMap(io.vertx.reactivex.core.MultiMap) Async(io.vertx.ext.unit.Async) HttpClient(io.vertx.reactivex.core.http.HttpClient)

Example 17 with MultiMap

use of io.vertx.reactivex.core.MultiMap in project knotx by Cognifide.

the class HttpClientFacade method updateRequestHeaders.

private void updateRequestHeaders(HttpRequest<Buffer> request, ClientRequest serviceRequest, ServiceMetadata serviceMetadata) {
    MultiMap filteredHeaders = getFilteredHeaders(serviceRequest.getHeaders(), serviceMetadata.getAllowedRequestHeaderPatterns());
    filteredHeaders.names().forEach(headerName -> filteredHeaders.getAll(headerName).forEach(value -> request.headers().add(headerName, value)));
    if (customRequestHeader.containsKey("name") && customRequestHeader.containsKey("value")) {
        request.headers().set(customRequestHeader.getString("name"), customRequestHeader.getString("value"));
    }
}
Also used : HttpResponse(io.vertx.reactivex.ext.web.client.HttpResponse) UnsupportedServiceException(io.knotx.adapter.common.exception.UnsupportedServiceException) MultiMapCollector(io.knotx.http.MultiMapCollector) Single(io.reactivex.Single) LoggerFactory(io.vertx.core.logging.LoggerFactory) WebClient(io.vertx.reactivex.ext.web.client.WebClient) AdapterServiceContractException(io.knotx.adapter.common.exception.AdapterServiceContractException) ClientResponse(io.knotx.dataobjects.ClientResponse) DataObjectsUtil(io.knotx.util.DataObjectsUtil) MultiMap(io.vertx.reactivex.core.MultiMap) List(java.util.List) AdapterRequest(io.knotx.dataobjects.AdapterRequest) Pair(org.apache.commons.lang3.tuple.Pair) UriTransformer(io.knotx.adapter.common.placeholders.UriTransformer) AllowedHeadersFilter(io.knotx.http.AllowedHeadersFilter) HttpMethod(io.vertx.core.http.HttpMethod) ClientRequest(io.knotx.dataobjects.ClientRequest) HttpRequest(io.vertx.reactivex.ext.web.client.HttpRequest) Optional(java.util.Optional) JsonObject(io.vertx.core.json.JsonObject) Pattern(java.util.regex.Pattern) Logger(io.vertx.core.logging.Logger) Buffer(io.vertx.reactivex.core.buffer.Buffer) MultiMap(io.vertx.reactivex.core.MultiMap)

Example 18 with MultiMap

use of io.vertx.reactivex.core.MultiMap in project knotx by Cognifide.

the class UriTransformerReplaceTest method getParamsMultiMap.

private static MultiMap getParamsMultiMap() {
    MultiMap map = MultiMap.caseInsensitiveMultiMap();
    map.add("q", "knot & x");
    map.add("action", "/some/action/path");
    return map;
}
Also used : MultiMap(io.vertx.reactivex.core.MultiMap)

Example 19 with MultiMap

use of io.vertx.reactivex.core.MultiMap in project knotx by Cognifide.

the class UriTransformerReplaceTest method getHeadersMultiMap.

private static MultiMap getHeadersMultiMap() {
    MultiMap map = MultiMap.caseInsensitiveMultiMap();
    map.add("authorizationId", "486434684345");
    return map;
}
Also used : MultiMap(io.vertx.reactivex.core.MultiMap)

Aggregations

MultiMap (io.vertx.reactivex.core.MultiMap)19 Async (io.vertx.ext.unit.Async)5 WebClient (io.vertx.reactivex.ext.web.client.WebClient)5 KnotxConfiguration (io.knotx.junit.rule.KnotxConfiguration)4 JsonObject (io.vertx.core.json.JsonObject)4 ClientResponse (io.knotx.dataobjects.ClientResponse)3 List (java.util.List)3 Test (org.junit.Test)3 UnsupportedServiceException (io.knotx.adapter.common.exception.UnsupportedServiceException)2 AdapterRequest (io.knotx.dataobjects.AdapterRequest)2 ClientRequest (io.knotx.dataobjects.ClientRequest)2 Single (io.reactivex.Single)2 HttpMethod (io.vertx.core.http.HttpMethod)2 Pattern (java.util.regex.Pattern)2 Lists (com.google.common.collect.Lists)1 Coercion (com.googlecode.zohhak.api.Coercion)1 TestWith (com.googlecode.zohhak.api.TestWith)1 AdapterServiceContractException (io.knotx.adapter.common.exception.AdapterServiceContractException)1 HttpAdapterConfiguration (io.knotx.adapter.common.http.HttpAdapterConfiguration)1 HttpClientFacade (io.knotx.adapter.common.http.HttpClientFacade)1