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 / MountPointEndToEndTest.java
index 94e8f4b2f70cecc9127c64c47b542c3adf14c3c3..be2e580ff1602a523135f46a0e00abf2e890ab1d 100644 (file)
@@ -71,8 +71,10 @@ import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSeriali
 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
@@ -93,6 +95,7 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegist
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl;
 import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
 import org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
@@ -161,10 +164,12 @@ public class MountPointEndToEndTest {
             new NodeKey(NODE_ID), TOPOLOGY_ID);
 
     @Mock private DOMRpcProviderService mockRpcProviderRegistry;
+    @Mock private DOMActionProviderService mockActionProviderRegistry;
     @Mock private NetconfClientDispatcher mockClientDispatcher;
     @Mock private AAAEncryptionService mockEncryptionService;
     @Mock private ThreadPool mockThreadPool;
     @Mock private ScheduledThreadPool mockKeepaliveExecutor;
+    @Mock private DeviceActionFactory deviceActionFactory;
 
     @Mock private ActorSystemProvider mockMasterActorSystemProvider;
     @Mock private DOMMountPointListener masterMountPointListener;
@@ -265,14 +270,16 @@ public class MountPointEndToEndTest {
                     topModuleInfo.getName().getRevision()), YangTextSchemaSource.class, 1));
 
         masterNetconfTopologyManager = new NetconfTopologyManager(masterDataBroker, mockRpcProviderRegistry,
-                masterClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
+            mockActionProviderRegistry, masterClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
                 mockMasterActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config,
-                masterMountPointService, mockEncryptionService) {
+                masterMountPointService, mockEncryptionService, deviceActionFactory) {
             @Override
             protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
-                    final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime) {
+                final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
+                final DeviceActionFactory deviceActionFact) {
                 NetconfTopologyContext context =
-                        super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime);
+                    super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime, deviceActionFact);
+
                 NetconfTopologyContext spiedContext = spy(context);
                 doAnswer(invocation -> {
                     final MasterSalFacade spiedFacade = (MasterSalFacade) spy(invocation.callRealMethod());
@@ -302,14 +309,16 @@ public class MountPointEndToEndTest {
                 .registerClusterSingletonService(any());
 
         slaveNetconfTopologyManager = new NetconfTopologyManager(slaveDataBroker, mockRpcProviderRegistry,
-                mockSlaveClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
+            mockActionProviderRegistry, mockSlaveClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
                 mockSlaveActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config,
-                slaveMountPointService, mockEncryptionService) {
+                slaveMountPointService, mockEncryptionService, deviceActionFactory) {
             @Override
             protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
-                    final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime) {
-                NetconfTopologyContext spiedContext =
-                        spy(super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime));
+                final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
+                final DeviceActionFactory actionFactory) {
+                NetconfTopologyContext spiedContext = spy(super.newNetconfTopologyContext(setup, serviceGroupIdent,
+                    actorResponseWaitTime, actionFactory));
+
                 slaveNetconfTopologyContextFuture.set(spiedContext);
                 return spiedContext;
             }
@@ -599,7 +608,7 @@ public class MountPointEndToEndTest {
         writeTx.commit().get(5, TimeUnit.SECONDS);
     }
 
-    private static void verifyDataInStore(final DOMDataTreeReadTransaction readTx, final YangInstanceIdentifier path,
+    private static void verifyDataInStore(final DOMDataTreeReadOperations readTx, final YangInstanceIdentifier path,
             final NormalizedNode<?, ?> expNode) throws InterruptedException, ExecutionException, TimeoutException {
         final Optional<NormalizedNode<?, ?>> read = readTx.read(LogicalDatastoreType.CONFIGURATION, path)
                 .get(5, TimeUnit.SECONDS);
@@ -651,6 +660,10 @@ public class MountPointEndToEndTest {
         return getMountPointService(mountPoint, DOMRpcService.class);
     }
 
+    private static DOMActionService getDomActionService(final DOMMountPoint mountPoint) {
+        return getMountPointService(mountPoint, DOMActionService.class);
+    }
+
     private static <T extends DOMService> T getMountPointService(final DOMMountPoint mountPoint,
             final Class<T> serviceClass) {
         final Optional<T> maybeService = mountPoint.getService(serviceClass);