DeviceReconnectionNotificationListener implements ConnectionListener { @Override public void deviceConnected(Device device, NetconfClientSession clientSession) { sendDeviceNotificationsToNbi(device); } DeviceReconnectionNotificationListener(NotificationService notificationService,
                                                  NetconfConnectionManager netconfConnectionManager); void init(); void destroy(); @Override void deviceConnected(Device device, NetconfClientSession clientSession); @Override void deviceDisConnected(Device device, NetconfClientSession session);  }
@Test public void testDeviceConnected() throws NetconfMessageBuilderException, IOException, SAXException { Device device = new Device(); device.setDeviceName("testDeviceOn"); NetconfClientSession clientSession = mock(NetconfClientSession.class); m_listener.deviceConnected(device, clientSession); ArgumentCaptor<Notification> captor = ArgumentCaptor.forClass(Notification.class); verify(m_notificationService, times(1)).sendNotification(eq("STATE_CHANGE"), captor.capture()); Notification notification = captor.getValue(); String expectedNotifElem = "<network-manager xmlns=\"urn:bbf:yang:obbaa:network-manager\">\n" + "<managed-devices>\n" + "<device>\n" + "<name>testDeviceOn</name>\n" + "<device-notification>\n" + "<device-state-change>\n" + "<event>online</event>\n" + "</device-state-change>\n" + "</device-notification>\n" + "</device>\n" + "</managed-devices>\n" + "</network-manager>\n"; TestUtil.assertXMLEquals(DocumentUtils.stringToDocument(expectedNotifElem).getDocumentElement(), notification.getNotificationElement()); }