Updated Java to Ver. 11
[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 org.junit.Before;
19 import org.junit.Test;
20 import org.onap.holmes.dsa.dmaappolling.Subscriber;
21 import org.powermock.api.easymock.PowerMock;
22 import org.powermock.reflect.Whitebox;
23
24 import java.util.HashMap;
25
26
27 public class SubscriberActionTest {
28
29     private SubscriberAction subscriberAction;
30
31     @Before
32     public void setUp() {
33         subscriberAction = new SubscriberAction();
34         HashMap<String, DMaaPAlarmPolling> dMaaPAlarmPollingHashMap = new HashMap<>();
35         DMaaPAlarmPolling dMaaPAlarmPolling = new DMaaPAlarmPolling(null, null, null);
36         dMaaPAlarmPollingHashMap.put("test", dMaaPAlarmPolling);
37         DMaaPAlarmPolling dMaaPAlarmPolling1 = new DMaaPAlarmPolling(null, null, null);
38         dMaaPAlarmPollingHashMap.put("testTopic", dMaaPAlarmPolling1);
39         Whitebox.setInternalState(subscriberAction, "pollingTasks", dMaaPAlarmPollingHashMap);
40         PowerMock.replayAll();
41     }
42
43     @Test
44     public void removeSubscriber() throws Exception {
45         Subscriber subscriber = PowerMock.createMock(Subscriber.class);
46         PowerMock.expectPrivate(subscriber, "getTopic").andReturn("testTopic");
47         PowerMock.expectPrivate(subscriber, "getUrl").andReturn("https");
48         PowerMock.replayAll();
49         subscriberAction.removeSubscriber(subscriber);
50         PowerMock.verifyAll();
51     }
52
53     @Test
54     public void stopPollingTasks() throws Exception {
55         subscriberAction.stopPollingTasks();
56         PowerMock.verifyAll();
57     }
58
59 }