2 * ============LICENSE_START=======================================================
3 * dcaegen2-collectors-veshv
4 * ================================================================================
5 * Copyright (C) 2018 NOKIA
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dcae.collectors.veshv.impl.adapters
22 import org.jetbrains.spek.api.Spek
23 import org.jetbrains.spek.api.dsl.describe
24 import org.jetbrains.spek.api.dsl.given
25 import org.jetbrains.spek.api.dsl.it
26 import reactor.core.publisher.Mono
27 import reactor.netty.http.client.HttpClient
28 import reactor.netty.http.server.HttpServer
29 import reactor.test.StepVerifier
30 import reactor.test.test
33 * @author Jakub Dudycz <jakub.dudycz@nokia.com>
36 internal object HttpAdapterTest : Spek({
37 describe("HttpAdapter") {
39 val httpServer = HttpServer.create()
42 routes.get("/url") { req, resp ->
43 resp.sendString(Mono.just(req.uri()))
47 val baseUrl = "http://${httpServer.host()}:${httpServer.port()}"
48 val httpAdapter = HttpAdapter(HttpClient.create().baseUrl(baseUrl))
51 httpServer.disposeNow()
54 given("url without query params") {
57 it("should not append query string") {
58 httpAdapter.get(url).test()
64 given("url with query params") {
65 val queryParams = mapOf(Pair("p", "the-value"))
68 it("should add them as query string to the url") {
69 httpAdapter.get(url, queryParams).test()
70 .expectNext("/url?p=the-value")
75 given("invalid url") {
76 val invalidUrl = "/wtf"
78 it("should interrupt the flux") {
80 .create(httpAdapter.get(invalidUrl))