Fix sonars from depeendency upgrade
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / test / java / org / onap / policy / controlloop / actorserviceprovider / parameters / BidirectionalTopicConfigTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020-2021 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.Arrays;
28 import java.util.List;
29 import java.util.concurrent.Executor;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mock;
34 import org.mockito.junit.MockitoJUnitRunner;
35 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
36 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
37 import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
38 import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
39
40 @RunWith(MockitoJUnitRunner.class)
41 public class BidirectionalTopicConfigTest {
42     private static final String MY_SINK = "my-sink";
43     private static final String MY_SOURCE = "my-source";
44     private static final int TIMEOUT_SEC = 10;
45
46     @Mock
47     private BidirectionalTopicManager topicManager;
48     @Mock
49     private BidirectionalTopicHandler topicHandler;
50     @Mock
51     private Forwarder forwarder;
52     @Mock
53     private Executor executor;
54
55     private BidirectionalTopicConfig config;
56
57     /**
58      * Sets up.
59      */
60     @Before
61     public void setUp() {
62         List<SelectorKey> keys = Arrays.asList(new SelectorKey(""));
63
64         when(topicManager.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(topicHandler);
65         when(topicHandler.addForwarder(keys)).thenReturn(forwarder);
66
67         BidirectionalTopicParams params = BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE)
68                         .timeoutSec(TIMEOUT_SEC).build();
69         config = new BidirectionalTopicConfig(executor, params, topicManager, keys);
70     }
71
72     @Test
73     public void test() {
74         assertSame(executor, config.getBlockingExecutor());
75         assertSame(topicHandler, config.getTopicHandler());
76         assertSame(forwarder, config.getForwarder());
77         assertEquals(1000L * TIMEOUT_SEC, config.getTimeoutMs());
78     }
79 }