@Test public void testCreateSubscriptionWithReplay() throws NetconfMessageBuilderException, InterruptedException, ExecutionException, ParserException { NetconfClientSession clientSession = mock(NetconfClientSession.class); Device device = getDevice(); NetConfResponse response = new NetConfResponse(); response.setOk(true); when(m_notificationService.isReplaySupported(any(NetconfClientSession.class))).thenReturn(true); when(m_notificationService.createSubscriptionWithCallback(any(NetconfClientSession.class), any(String.class), any(NotificationListener.class), any(), eq(true))).thenReturn(response); m_deviceReconnectNotificationAction.deviceConnected(device, clientSession); verify(m_notificationService, never()).createSubscriptionWithCallback(any(NetconfClientSession.class), any(String.class), any(NotificationListener.class), any(), eq(false)); }
@Override public void deviceConnected(Device device, NetconfClientSession clientSession) { if (m_notificationService.isNotificationSupported(clientSession)) { try { if (m_notificationService.isReplaySupported(clientSession)) { createSubscriptionToDevice(clientSession, device, true); } else { LOGGER.debug("Create subscription to device doesn't support replay"); createSubscriptionToDevice(clientSession, device, false); } } catch (NetconfMessageBuilderException | InterruptedException | ExecutionException e) { LOGGER.error("Device can't get replay supported attribute in Netconf Stream", e); } } else { LOGGER.info(String.format("Device %s doesn't support for notification function", device)); } }
DeviceReconnectionNotificationAction implements ConnectionListener { @Override public void deviceConnected(Device device, NetconfClientSession clientSession) { if (m_notificationService.isNotificationSupported(clientSession)) { try { if (m_notificationService.isReplaySupported(clientSession)) { createSubscriptionToDevice(clientSession, device, true); } else { LOGGER.debug("Create subscription to device doesn't support replay"); createSubscriptionToDevice(clientSession, device, false); } } catch (NetconfMessageBuilderException | InterruptedException | ExecutionException e) { LOGGER.error("Device can't get replay supported attribute in Netconf Stream", e); } } else { LOGGER.info(String.format("Device %s doesn't support for notification function", device)); } } }
DeviceReconnectionNotificationAction implements ConnectionListener { @Override public void deviceConnected(Device device, NetconfClientSession clientSession) { if (m_notificationService.isNotificationSupported(clientSession)) { try { if (m_notificationService.isReplaySupported(clientSession)) { createSubscriptionToDevice(clientSession, device, true); } else { LOGGER.debug("Create subscription to device doesn't support replay"); createSubscriptionToDevice(clientSession, device, false); } } catch (NetconfMessageBuilderException | InterruptedException | ExecutionException e) { LOGGER.error("Device can't get replay supported attribute in Netconf Stream", e); } } else { LOGGER.info(String.format("Device %s doesn't support for notification function", device)); } } DeviceReconnectionNotificationAction(NotificationService notificationService,
                                                NetconfConnectionManager netconfConnectionManager, AdapterManager adapterManager,
                                                PmaRegistry pmaRegistry); }
DeviceReconnectionNotificationAction implements ConnectionListener { @Override public void deviceConnected(Device device, NetconfClientSession clientSession) { if (m_notificationService.isNotificationSupported(clientSession)) { try { if (m_notificationService.isReplaySupported(clientSession)) { createSubscriptionToDevice(clientSession, device, true); } else { LOGGER.debug("Create subscription to device doesn't support replay"); createSubscriptionToDevice(clientSession, device, false); } } catch (NetconfMessageBuilderException | InterruptedException | ExecutionException e) { LOGGER.error("Device can't get replay supported attribute in Netconf Stream", e); } } else { LOGGER.info(String.format("Device %s doesn't support for notification function", device)); } } DeviceReconnectionNotificationAction(NotificationService notificationService,
                                                NetconfConnectionManager netconfConnectionManager, AdapterManager adapterManager,
                                                PmaRegistry pmaRegistry); void init(); void destroy(); @Override void deviceConnected(Device device, NetconfClientSession clientSession); @Override void deviceDisConnected(Device device, NetconfClientSession session); }
DeviceReconnectionNotificationAction implements ConnectionListener { @Override public void deviceConnected(Device device, NetconfClientSession clientSession) { if (m_notificationService.isNotificationSupported(clientSession)) { try { if (m_notificationService.isReplaySupported(clientSession)) { createSubscriptionToDevice(clientSession, device, true); } else { LOGGER.debug("Create subscription to device doesn't support replay"); createSubscriptionToDevice(clientSession, device, false); } } catch (NetconfMessageBuilderException | InterruptedException | ExecutionException e) { LOGGER.error("Device can't get replay supported attribute in Netconf Stream", e); } } else { LOGGER.info(String.format("Device %s doesn't support for notification function", device)); } } DeviceReconnectionNotificationAction(NotificationService notificationService,
                                                NetconfConnectionManager netconfConnectionManager, AdapterManager adapterManager,
                                                PmaRegistry pmaRegistry); void init(); void destroy(); @Override void deviceConnected(Device device, NetconfClientSession clientSession); @Override void deviceDisConnected(Device device, NetconfClientSession session);  }