*/
package org.opendaylight.transportpce.networkmodel;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collection;
import java.util.Map;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.networkmodel.dto.NodeRegistration;
-import org.opendaylight.transportpce.networkmodel.dto.NodeRegistration22;
-import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener;
-import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener221;
-import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener;
-import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener221;
-import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener121;
-import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener221;
-import org.opendaylight.transportpce.networkmodel.listeners.TcaListener;
-import org.opendaylight.transportpce.networkmodel.listeners.TcaListener221;
import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev161014.OrgOpenroadmAlarmListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev161014.OrgOpenroadmDeOperationsListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev161014.OrgOpenroadmTcaListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final DataBroker dataBroker;
private final DeviceTransactionManager deviceTransactionManager;
private final Map<String, NodeRegistration> registrations;
- private final Map<String, NodeRegistration22> registrations22;
private final PortMapping portMapping;
public NetConfTopologyListener(final NetworkModelService networkModelService, final DataBroker dataBroker,
this.dataBroker = dataBroker;
this.deviceTransactionManager = deviceTransactionManager;
this.registrations = new ConcurrentHashMap<>();
- this.registrations22 = new ConcurrentHashMap<>();
this.portMapping = portMapping;
}
switch (rootNode.getModificationType()) {
case DELETE:
this.networkModelService.deleteOpenRoadmnode(nodeId);
- String deviceVersion = netconfNodeBefore
- .getAvailableCapabilities().getAvailableCapability().stream()
- .filter(cp -> cp.getCapability().contains(StringConstants.OPENROADM_DEVICE_MODEL_NAME))
- .sorted((c1, c2) -> c1.getCapability().compareTo(c2.getCapability()))
- .findFirst()
- .get().getCapability();
- onDeviceDisConnected(nodeId, deviceVersion);
+ onDeviceDisConnected(nodeId);
LOG.info("Device {} correctly disconnected from controller", nodeId);
break;
case WRITE:
Optional<AvailableCapability> deviceCapabilityOpt = netconfNodeAfter
.getAvailableCapabilities().getAvailableCapability().stream()
.filter(cp -> cp.getCapability().contains(StringConstants.OPENROADM_DEVICE_MODEL_NAME))
- .sorted((c1, c2) -> c1.getCapability().compareTo(c2.getCapability()))
+ .sorted((c1, c2) -> c2.getCapability().compareTo(c1.getCapability()))
.findFirst();
if (deviceCapabilityOpt.isEmpty()) {
LOG.error("Unable to get openroadm-device-capability");
LOG.error(RPC_SERVICE_FAILED, nodeId);
return;
}
- switch (openRoadmVersion) {
- case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- NodeRegistration node121Registration = registrateNode121Listeners(nodeId, notificationService.get());
- registrations.put(nodeId, node121Registration);
- break;
- case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
- NodeRegistration22 node221Registration = registrateNode221Listeners(nodeId, notificationService.get());
- registrations22.put(nodeId, node221Registration);
- break;
- default:
- break;
- }
+ NodeRegistration nodeRegistration = new NodeRegistration(nodeId, openRoadmVersion,
+ notificationService.get(), this.dataBroker, this.portMapping);
+ nodeRegistration.registerListeners();
+ registrations.put(nodeId, nodeRegistration);
String streamName = "NETCONF";
subscribeStream(mountPoint, streamName, nodeId);
}
- private void onDeviceDisConnected(final String nodeId, String openRoadmVersion) {
+ private void onDeviceDisConnected(final String nodeId) {
LOG.info("onDeviceDisConnected: {}", nodeId);
- switch (openRoadmVersion) {
- case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
- NodeRegistration nodeRegistration = this.registrations.remove(nodeId);
- if (nodeRegistration != null) {
- nodeRegistration.getAccessAlarmNotificationListenerRegistration().close();
- nodeRegistration.getAccessDeOperationasNotificationListenerRegistration().close();
- nodeRegistration.getAccessDeviceNotificationListenerRegistration().close();
- nodeRegistration.getAccessTcaNotificationListenerRegistration().close();
- }
- break;
- case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
- NodeRegistration22 nodeRegistration221 = this.registrations22.remove(nodeId);
- if (nodeRegistration221 != null) {
- nodeRegistration221.getAccessAlarmNotificationListenerRegistration().close();
- nodeRegistration221.getAccessDeOperationasNotificationListenerRegistration().close();
- nodeRegistration221.getAccessDeviceNotificationListenerRegistration().close();
- nodeRegistration221.getAccessTcaNotificationListenerRegistration().close();
- }
- break;
- default:
- break;
- }
- }
-
- private NodeRegistration registrateNode121Listeners(String nodeId, NotificationService notificationService) {
- final OrgOpenroadmAlarmListener alarmListener = new AlarmNotificationListener(this.dataBroker);
- LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId);
- final ListenerRegistration<OrgOpenroadmAlarmListener> accessAlarmNotificationListenerRegistration =
- notificationService.registerNotificationListener(alarmListener);
-
- final OrgOpenroadmDeOperationsListener deOperationsListener = new DeOperationsListener();
- LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId);
- final ListenerRegistration<OrgOpenroadmDeOperationsListener>
- accessDeOperationasNotificationListenerRegistration =
- notificationService.registerNotificationListener(deOperationsListener);
-
- final OrgOpenroadmDeviceListener deviceListener = new DeviceListener121(nodeId, this.portMapping);
- LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId);
- final ListenerRegistration<OrgOpenroadmDeviceListener> accessDeviceNotificationListenerRegistration =
- notificationService.registerNotificationListener(deviceListener);
-
- TcaListener tcaListener = new TcaListener();
- LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId);
- final ListenerRegistration<OrgOpenroadmTcaListener> accessTcaNotificationListenerRegistration =
- notificationService.registerNotificationListener(tcaListener);
- return new NodeRegistration(nodeId, accessAlarmNotificationListenerRegistration,
- accessDeOperationasNotificationListenerRegistration, accessDeviceNotificationListenerRegistration,
- null, accessTcaNotificationListenerRegistration);
- }
-
- private NodeRegistration22 registrateNode221Listeners(String nodeId, NotificationService notificationService) {
- final org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev181019.OrgOpenroadmAlarmListener
- alarmListener = new AlarmNotificationListener221(dataBroker);
- LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId);
- final ListenerRegistration<org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev181019
- .OrgOpenroadmAlarmListener> accessAlarmNotificationListenerRegistration =
- notificationService.registerNotificationListener(alarmListener);
-
- final org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev181019
- .OrgOpenroadmDeOperationsListener deOperationsListener = new DeOperationsListener221();
- LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId);
- final ListenerRegistration<org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev181019
- .OrgOpenroadmDeOperationsListener> accessDeOperationasNotificationListenerRegistration =
- notificationService.registerNotificationListener(deOperationsListener);
-
- final org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.OrgOpenroadmDeviceListener
- deviceListener = new DeviceListener221(nodeId, this.portMapping);
- LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId);
- final ListenerRegistration<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019
- .OrgOpenroadmDeviceListener> accessDeviceNotificationListenerRegistration =
- notificationService.registerNotificationListener(deviceListener);
-
- final org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev181019.OrgOpenroadmTcaListener
- tcaListener = new TcaListener221();
- LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId);
- final ListenerRegistration<org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev181019
- .OrgOpenroadmTcaListener> accessTcaNotificationListenerRegistration =
- notificationService.registerNotificationListener(tcaListener);
- return new NodeRegistration22(nodeId, accessAlarmNotificationListenerRegistration,
- accessDeOperationasNotificationListenerRegistration, accessDeviceNotificationListenerRegistration,
- null, accessTcaNotificationListenerRegistration);
+ NodeRegistration nodeRegistration = this.registrations.remove(nodeId);
+ nodeRegistration.unregisterListeners();
}
private boolean subscribeStream(MountPoint mountPoint, String streamName, String nodeId) {
}
return true;
}
+
+ @VisibleForTesting
+ public NetConfTopologyListener(final NetworkModelService networkModelService, final DataBroker dataBroker,
+ DeviceTransactionManager deviceTransactionManager, PortMapping portMapping,
+ Map<String, NodeRegistration> registrations) {
+ this.networkModelService = networkModelService;
+ this.dataBroker = dataBroker;
+ this.deviceTransactionManager = deviceTransactionManager;
+ this.portMapping = portMapping;
+ this.registrations = registrations;
+ }
}
*/
package org.opendaylight.transportpce.networkmodel.dto;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.transportpce.common.StringConstants;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener;
+import org.opendaylight.transportpce.networkmodel.listeners.AlarmNotificationListener221;
+import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener;
+import org.opendaylight.transportpce.networkmodel.listeners.DeOperationsListener221;
+import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener121;
+import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener221;
+import org.opendaylight.transportpce.networkmodel.listeners.DeviceListener710;
+import org.opendaylight.transportpce.networkmodel.listeners.TcaListener;
+import org.opendaylight.transportpce.networkmodel.listeners.TcaListener221;
import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev161014.OrgOpenroadmAlarmListener;
import org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev161014.OrgOpenroadmDeOperationsListener;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.OrgOpenroadmLldpListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev161014.OrgOpenroadmTcaListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class NodeRegistration {
-
+ private static final Logger LOG = LoggerFactory.getLogger(NodeRegistration.class);
private final String nodeId;
- private final ListenerRegistration<OrgOpenroadmAlarmListener> accessAlarmNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmDeOperationsListener>
- accessDeOperationasNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmDeviceListener> accessDeviceNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmLldpListener> accessLldpNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmTcaListener> accessTcaNotificationListenerRegistration;
+ private final String nodeVersion;
+ private final NotificationService notificationService;
+ private final DataBroker dataBroker;
+ private final PortMapping portMapping;
+ private final List<ListenerRegistration<?>> listeners;
- public NodeRegistration(String nodeId,
- ListenerRegistration<OrgOpenroadmAlarmListener> accessAlarmNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmDeOperationsListener> accessDeOperationasNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmDeviceListener> accessDeviceNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmLldpListener> accessLldpNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmTcaListener> accessTcaNotificationListenerRegistration) {
+ public NodeRegistration(String nodeId, String nodeVersion, NotificationService notificationService,
+ DataBroker dataBroker, PortMapping portMapping) {
this.nodeId = nodeId;
- this.accessAlarmNotificationListenerRegistration = accessAlarmNotificationListenerRegistration;
- this.accessDeOperationasNotificationListenerRegistration = accessDeOperationasNotificationListenerRegistration;
- this.accessDeviceNotificationListenerRegistration = accessDeviceNotificationListenerRegistration;
- this.accessLldpNotificationListenerRegistration = accessLldpNotificationListenerRegistration;
- this.accessTcaNotificationListenerRegistration = accessTcaNotificationListenerRegistration;
+ this.nodeVersion = nodeVersion;
+ this.notificationService = notificationService;
+ this.dataBroker = dataBroker;
+ this.portMapping = portMapping;
+ listeners = new ArrayList<ListenerRegistration<?>>();
}
- public String getNodeId() {
- return nodeId;
+ public void registerListeners() {
+ switch (this.nodeVersion) {
+ case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
+ registerListeners121();
+ break;
+ case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
+ registerListeners221();
+ break;
+ case StringConstants.OPENROADM_DEVICE_VERSION_7_1_0:
+ registerListeners710();
+ break;
+ default:
+ LOG.debug("Unable to register listeners - unknown device version for {}", this.nodeId);
+ break;
+ }
}
- public ListenerRegistration<OrgOpenroadmAlarmListener> getAccessAlarmNotificationListenerRegistration() {
- return accessAlarmNotificationListenerRegistration;
+ public void unregisterListeners() {
+ LOG.info("Unregistering notification listeners for node: {}", this.nodeId);
+ for (ListenerRegistration<?> listenerRegistration : listeners) {
+ listenerRegistration.close();
+ }
}
- public ListenerRegistration<OrgOpenroadmDeOperationsListener>
- getAccessDeOperationasNotificationListenerRegistration() {
- return accessDeOperationasNotificationListenerRegistration;
- }
+ private void registerListeners121() {
+ OrgOpenroadmAlarmListener alarmListener = new AlarmNotificationListener(this.dataBroker);
+ LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(alarmListener));
- public ListenerRegistration<OrgOpenroadmDeviceListener> getAccessDeviceNotificationListenerRegistration() {
- return accessDeviceNotificationListenerRegistration;
- }
+ OrgOpenroadmDeOperationsListener deOperationsListener = new DeOperationsListener();
+ LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(deOperationsListener));
+
+ OrgOpenroadmDeviceListener deviceListener = new DeviceListener121(nodeId, this.portMapping);
+ LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(deviceListener));
- public ListenerRegistration<OrgOpenroadmLldpListener> getAccessLldpNotificationListenerRegistration() {
- return accessLldpNotificationListenerRegistration;
+ TcaListener tcaListener = new TcaListener();
+ LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(tcaListener));
}
- public ListenerRegistration<OrgOpenroadmTcaListener> getAccessTcaNotificationListenerRegistration() {
- return accessTcaNotificationListenerRegistration;
+ private void registerListeners221() {
+ AlarmNotificationListener221 alarmListener = new AlarmNotificationListener221(dataBroker);
+ LOG.info("Registering notification listener on OrgOpenroadmAlarmListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(alarmListener));
+
+ DeOperationsListener221 deOperationsListener = new DeOperationsListener221();
+ LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(deOperationsListener));
+
+ DeviceListener221 deviceListener = new DeviceListener221(nodeId, this.portMapping);
+ LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(deviceListener));
+
+ TcaListener221 tcaListener = new TcaListener221();
+ LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(tcaListener));
}
+ private void registerListeners710() {
+ DeviceListener710 deviceListener = new DeviceListener710(nodeId, this.portMapping);
+ LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId);
+ listeners.add(notificationService.registerNotificationListener(deviceListener));
+ }
}
+++ /dev/null
-/*
- * Copyright © 2016 AT&T and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.networkmodel.dto;
-
-import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev181019.OrgOpenroadmAlarmListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.de.operations.rev181019.OrgOpenroadmDeOperationsListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.OrgOpenroadmDeviceListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.OrgOpenroadmLldpListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.tca.rev181019.OrgOpenroadmTcaListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-public class NodeRegistration22 {
-
- private final String nodeId;
- private final ListenerRegistration<OrgOpenroadmAlarmListener> accessAlarmNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmDeOperationsListener>
- accessDeOperationasNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmDeviceListener> accessDeviceNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmLldpListener> accessLldpNotificationListenerRegistration;
- private final ListenerRegistration<OrgOpenroadmTcaListener> accessTcaNotificationListenerRegistration;
-
- public NodeRegistration22(String nodeId,
- ListenerRegistration<OrgOpenroadmAlarmListener>
- accessAlarmNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmDeOperationsListener>
- accessDeOperationasNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmDeviceListener>
- accessDeviceNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmLldpListener>
- accessLldpNotificationListenerRegistration,
- ListenerRegistration<OrgOpenroadmTcaListener>
- accessTcaNotificationListenerRegistration) {
- this.nodeId = nodeId;
- this.accessAlarmNotificationListenerRegistration = accessAlarmNotificationListenerRegistration;
- this.accessDeOperationasNotificationListenerRegistration = accessDeOperationasNotificationListenerRegistration;
- this.accessDeviceNotificationListenerRegistration = accessDeviceNotificationListenerRegistration;
- this.accessLldpNotificationListenerRegistration = accessLldpNotificationListenerRegistration;
- this.accessTcaNotificationListenerRegistration = accessTcaNotificationListenerRegistration;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public ListenerRegistration<OrgOpenroadmAlarmListener> getAccessAlarmNotificationListenerRegistration() {
- return accessAlarmNotificationListenerRegistration;
- }
-
- public ListenerRegistration<OrgOpenroadmDeOperationsListener>
- getAccessDeOperationasNotificationListenerRegistration() {
- return accessDeOperationasNotificationListenerRegistration;
- }
-
- public ListenerRegistration<OrgOpenroadmDeviceListener> getAccessDeviceNotificationListenerRegistration() {
- return accessDeviceNotificationListenerRegistration;
- }
-
- public ListenerRegistration<OrgOpenroadmLldpListener> getAccessLldpNotificationListenerRegistration() {
- return accessLldpNotificationListenerRegistration;
- }
-
- public ListenerRegistration<OrgOpenroadmTcaListener> getAccessTcaNotificationListenerRegistration() {
- return accessTcaNotificationListenerRegistration;
- }
-
-}
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.transportpce.networkmodel.dto.NodeRegistration;
import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
private DeviceTransactionManager deviceTransactionManager;
@Mock
private PortMapping portMapping;
+ @Mock
+ private Map<String, NodeRegistration> registrations;
@Test
public void testOnDataTreeChangedWhenDeleteNode() {
final DataObjectModification<Node> node = mock(DataObjectModification.class);
final Collection<DataTreeModification<Node>> changes = new HashSet<>();
final DataTreeModification<Node> ch = mock(DataTreeModification.class);
+ final NodeRegistration nodeRegistration = mock(NodeRegistration.class);
changes.add(ch);
when(ch.getRootNode()).thenReturn(node);
OPENROADM_DEVICE_VERSION_2_2_1);
when(node.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
when(node.getDataBefore()).thenReturn(netconfNode);
+ when(registrations.remove(anyString())).thenReturn(nodeRegistration);
+
NetConfTopologyListener listener = new NetConfTopologyListener(networkModelService, dataBroker,
- deviceTransactionManager, portMapping);
+ deviceTransactionManager, portMapping, registrations);
listener.onDataTreeChanged(changes);
verify(ch, times(1)).getRootNode();
verify(node, times(1)).getModificationType();
verify(node, times(3)).getDataBefore();
verify(networkModelService, times(1)).deleteOpenRoadmnode(anyString());
+ verify(nodeRegistration, times(1)).unregisterListeners();
}
@Test