Point to latest snapshot
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / test / java / org / onap / policy / controlloop / actorserviceprovider / parameters / HttpConfigTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.controlloop.actorserviceprovider.parameters;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertSame;
25 import static org.mockito.Mockito.when;
26
27 import java.util.concurrent.Executor;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.mockito.Mock;
31 import org.mockito.MockitoAnnotations;
32 import org.onap.policy.common.endpoints.http.client.HttpClient;
33 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
34
35 public class HttpConfigTest {
36     private static final String MY_CLIENT = "my-client";
37     private static final String MY_PATH = "my-path";
38     private static final int TIMEOUT_SEC = 10;
39
40     @Mock
41     private HttpClient client;
42     @Mock
43     private HttpClientFactory factory;
44     @Mock
45     private Executor executor;
46
47     private HttpConfig config;
48
49     /**
50      * Sets up.
51      */
52     @Before
53     public void setUp() {
54         MockitoAnnotations.initMocks(this);
55
56         when(factory.get(MY_CLIENT)).thenReturn(client);
57
58         HttpParams params = HttpParams.builder().clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
59         config = new HttpConfig(executor, params, factory);
60     }
61
62     @Test
63     public void test() {
64         assertSame(executor, config.getBlockingExecutor());
65         assertSame(client, config.getClient());
66         assertEquals(MY_PATH, config.getPath());
67         assertEquals(1000L * TIMEOUT_SEC, config.getTimeoutMs());
68     }
69 }