Teach NETCONF about YANG 1.1 actions in cluster topology
[netconf.git] / netconf / netconf-topology-singleton / src / test / java / org / opendaylight / netconf / topology / singleton / impl / NetconfNodeManagerTest.java
index 721817e809085435ab67da54f7b1a693f87b9e5d..e270ea6f8deb131032e5083a9ce9d012fb09eeb1 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.netconf.topology.singleton.impl;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.after;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
@@ -19,9 +19,9 @@ import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.MockitoAnnotations.initMocks;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.DELETE;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED;
-import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.WRITE;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED;
+import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
 
 import akka.actor.ActorSystem;
 import akka.actor.Props;
@@ -49,15 +49,16 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver;
 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
@@ -120,6 +121,9 @@ public class NetconfNodeManagerTest {
     @Mock
     private DOMRpcService mockRpcService;
 
+    @Mock
+    private DOMActionService mockActionService;
+
     @Mock
     private NetconfDeviceSchemasResolver mockSchemasResolver;
 
@@ -219,7 +223,7 @@ public class NetconfNodeManagerTest {
         doReturn(node).when(mockDataObjModification).getDataAfter();
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         verify(mockMountPointBuilder, timeout(5000)).register();
@@ -235,7 +239,7 @@ public class NetconfNodeManagerTest {
         doReturn(null).when(mockDataObjModification).getDataAfter();
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         verify(mockMountPointReg, timeout(5000)).close();
@@ -249,7 +253,7 @@ public class NetconfNodeManagerTest {
         doReturn(node).when(mockDataObjModification).getDataAfter();
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         verify(mockMountPointBuilder, timeout(5000)).register();
@@ -262,7 +266,7 @@ public class NetconfNodeManagerTest {
         doReturn(node).when(mockDataObjModification).getDataBefore();
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         verify(mockMountPointReg, timeout(5000)).close();
@@ -283,7 +287,7 @@ public class NetconfNodeManagerTest {
         doReturn(updatedNode).when(mockDataObjModification).getDataAfter();
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         verify(mockMountPointReg, timeout(5000)).close();
@@ -313,7 +317,7 @@ public class NetconfNodeManagerTest {
         // First try the registration where the perceived master hasn't been initialized as the master.
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         verify(mockMountPointBuilder, after(1000).never()).register();
@@ -328,7 +332,7 @@ public class NetconfNodeManagerTest {
                 yangTextSchemaSourceRequestFuture);
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         yangTextSchemaSourceRequestFuture.get(5, TimeUnit.SECONDS);
@@ -344,7 +348,7 @@ public class NetconfNodeManagerTest {
                 askForMasterMountPointFuture);
 
         netconfNodeManager.onDataTreeChanged(Collections.singletonList(
-                new NetconfTopologyManagerTest.CustomTreeModification(new DataTreeIdentifier<>(
+                new NetconfTopologyManagerTest.CustomTreeModification(DataTreeIdentifier.create(
                         LogicalDatastoreType.OPERATIONAL, nodeListPath), mockDataObjModification)));
 
         askForMasterMountPointFuture.get(5, TimeUnit.SECONDS);
@@ -382,7 +386,7 @@ public class NetconfNodeManagerTest {
         TestKit kit = new TestKit(masterSystem);
 
         testMasterActorRef.tell(new CreateInitialMasterActorData(mockDeviceDataBroker, SOURCE_IDENTIFIERS,
-                mockRpcService), kit.getRef());
+                mockRpcService, mockActionService), kit.getRef());
 
         kit.expectMsgClass(MasterActorDataInitialized.class);
     }
@@ -390,15 +394,15 @@ public class NetconfNodeManagerTest {
     private static class TestMasterActor extends NetconfNodeActor {
         final Map<Class<?>, CompletableFuture<? extends Object>> messagesToDrop = new ConcurrentHashMap<>();
 
-        TestMasterActor(NetconfTopologySetup setup, RemoteDeviceId deviceId, Timeout actorResponseWaitTime,
-                DOMMountPointService mountPointService) {
+        TestMasterActor(final NetconfTopologySetup setup, final RemoteDeviceId deviceId,
+                final Timeout actorResponseWaitTime, final DOMMountPointService mountPointService) {
             super(setup, deviceId, setup.getSchemaResourcesDTO().getSchemaRegistry(),
                     setup.getSchemaResourcesDTO().getSchemaRepository(), actorResponseWaitTime, mountPointService);
         }
 
         @SuppressWarnings({ "rawtypes", "unchecked" })
         @Override
-        public void handleReceive(Object message) {
+        public void handleReceive(final Object message) {
             CompletableFuture dropFuture = messagesToDrop.remove(message.getClass());
             if (dropFuture != null) {
                 dropFuture.complete(message);