Fix netconf-connector-config groupId
[netconf.git] / netconf / sal-netconf-connector / src / test / java / org / opendaylight / netconf / sal / connect / netconf / sal / NetconfDeviceNotificationServiceTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netconf.sal.connect.netconf.sal;
10
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.never;
13 import static org.mockito.Mockito.verify;
14
15 import java.net.URI;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
21 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
22 import org.opendaylight.yangtools.yang.common.QName;
23 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24
25 public class NetconfDeviceNotificationServiceTest {
26
27     @Mock
28     private DOMNotificationListener listener1;
29     @Mock
30     private DOMNotificationListener listener2;
31     @Mock
32     private DOMNotification notification1;
33     @Mock
34     private DOMNotification notification2;
35
36     private NetconfDeviceNotificationService service;
37
38
39     @Before
40     public void setUp() throws Exception {
41         MockitoAnnotations.initMocks(this);
42         SchemaPath path1 = SchemaPath.create(true, new QName(new URI("namespace1"), "path1"));
43         SchemaPath path2 = SchemaPath.create(true, new QName(new URI("namespace2"), "path2"));
44         service = new NetconfDeviceNotificationService();
45         service.registerNotificationListener(listener1, path1);
46         service.registerNotificationListener(listener2, path2);
47
48         doReturn(path1).when(notification1).getType();
49         doReturn(path2).when(notification2).getType();
50
51     }
52
53     @Test
54     public void testPublishNotification() throws Exception {
55
56         service.publishNotification(notification1);
57         verify(listener1).onNotification(notification1);
58         verify(listener2, never()).onNotification(notification1);
59
60         service.publishNotification(notification2);
61         verify(listener2).onNotification(notification2);
62         verify(listener1, never()).onNotification(notification2);
63     }
64
65 }