@Test public void testNotificationReceivedNoNormalization() { when(m_deviceInterface.normalizeNotification(m_notification)).thenReturn(m_notification); m_deviceNotificationListener.notificationReceived(m_notification); verify(m_notificationService).executeCallBack(eq(m_notification), m_notificationContextCaptor.capture()); NotificationContext context = m_notificationContextCaptor.getValue(); assertEquals(m_device, context.get(Device.class.getSimpleName())); assertEquals(m_deviceAdapterId, context.get(DeviceAdapterId.class.getSimpleName())); }
@Override public void notificationReceived(final Notification notification) { LOGGER.info(String.format("Received device notification from device: %s with notification: %s", m_device.getDeviceName(), notification.notificationToString())); Notification normalizedNotification = m_adapterContext.getDeviceInterface().normalizeNotification(notification); if (normalizedNotification != null) { RequestScope.withScope(new RequestScope.RsTemplate<Void>() { @Override protected Void execute() throws RequestScopeExecutionException { try { NotificationContext context = new NotificationContext(); context.put(Device.class.getSimpleName(), m_device); context.put(DeviceAdapterId.class.getSimpleName(), m_deviceAdapterId); QName onuStateChangeNotification = QName.create(ONU_STATE_CHANGE_NS, "onu-state-change"); if (onuStateChangeNotification.equals(normalizedNotification.getType())) { getDeviceSlotAndPort(m_device.getDeviceName(), normalizedNotification); } m_notificationService.executeCallBack(normalizedNotification, context); } catch (Exception e) { LOGGER.error("Error while processing notification", e); } return null; } }); } else { LOGGER.debug("The normalized notification received from the adapter is null"); } }
DeviceNotificationListener implements NotificationListener { @Override public void notificationReceived(final Notification notification) { LOGGER.info(String.format("Received device notification from device: %s with notification: %s", m_device.getDeviceName(), notification.notificationToString())); Notification normalizedNotification = m_adapterContext.getDeviceInterface().normalizeNotification(notification); if (normalizedNotification != null) { RequestScope.withScope(new RequestScope.RsTemplate<Void>() { @Override protected Void execute() throws RequestScopeExecutionException { try { NotificationContext context = new NotificationContext(); context.put(Device.class.getSimpleName(), m_device); context.put(DeviceAdapterId.class.getSimpleName(), m_deviceAdapterId); QName onuStateChangeNotification = QName.create(ONU_STATE_CHANGE_NS, "onu-state-change"); if (onuStateChangeNotification.equals(normalizedNotification.getType())) { getDeviceSlotAndPort(m_device.getDeviceName(), normalizedNotification); } m_notificationService.executeCallBack(normalizedNotification, context); } catch (Exception e) { LOGGER.error("Error while processing notification", e); } return null; } }); } else { LOGGER.debug("The normalized notification received from the adapter is null"); } } }
DeviceNotificationListener implements NotificationListener { @Override public void notificationReceived(final Notification notification) { LOGGER.info(String.format("Received device notification from device: %s with notification: %s", m_device.getDeviceName(), notification.notificationToString())); Notification normalizedNotification = m_adapterContext.getDeviceInterface().normalizeNotification(notification); if (normalizedNotification != null) { RequestScope.withScope(new RequestScope.RsTemplate<Void>() { @Override protected Void execute() throws RequestScopeExecutionException { try { NotificationContext context = new NotificationContext(); context.put(Device.class.getSimpleName(), m_device); context.put(DeviceAdapterId.class.getSimpleName(), m_deviceAdapterId); QName onuStateChangeNotification = QName.create(ONU_STATE_CHANGE_NS, "onu-state-change"); if (onuStateChangeNotification.equals(normalizedNotification.getType())) { getDeviceSlotAndPort(m_device.getDeviceName(), normalizedNotification); } m_notificationService.executeCallBack(normalizedNotification, context); } catch (Exception e) { LOGGER.error("Error while processing notification", e); } return null; } }); } else { LOGGER.debug("The normalized notification received from the adapter is null"); } } DeviceNotificationListener(Device device, DeviceAdapterId deviceAdapterId, NotificationService notificationService,
                                      AdapterContext adapterContext, PmaRegistry pmaRegistry); }
DeviceNotificationListener implements NotificationListener { @Override public void notificationReceived(final Notification notification) { LOGGER.info(String.format("Received device notification from device: %s with notification: %s", m_device.getDeviceName(), notification.notificationToString())); Notification normalizedNotification = m_adapterContext.getDeviceInterface().normalizeNotification(notification); if (normalizedNotification != null) { RequestScope.withScope(new RequestScope.RsTemplate<Void>() { @Override protected Void execute() throws RequestScopeExecutionException { try { NotificationContext context = new NotificationContext(); context.put(Device.class.getSimpleName(), m_device); context.put(DeviceAdapterId.class.getSimpleName(), m_deviceAdapterId); QName onuStateChangeNotification = QName.create(ONU_STATE_CHANGE_NS, "onu-state-change"); if (onuStateChangeNotification.equals(normalizedNotification.getType())) { getDeviceSlotAndPort(m_device.getDeviceName(), normalizedNotification); } m_notificationService.executeCallBack(normalizedNotification, context); } catch (Exception e) { LOGGER.error("Error while processing notification", e); } return null; } }); } else { LOGGER.debug("The normalized notification received from the adapter is null"); } } DeviceNotificationListener(Device device, DeviceAdapterId deviceAdapterId, NotificationService notificationService,
                                      AdapterContext adapterContext, PmaRegistry pmaRegistry); @Override void notificationReceived(final Notification notification); }
DeviceNotificationListener implements NotificationListener { @Override public void notificationReceived(final Notification notification) { LOGGER.info(String.format("Received device notification from device: %s with notification: %s", m_device.getDeviceName(), notification.notificationToString())); Notification normalizedNotification = m_adapterContext.getDeviceInterface().normalizeNotification(notification); if (normalizedNotification != null) { RequestScope.withScope(new RequestScope.RsTemplate<Void>() { @Override protected Void execute() throws RequestScopeExecutionException { try { NotificationContext context = new NotificationContext(); context.put(Device.class.getSimpleName(), m_device); context.put(DeviceAdapterId.class.getSimpleName(), m_deviceAdapterId); QName onuStateChangeNotification = QName.create(ONU_STATE_CHANGE_NS, "onu-state-change"); if (onuStateChangeNotification.equals(normalizedNotification.getType())) { getDeviceSlotAndPort(m_device.getDeviceName(), normalizedNotification); } m_notificationService.executeCallBack(normalizedNotification, context); } catch (Exception e) { LOGGER.error("Error while processing notification", e); } return null; } }); } else { LOGGER.debug("The normalized notification received from the adapter is null"); } } DeviceNotificationListener(Device device, DeviceAdapterId deviceAdapterId, NotificationService notificationService,
                                      AdapterContext adapterContext, PmaRegistry pmaRegistry); @Override void notificationReceived(final Notification notification);  }