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 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;
24 import java.util.HashMap;
27 public class SubscriberActionTest {
29 private SubscriberAction subscriberAction;
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();
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();
54 public void stopPollingTasks() throws Exception {
55 subscriberAction.stopPollingTasks();
56 PowerMock.verifyAll();