2 * Copyright 2017 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.holmes.engine.dmaap;
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;
25 public class SubscriberActionTest {
27 private SubscriberAction subscriberAction;
31 subscriberAction = new SubscriberAction();
32 HashMap<String, DMaaPAlarmPolling> dMaaPAlarmPollingHashMap = new HashMap<>();
33 DMaaPAlarmPolling dMaaPAlarmPolling = new DMaaPAlarmPolling(null, null,null);
34 dMaaPAlarmPollingHashMap.put("test", dMaaPAlarmPolling);
35 DMaaPAlarmPolling dMaaPAlarmPolling1 = new DMaaPAlarmPolling(null, null,null);
36 dMaaPAlarmPollingHashMap.put("testTopic", dMaaPAlarmPolling1);
37 Whitebox.setInternalState(subscriberAction, "pollingTasks", dMaaPAlarmPollingHashMap);
38 PowerMock.replayAll();
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();
52 public void stopPollingTasks() throws Exception {
53 subscriberAction.stopPollingTasks();
54 PowerMock.verifyAll();