f55d3abdfe1bd153670e9bb09a0907f94731d7dd
[hc2vpp.git] /
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
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 io.fd.honeycomb.v3po.notification.impl;
17
18 import static org.mockito.Mockito.atLeast;
19 import static org.mockito.Mockito.verify;
20
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;
30
31 public class HoneycombNotificationCollectorTest {
32
33     private NotificationProducerRegistry notificationRegistry;
34     @Mock
35     private NotificationPublishService notificationService;
36     @Mock
37     private ManagedNotificationProducer producer;
38
39     @Before
40     public void setUp() throws Exception {
41         MockitoAnnotations.initMocks(this);
42         notificationRegistry = new NotificationProducerRegistry(Lists.newArrayList(producer));
43     }
44
45     @Test
46     public void testNotificationTypes() throws Exception {
47         final HoneycombNotificationCollector honeycombNotificationCollector =
48             new HoneycombNotificationCollector(notificationService, notificationRegistry);
49
50         honeycombNotificationCollector.getNotificationTypes();
51         verify(producer, atLeast(1)).getNotificationTypes();
52     }
53
54     @Test
55     public void testCollect() throws Exception {
56         final HoneycombNotificationCollector honeycombNotificationCollector =
57             new HoneycombNotificationCollector(notificationService, notificationRegistry);
58
59         final NetconfSessionStart notif = new NetconfSessionStartBuilder().build();
60         honeycombNotificationCollector.onNotification(notif);
61         verify(notificationService).putNotification(notif);
62     }
63 }