2 * ============LICENSE_START=======================================================
3 * DCAEGEN2-SERVICES-SDK
4 * ================================================================================
5 * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
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.dcaegen2.services.sdk.rest.services.aai.client.api.get;
22 import static org.mockito.ArgumentMatchers.any;
23 import static org.mockito.ArgumentMatchers.argThat;
24 import static org.mockito.BDDMockito.given;
25 import static org.mockito.Mockito.verify;
26 import static org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.AaiClientConfigurations.secureConfiguration;
28 import io.vavr.collection.HashMap;
29 import io.vavr.collection.Map;
30 import org.junit.jupiter.api.Test;
31 import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.AaiClientConfiguration;
32 import org.onap.dcaegen2.services.sdk.rest.services.aai.client.api.AbstractHttpClientTest;
33 import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
34 import reactor.core.publisher.Mono;
35 import reactor.test.StepVerifier;
37 class AaiHttpGetClientTest extends AbstractHttpClientTest {
40 void getAaiResponse_shouldCallGetMethod_withGivenAaiHeaders() {
43 Map<String, String> headers = HashMap.of("sample-key", "sample-value");
44 AaiHttpGetClient cut = new AaiHttpGetClient(secureConfiguration(headers.toJavaMap()), httpClient);
46 given(httpClient.call(any(HttpRequest.class)))
47 .willReturn(Mono.just(response));
51 .create(cut.getAaiResponse(aaiModel))
57 .call(argThat(httpRequest -> httpRequest.customHeaders().equals(headers)));
61 void getAaiResponse_shouldCallGetMethod_withProperUri() {
64 AaiClientConfiguration configuration = secureConfiguration();
65 String uri = constructAaiUri(configuration, aaiModel.getCorrelationId());
66 AaiHttpGetClient cut = new AaiHttpGetClient(configuration, httpClient);
68 given(httpClient.call(any(HttpRequest.class)))
69 .willReturn(Mono.just(response));
73 .create(cut.getAaiResponse(aaiModel))
79 .call(argThat(httpRequest -> httpRequest.url().equals(uri)));