2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2024 Nordix Foundation
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controlloop.actorserviceprovider.parameters;
24 import static org.junit.jupiter.api.Assertions.assertEquals;
25 import static org.junit.jupiter.api.Assertions.assertSame;
26 import static org.mockito.Mockito.when;
28 import java.util.concurrent.Executor;
29 import org.junit.jupiter.api.BeforeEach;
30 import org.junit.jupiter.api.Test;
31 import org.junit.jupiter.api.extension.ExtendWith;
32 import org.mockito.Mock;
33 import org.mockito.junit.jupiter.MockitoExtension;
34 import org.onap.policy.common.endpoints.http.client.HttpClient;
35 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
37 @ExtendWith(MockitoExtension.class)
38 class HttpConfigTest {
39 private static final String MY_CLIENT = "my-client";
40 private static final String MY_PATH = "my-path";
41 private static final int TIMEOUT_SEC = 10;
44 private HttpClient client;
46 private HttpClientFactory factory;
48 private Executor executor;
50 private HttpConfig config;
57 when(factory.get(MY_CLIENT)).thenReturn(client);
59 HttpParams params = HttpParams.builder().clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
60 config = new HttpConfig(executor, params, factory);
65 assertSame(executor, config.getBlockingExecutor());
66 assertSame(client, config.getClient());
67 assertEquals(MY_PATH, config.getPath());
68 assertEquals(1000L * TIMEOUT_SEC, config.getTimeoutMs());