@Test public void testHandleNotificationNewDevice() { Notification notification = mock(Notification.class); AdapterContext adapterContext = mock(AdapterContext.class); DeviceInterface deviceInterface = mock(DeviceInterface.class); when(m_adapterManager.getAdapterContext(any(DeviceAdapterId.class))).thenReturn(adapterContext); when(adapterContext.getDeviceInterface()).thenReturn(deviceInterface); m_nonNetconfDeviceAdapter.handleNotification(ip_address, port, notification); verify(notification).notificationToString(); }
public void handleNotification(String ip, String port, Notification notification) { Device device = getDeviceFromIpAndPort(ip, port); if (device != null) { DeviceNotificationListener deviceListener; DeviceAdapterId deviceAdapterId = new DeviceAdapterId(device.getDeviceManagement().getDeviceType(), device.getDeviceManagement().getDeviceInterfaceVersion(), device.getDeviceManagement().getDeviceModel(), device.getDeviceManagement().getDeviceVendor()); String deviceName = device.getDeviceName(); if (m_deviceNotificationListenerMap.get(deviceName) != null) { deviceListener = m_deviceNotificationListenerMap.get(deviceName); } else { AdapterContext adapterContext = AdapterUtils.getAdapterContext(device, m_adapterManager); deviceListener = new DeviceNotificationListener(device, deviceAdapterId, m_notificationService, adapterContext, m_pmaRegistry); m_deviceNotificationListenerMap.put(deviceName, deviceListener); } deviceListener.notificationReceived(notification); } else { LOGGER.info(String.format("No device found corresponding to ip: %s and port: %s", ip, port)); } }
NonNCNotificationHandlerImpl implements NonNCNotificationHandler { public void handleNotification(String ip, String port, Notification notification) { Device device = getDeviceFromIpAndPort(ip, port); if (device != null) { DeviceNotificationListener deviceListener; DeviceAdapterId deviceAdapterId = new DeviceAdapterId(device.getDeviceManagement().getDeviceType(), device.getDeviceManagement().getDeviceInterfaceVersion(), device.getDeviceManagement().getDeviceModel(), device.getDeviceManagement().getDeviceVendor()); String deviceName = device.getDeviceName(); if (m_deviceNotificationListenerMap.get(deviceName) != null) { deviceListener = m_deviceNotificationListenerMap.get(deviceName); } else { AdapterContext adapterContext = AdapterUtils.getAdapterContext(device, m_adapterManager); deviceListener = new DeviceNotificationListener(device, deviceAdapterId, m_notificationService, adapterContext, m_pmaRegistry); m_deviceNotificationListenerMap.put(deviceName, deviceListener); } deviceListener.notificationReceived(notification); } else { LOGGER.info(String.format("No device found corresponding to ip: %s and port: %s", ip, port)); } } }
NonNCNotificationHandlerImpl implements NonNCNotificationHandler { public void handleNotification(String ip, String port, Notification notification) { Device device = getDeviceFromIpAndPort(ip, port); if (device != null) { DeviceNotificationListener deviceListener; DeviceAdapterId deviceAdapterId = new DeviceAdapterId(device.getDeviceManagement().getDeviceType(), device.getDeviceManagement().getDeviceInterfaceVersion(), device.getDeviceManagement().getDeviceModel(), device.getDeviceManagement().getDeviceVendor()); String deviceName = device.getDeviceName(); if (m_deviceNotificationListenerMap.get(deviceName) != null) { deviceListener = m_deviceNotificationListenerMap.get(deviceName); } else { AdapterContext adapterContext = AdapterUtils.getAdapterContext(device, m_adapterManager); deviceListener = new DeviceNotificationListener(device, deviceAdapterId, m_notificationService, adapterContext, m_pmaRegistry); m_deviceNotificationListenerMap.put(deviceName, deviceListener); } deviceListener.notificationReceived(notification); } else { LOGGER.info(String.format("No device found corresponding to ip: %s and port: %s", ip, port)); } } NonNCNotificationHandlerImpl(NotificationService notificationService, AdapterManager adapterManager,
                                        PmaRegistry pmaRegistry, DeviceManager deviceManager); }
NonNCNotificationHandlerImpl implements NonNCNotificationHandler { public void handleNotification(String ip, String port, Notification notification) { Device device = getDeviceFromIpAndPort(ip, port); if (device != null) { DeviceNotificationListener deviceListener; DeviceAdapterId deviceAdapterId = new DeviceAdapterId(device.getDeviceManagement().getDeviceType(), device.getDeviceManagement().getDeviceInterfaceVersion(), device.getDeviceManagement().getDeviceModel(), device.getDeviceManagement().getDeviceVendor()); String deviceName = device.getDeviceName(); if (m_deviceNotificationListenerMap.get(deviceName) != null) { deviceListener = m_deviceNotificationListenerMap.get(deviceName); } else { AdapterContext adapterContext = AdapterUtils.getAdapterContext(device, m_adapterManager); deviceListener = new DeviceNotificationListener(device, deviceAdapterId, m_notificationService, adapterContext, m_pmaRegistry); m_deviceNotificationListenerMap.put(deviceName, deviceListener); } deviceListener.notificationReceived(notification); } else { LOGGER.info(String.format("No device found corresponding to ip: %s and port: %s", ip, port)); } } NonNCNotificationHandlerImpl(NotificationService notificationService, AdapterManager adapterManager,
                                        PmaRegistry pmaRegistry, DeviceManager deviceManager); void handleNotification(String ip, String port, Notification notification); }
NonNCNotificationHandlerImpl implements NonNCNotificationHandler { public void handleNotification(String ip, String port, Notification notification) { Device device = getDeviceFromIpAndPort(ip, port); if (device != null) { DeviceNotificationListener deviceListener; DeviceAdapterId deviceAdapterId = new DeviceAdapterId(device.getDeviceManagement().getDeviceType(), device.getDeviceManagement().getDeviceInterfaceVersion(), device.getDeviceManagement().getDeviceModel(), device.getDeviceManagement().getDeviceVendor()); String deviceName = device.getDeviceName(); if (m_deviceNotificationListenerMap.get(deviceName) != null) { deviceListener = m_deviceNotificationListenerMap.get(deviceName); } else { AdapterContext adapterContext = AdapterUtils.getAdapterContext(device, m_adapterManager); deviceListener = new DeviceNotificationListener(device, deviceAdapterId, m_notificationService, adapterContext, m_pmaRegistry); m_deviceNotificationListenerMap.put(deviceName, deviceListener); } deviceListener.notificationReceived(notification); } else { LOGGER.info(String.format("No device found corresponding to ip: %s and port: %s", ip, port)); } } NonNCNotificationHandlerImpl(NotificationService notificationService, AdapterManager adapterManager,
                                        PmaRegistry pmaRegistry, DeviceManager deviceManager); void handleNotification(String ip, String port, Notification notification);  }