2 * Copyright (c) 2016 Cisco and/or its affiliates.
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 io.fd.honeycomb.v3po.notification.impl;
18 import static org.mockito.Mockito.atLeast;
19 import static org.mockito.Mockito.verify;
21 import com.google.common.collect.Lists;
22 import io.fd.honeycomb.v3po.notification.ManagedNotificationProducer;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.mockito.Mock;
26 import org.mockito.MockitoAnnotations;
27 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStartBuilder;
31 public class HoneycombNotificationCollectorTest {
33 private NotificationProducerRegistry notificationRegistry;
35 private NotificationPublishService notificationService;
37 private ManagedNotificationProducer producer;
40 public void setUp() throws Exception {
41 MockitoAnnotations.initMocks(this);
42 notificationRegistry = new NotificationProducerRegistry(Lists.newArrayList(producer));
46 public void testNotificationTypes() throws Exception {
47 final HoneycombNotificationCollector honeycombNotificationCollector =
48 new HoneycombNotificationCollector(notificationService, notificationRegistry);
50 honeycombNotificationCollector.getNotificationTypes();
51 verify(producer, atLeast(1)).getNotificationTypes();
55 public void testCollect() throws Exception {
56 final HoneycombNotificationCollector honeycombNotificationCollector =
57 new HoneycombNotificationCollector(notificationService, notificationRegistry);
59 final NetconfSessionStart notif = new NetconfSessionStartBuilder().build();
60 honeycombNotificationCollector.onNotification(notif);
61 verify(notificationService).putNotification(notif);