import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.netconf.client.NetconfClientFactory;
import org.opendaylight.netconf.client.mdsal.api.DeviceActionFactory;
import org.opendaylight.netconf.client.mdsal.impl.DefaultSchemaResourceManager;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyStep;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
@Mock
private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
@Mock
- private ListenerRegistration<?> mockListenerReg;
+ private Registration mockListenerReg;
@Mock
private Registration mockRpcReg;
@Mock
dataBroker = spy(dataBrokerTest.getDataBroker());
doNothing().when(mockListenerReg).close();
- doReturn(mockListenerReg).when(dataBroker).registerDataTreeChangeListener(any(), any());
+ doReturn(mockListenerReg).when(dataBroker).registerTreeChangeListener(any(), any());
doReturn(mockRpcReg).when(rpcProviderService).registerRpcImplementations(any());
netconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, dataBroker, clusterSingletonServiceProvider,
// verify registration is called with right parameters
- verify(dataBroker).registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, NetconfTopologyUtils
+ verify(dataBroker).registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, NetconfTopologyUtils
.createTopologyListPath(TOPOLOGY_ID).child(Node.class)), netconfTopologyManager);
netconfTopologyManager.close();
final Node node1 = new NodeBuilder().setNodeId(nodeId1).addAugmentation(netconfNode1).build();
final DataObjectModification<Node> dataObjectModification1 = mock(DataObjectModification.class);
- doReturn(WRITE).when(dataObjectModification1).getModificationType();
- doReturn(node1).when(dataObjectModification1).getDataAfter();
- doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId1)))
- .when(dataObjectModification1).getIdentifier();
+ doReturn(WRITE).when(dataObjectModification1).modificationType();
+ doReturn(node1).when(dataObjectModification1).dataAfter();
+ doReturn(new KeyStep<>(Node.class, new NodeKey(nodeId1)))
+ .when(dataObjectModification1).step();
final NetconfNode netconfNode2 = new NetconfNodeBuilder()
.setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
final Node node2 = new NodeBuilder().setNodeId(nodeId2).addAugmentation(netconfNode2).build();
final DataObjectModification<Node> dataObjectModification2 = mock(DataObjectModification.class);
- doReturn(WRITE).when(dataObjectModification2).getModificationType();
- doReturn(node2).when(dataObjectModification2).getDataAfter();
- doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId2)))
- .when(dataObjectModification2).getIdentifier();
+ doReturn(WRITE).when(dataObjectModification2).modificationType();
+ doReturn(node2).when(dataObjectModification2).dataAfter();
+ doReturn(new KeyStep<>(Node.class, new NodeKey(nodeId2))).when(dataObjectModification2).step();
final NetconfTopologyContext mockContext1 = mock(NetconfTopologyContext.class);
mockContextMap.put(nodeInstanceId1, setup -> {
return mockContext2;
});
- ClusterSingletonServiceRegistration mockClusterRegistration1 = mock(ClusterSingletonServiceRegistration.class);
- ClusterSingletonServiceRegistration mockClusterRegistration2 = mock(ClusterSingletonServiceRegistration.class);
+ final var mockClusterRegistration1 = mock(Registration.class);
+ final var mockClusterRegistration2 = mock(Registration.class);
doReturn(mockClusterRegistration1).when(clusterSingletonServiceProvider)
.registerClusterSingletonService(mockContext1);
.registerClusterSingletonService(mockContext2);
netconfTopologyManager.onDataTreeChanged(List.of(
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1),
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId2), dataObjectModification2)));
verify(clusterSingletonServiceProvider).registerClusterSingletonService(mockContext1);
.setPort(new PortNumber(Uint16.valueOf(33333))).build();
final Node updatedNode1 = new NodeBuilder().setNodeId(nodeId1).addAugmentation(updatedNetconfNode1).build();
- doReturn(WRITE).when(dataObjectModification1).getModificationType();
- doReturn(updatedNode1).when(dataObjectModification1).getDataAfter();
+ doReturn(WRITE).when(dataObjectModification1).modificationType();
+ doReturn(updatedNode1).when(dataObjectModification1).dataAfter();
- doReturn(SUBTREE_MODIFIED).when(dataObjectModification2).getModificationType();
- doReturn(node2).when(dataObjectModification2).getDataAfter();
+ doReturn(SUBTREE_MODIFIED).when(dataObjectModification2).modificationType();
+ doReturn(node2).when(dataObjectModification2).dataAfter();
doNothing().when(mockContext1).refresh(any());
doNothing().when(mockContext2).refresh(any());
netconfTopologyManager.onDataTreeChanged(List.of(
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1),
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId2), dataObjectModification2)));
ArgumentCaptor<NetconfTopologySetup> mockContext1Setup = ArgumentCaptor.forClass(NetconfTopologySetup.class);
verifyNoMoreInteractions(clusterSingletonServiceProvider);
// Notify of Node 1 deleted.
- doReturn(DELETE).when(dataObjectModification1).getModificationType();
+ doReturn(DELETE).when(dataObjectModification1).modificationType();
netconfTopologyManager.onDataTreeChanged(List.of(
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1)));
verify(mockClusterRegistration1).close();
reset(clusterSingletonServiceProvider);
final NetconfTopologyContext newMockContext1 = mock(NetconfTopologyContext.class);
- final ClusterSingletonServiceRegistration newMockClusterRegistration1 =
- mock(ClusterSingletonServiceRegistration.class);
+ final var newMockClusterRegistration1 = mock(Registration.class);
doThrow(new RuntimeException("mock error")).doReturn(newMockClusterRegistration1)
.when(clusterSingletonServiceProvider).registerClusterSingletonService(newMockContext1);
- doReturn(WRITE).when(dataObjectModification1).getModificationType();
- doReturn(node1).when(dataObjectModification1).getDataAfter();
+ doReturn(WRITE).when(dataObjectModification1).modificationType();
+ doReturn(node1).when(dataObjectModification1).dataAfter();
mockContextMap.put(nodeInstanceId1, setup -> {
assertEquals(node1, setup.getNode());
});
netconfTopologyManager.onDataTreeChanged(List.of(
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId1), dataObjectModification1)));
verify(clusterSingletonServiceProvider, times(2)).registerClusterSingletonService(newMockContext1);
.build();
final DataObjectModification<Node> dataObjectModification = mock(DataObjectModification.class);
- doReturn(WRITE).when(dataObjectModification).getModificationType();
- doReturn(node).when(dataObjectModification).getDataAfter();
- doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId)))
- .when(dataObjectModification).getIdentifier();
+ doReturn(WRITE).when(dataObjectModification).modificationType();
+ doReturn(node).when(dataObjectModification).dataAfter();
+ doReturn(new KeyStep<>(Node.class, new NodeKey(nodeId))).when(dataObjectModification).step();
final NetconfTopologyContext mockContext = mock(NetconfTopologyContext.class);
mockContextMap.put(nodeInstanceId, setup -> mockContext);
.registerClusterSingletonService(mockContext);
netconfTopologyManager.onDataTreeChanged(List.of(
- new CustomTreeModification(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ new CustomTreeModification(DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
nodeInstanceId), dataObjectModification)));
verify(clusterSingletonServiceProvider, times(3)).registerClusterSingletonService(mockContext);