Fix the Sonar Findings
[holmes/engine-management.git] / engine-d / src / test / java / org / onap / holmes / engine / dmaap / SubscriberActionTest.java
1 /*
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.holmes.engine.dmaap;
17
18 import java.util.HashMap;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.onap.holmes.dsa.dmaappolling.Subscriber;
22 import org.powermock.api.easymock.PowerMock;
23 import org.powermock.reflect.Whitebox;
24
25 public class SubscriberActionTest {
26
27     private SubscriberAction subscriberAction;
28
29     @Before
30     public void setUp() {
31         subscriberAction = new SubscriberAction();
32         HashMap<String, DMaaPAlarmPolling> dMaaPAlarmPollingHashMap = new HashMap<>();
33         DMaaPAlarmPolling dMaaPAlarmPolling = new DMaaPAlarmPolling(null, null);
34         dMaaPAlarmPollingHashMap.put("test", dMaaPAlarmPolling);
35         DMaaPAlarmPolling dMaaPAlarmPolling1 = new DMaaPAlarmPolling(null, null);
36         dMaaPAlarmPollingHashMap.put("testTopic", dMaaPAlarmPolling1);
37         Whitebox.setInternalState(subscriberAction, "pollingTasks", dMaaPAlarmPollingHashMap);
38         PowerMock.replayAll();
39     }
40
41     @Test
42     public void removeSubscriber() throws Exception {
43         Subscriber subscriber = PowerMock.createMock(Subscriber.class);
44         PowerMock.expectPrivate(subscriber, "getTopic").andReturn("testTopic");
45         PowerMock.expectPrivate(subscriber, "getUrl").andReturn("https");
46         PowerMock.replayAll();
47         subscriberAction.removeSubscriber(subscriber);
48         PowerMock.verifyAll();
49     }
50
51     @Test
52     public void stopPollingTasks() throws Exception {
53         subscriberAction.stopPollingTasks();
54         PowerMock.verifyAll();
55     }
56
57 }