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.Arrays;
29 import java.util.List;
30 import java.util.concurrent.Executor;
31 import org.junit.jupiter.api.BeforeEach;
32 import org.junit.jupiter.api.Test;
33 import org.junit.jupiter.api.extension.ExtendWith;
34 import org.junit.runner.RunWith;
35 import org.mockito.Mock;
36 import org.mockito.junit.MockitoJUnitRunner;
37 import org.mockito.junit.jupiter.MockitoExtension;
38 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
39 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
40 import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
41 import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
43 @ExtendWith(MockitoExtension.class)
44 class BidirectionalTopicConfigTest {
45 private static final String MY_SINK = "my-sink";
46 private static final String MY_SOURCE = "my-source";
47 private static final int TIMEOUT_SEC = 10;
50 private BidirectionalTopicManager topicManager;
52 private BidirectionalTopicHandler topicHandler;
54 private Forwarder forwarder;
56 private Executor executor;
58 private BidirectionalTopicConfig config;
65 List<SelectorKey> keys = Arrays.asList(new SelectorKey(""));
67 when(topicManager.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(topicHandler);
68 when(topicHandler.addForwarder(keys)).thenReturn(forwarder);
70 BidirectionalTopicParams params = BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE)
71 .timeoutSec(TIMEOUT_SEC).build();
72 config = new BidirectionalTopicConfig(executor, params, topicManager, keys);
77 assertSame(executor, config.getBlockingExecutor());
78 assertSame(topicHandler, config.getTopicHandler());
79 assertSame(forwarder, config.getForwarder());
80 assertEquals(1000L * TIMEOUT_SEC, config.getTimeoutMs());