2 * ============LICENSE_START====================================
3 * DCAEGEN2-SERVICES-SDK
4 * =========================================================
5 * Copyright (C) 2019 Nokia. 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=====================================
21 package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.mockito.ArgumentMatchers.any;
25 import static org.mockito.ArgumentMatchers.anyString;
26 import static org.mockito.BDDMockito.given;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.verify;
30 import com.google.gson.JsonObject;
31 import java.net.InetSocketAddress;
32 import org.junit.jupiter.api.Test;
33 import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.impl.adapters.CloudHttpClient;
34 import reactor.core.publisher.Mono;
37 * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
38 * @since February 2019
40 class CbsClientImplTest {
41 private final CloudHttpClient httpClient = mock(CloudHttpClient.class);
44 void shouldFetchUsingProperUrl() {
46 InetSocketAddress cbsAddress = InetSocketAddress.createUnresolved("cbshost", 6969);
47 String serviceName = "dcaegen2-ves-collector";
48 final CbsClientImpl cut = CbsClientImpl.create(httpClient, cbsAddress, serviceName);
49 final JsonObject httpResponse = new JsonObject();
50 given(httpClient.callHttpGet(anyString(), any(Class.class))).willReturn(Mono.just(httpResponse));
53 final JsonObject result = cut.get().block();
56 verify(httpClient).callHttpGet("http://cbshost:6969/service_component/dcaegen2-ves-collector", JsonObject.class);
57 assertThat(result).isSameAs(httpResponse);