Clean up of JUnit 4 dependencies
[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-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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.controlloop.actorserviceprovider.parameters;
23
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;
27
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;
36
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;
42
43     @Mock
44     private HttpClient client;
45     @Mock
46     private HttpClientFactory factory;
47     @Mock
48     private Executor executor;
49
50     private HttpConfig config;
51
52     /**
53      * Sets up.
54      */
55     @BeforeEach
56      void setUp() {
57         when(factory.get(MY_CLIENT)).thenReturn(client);
58
59         HttpParams params = HttpParams.builder().clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
60         config = new HttpConfig(executor, params, factory);
61     }
62
63     @Test
64      void test() {
65         assertSame(executor, config.getBlockingExecutor());
66         assertSame(client, config.getClient());
67         assertEquals(MY_PATH, config.getPath());
68         assertEquals(1000L * TIMEOUT_SEC, config.getTimeoutMs());
69     }
70 }