Bump upstream versions
[netconf.git] / netconf / netconf-topology-singleton / src / test / java / org / opendaylight / netconf / topology / singleton / impl / MountPointEndToEndTest.java
index f626164bf423baa3cb1e3cd9caef4319e4392fee..44fcf748e1db5fe84ed5516e21b2bf663407491d 100644 (file)
@@ -17,17 +17,19 @@ import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
 
 import akka.actor.ActorSystem;
 import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -36,12 +38,11 @@ import com.google.common.util.concurrent.SettableFuture;
 import com.typesafe.config.ConfigFactory;
 import io.netty.util.concurrent.EventExecutor;
 import io.netty.util.concurrent.GlobalEventExecutor;
-import io.netty.util.concurrent.SucceededFuture;
 import java.io.File;
 import java.util.AbstractMap.SimpleEntry;
-import java.util.Arrays;
-import java.util.Collections;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.Set;
@@ -52,7 +53,9 @@ import org.apache.commons.io.FileUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
 import org.opendaylight.controller.cluster.ActorSystemProvider;
 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
@@ -62,13 +65,14 @@ import org.opendaylight.mdsal.binding.api.DataObjectModification;
 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
 import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.api.Transaction;
 import org.opendaylight.mdsal.binding.api.TransactionChain;
 import org.opendaylight.mdsal.binding.api.TransactionChainListener;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
@@ -89,14 +93,18 @@ import org.opendaylight.mdsal.dom.api.DOMService;
 import org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl;
 import org.opendaylight.mdsal.dom.broker.DOMRpcRouter;
 import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService;
 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.dom.impl.DOMClusterSingletonServiceProviderImpl;
 import org.opendaylight.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.netconf.nettyutil.ReconnectFuture;
 import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
+import org.opendaylight.netconf.sal.connect.api.SchemaResourceManager;
+import org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager;
+import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
+import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
 import org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
@@ -113,26 +121,32 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.PutTopInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 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.rcf8528.data.util.EmptyMountPointContext;
+import org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@@ -140,13 +154,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
+import org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -155,17 +169,21 @@ import org.slf4j.LoggerFactory;
  *
  * @author Thomas Pantelis
  */
-public class MountPointEndToEndTest {
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
+public class MountPointEndToEndTest extends AbstractBaseSchemasTest {
     private static final Logger LOG = LoggerFactory.getLogger(MountPointEndToEndTest.class);
 
     private static final String TOP_MODULE_NAME = "opendaylight-mdsal-list-test";
     private static final String ACTOR_SYSTEM_NAME = "test";
     private static final String TOPOLOGY_ID = TopologyNetconf.QNAME.getLocalName();
-    private static final NodeId NODE_ID = new NodeId("node-id");
-    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID = NetconfTopologyUtils.createTopologyNodeListPath(
-            new NodeKey(NODE_ID), TOPOLOGY_ID);
+    private static final KeyedInstanceIdentifier<Node, NodeKey> NODE_INSTANCE_ID =
+        NetconfTopologyUtils.createTopologyNodeListPath(new NodeKey(new NodeId("node-id")), TOPOLOGY_ID);
+
+    private static final String TEST_ROOT_DIRECTORY = "test-cache-root";
+    private static final String TEST_DEFAULT_SUBDIR = "test-schema";
 
     @Mock private DOMRpcProviderService mockRpcProviderRegistry;
+    @Mock private RpcProviderService mockRpcProviderService;
     @Mock private DOMActionProviderService mockActionProviderRegistry;
     @Mock private NetconfClientDispatcher mockClientDispatcher;
     @Mock private AAAEncryptionService mockEncryptionService;
@@ -196,32 +214,33 @@ public class MountPointEndToEndTest {
     private TransactionChain slaveTxChain;
 
     private final EventExecutor eventExecutor = GlobalEventExecutor.INSTANCE;
-    private final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(0).build();
-    private SchemaContext deviceSchemaContext;
+    private final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(Uint16.ZERO).build();
+    private EffectiveModelContext deviceSchemaContext;
     private YangModuleInfo topModuleInfo;
-    private SchemaPath putTopRpcSchemaPath;
-    private SchemaPath getTopRpcSchemaPath;
+    private QName putTopRpcSchemaPath;
+    private QName getTopRpcSchemaPath;
     private BindingNormalizedNodeSerializer bindingToNormalized;
     private YangInstanceIdentifier yangNodeInstanceId;
     private final TopDOMRpcImplementation topRpcImplementation = new TopDOMRpcImplementation();
+    private final ContainerNode getTopInput = ImmutableNodes.containerNode(GetTopInput.QNAME);
+
+    private SchemaResourceManager resourceManager;
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     @Before
     public void setUp() throws Exception {
-        initMocks(this);
-
         deleteCacheDir();
 
+        resourceManager = new DefaultSchemaResourceManager(new DefaultYangParserFactory(), TEST_ROOT_DIRECTORY,
+            TEST_DEFAULT_SUBDIR);
+
         topModuleInfo = BindingReflections.getModuleInfo(Top.class);
 
-        final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
-        moduleContext.addModuleInfos(Arrays.asList(topModuleInfo));
-        deviceSchemaContext = moduleContext.tryToCreateSchemaContext().get();
+        deviceSchemaContext = BindingRuntimeHelpers.createEffectiveModel(Top.class);
 
-        deviceRpcService.onGlobalContextUpdated(deviceSchemaContext);
+        deviceRpcService.onModelContextUpdated(deviceSchemaContext);
 
-        putTopRpcSchemaPath = findRpcDefinition("put-top").getPath();
-        getTopRpcSchemaPath = findRpcDefinition("get-top").getPath();
+        putTopRpcSchemaPath = findRpcDefinition("put-top").getQName();
+        getTopRpcSchemaPath = findRpcDefinition("get-top").getQName();
 
         deviceRpcService.getRpcProviderService().registerRpcImplementation(topRpcImplementation,
                 DOMRpcIdentifier.create(putTopRpcSchemaPath), DOMRpcIdentifier.create(getTopRpcSchemaPath));
@@ -232,14 +251,13 @@ public class MountPointEndToEndTest {
 
         yangNodeInstanceId = bindingToNormalized.toYangInstanceIdentifier(NODE_INSTANCE_ID);
 
-        doReturn(new SucceededFuture(GlobalEventExecutor.INSTANCE, null)).when(mockClientDispatcher)
-                .createReconnectingClient(any());
+        doReturn(mock(ReconnectFuture.class)).when(mockClientDispatcher).createReconnectingClient(any());
 
         LOG.info("****** Setup complete");
     }
 
     private static void deleteCacheDir() {
-        FileUtils.deleteQuietly(new File(NetconfTopologyUtils.CACHE_DIRECTORY));
+        FileUtils.deleteQuietly(new File(TEST_ROOT_DIRECTORY));
     }
 
     @After
@@ -253,28 +271,31 @@ public class MountPointEndToEndTest {
         AbstractConcurrentDataBrokerTest dataBrokerTest = newDataBrokerTest();
         masterDataBroker = dataBrokerTest.getDataBroker();
         deviceDOMDataBroker = dataBrokerTest.getDomBroker();
-        bindingToNormalized = dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized();
+        bindingToNormalized = dataBrokerTest.getDataBrokerTestCustomizer().getAdapterContext().currentSerializer();
 
         masterSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Master"));
 
-        masterClusterSingletonServiceProvider = new DOMClusterSingletonServiceProviderImpl(
-                new SimpleDOMEntityOwnershipService());
+        masterClusterSingletonServiceProvider = new DOMClusterSingletonServiceProviderImpl();
         masterClusterSingletonServiceProvider.initializeProvider();
 
         doReturn(masterSystem).when(mockMasterActorSystemProvider).getActorSystem();
 
         doReturn(MoreExecutors.newDirectExecutorService()).when(mockThreadPool).getExecutor();
 
-        NetconfTopologyUtils.DEFAULT_SCHEMA_REPOSITORY.registerSchemaSource(
+        final SchemaResourcesDTO resources =  resourceManager.getSchemaResources(
+            new NetconfNodeBuilder().setSchemaCacheDirectory(TEST_DEFAULT_SUBDIR).build(), "test");
+        resources.getSchemaRegistry().registerSchemaSource(
             id -> Futures.immediateFuture(YangTextSchemaSource.delegateForByteSource(id,
                     topModuleInfo.getYangTextByteSource())),
-            PotentialSchemaSource.create(RevisionSourceIdentifier.create(TOP_MODULE_NAME,
-                    topModuleInfo.getName().getRevision()), YangTextSchemaSource.class, 1));
-
-        masterNetconfTopologyManager = new NetconfTopologyManager(masterDataBroker, mockRpcProviderRegistry,
-            mockActionProviderRegistry, masterClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
-                mockMasterActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config,
-                masterMountPointService, mockEncryptionService, deviceActionFactory) {
+            PotentialSchemaSource.create(new SourceIdentifier(TOP_MODULE_NAME,
+                    topModuleInfo.getName().getRevision().map(Revision::toString).orElse(null)),
+                YangTextSchemaSource.class, 1));
+
+        masterNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, masterDataBroker,
+                mockRpcProviderRegistry, mockActionProviderRegistry, masterClusterSingletonServiceProvider,
+                mockKeepaliveExecutor, mockThreadPool, mockMasterActorSystemProvider, eventExecutor,
+                mockClientDispatcher, TOPOLOGY_ID, config, masterMountPointService, mockEncryptionService,
+                mockRpcProviderService, deviceActionFactory, resourceManager) {
             @Override
             protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
                 final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
@@ -310,10 +331,11 @@ public class MountPointEndToEndTest {
         doReturn(mockSlaveClusterSingletonServiceReg).when(mockSlaveClusterSingletonServiceProvider)
                 .registerClusterSingletonService(any());
 
-        slaveNetconfTopologyManager = new NetconfTopologyManager(slaveDataBroker, mockRpcProviderRegistry,
+        slaveNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, slaveDataBroker, mockRpcProviderRegistry,
             mockActionProviderRegistry, mockSlaveClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
                 mockSlaveActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config,
-                slaveMountPointService, mockEncryptionService, deviceActionFactory) {
+                slaveMountPointService, mockEncryptionService, mockRpcProviderService, deviceActionFactory,
+                resourceManager) {
             @Override
             protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
                 final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime,
@@ -359,12 +381,14 @@ public class MountPointEndToEndTest {
     private MasterSalFacade testMaster() throws InterruptedException, ExecutionException, TimeoutException {
         LOG.info("****** Testing master");
 
-        writeNetconfNode(NetconfTopologyUtils.DEFAULT_CACHE_DIRECTORY, masterDataBroker);
+        writeNetconfNode(TEST_DEFAULT_SUBDIR, masterDataBroker);
 
         final MasterSalFacade masterSalFacade = masterSalFacadeFuture.get(5, TimeUnit.SECONDS);
+        final ArrayList<String> capabilities = Lists.newArrayList(
+            NetconfMessageTransformUtil.NETCONF_CANDIDATE_URI.toString());
 
         masterSalFacade.onDeviceConnected(new EmptyMountPointContext(deviceSchemaContext),
-                NetconfSessionPreferences.fromStrings(Collections.emptyList()), deviceRpcService.getRpcService());
+                NetconfSessionPreferences.fromStrings(capabilities), deviceRpcService.getRpcService());
 
         DOMMountPoint masterMountPoint = awaitMountPoint(masterMountPointService);
 
@@ -432,14 +456,16 @@ public class MountPointEndToEndTest {
         slaveMountPointService.registerProvisionListener(slaveMountPointListener);
 
         masterSalFacadeFuture = SettableFuture.create();
-        writeNetconfNode(NetconfTopologyUtils.DEFAULT_CACHE_DIRECTORY, masterDataBroker);
+        writeNetconfNode(TEST_DEFAULT_SUBDIR, masterDataBroker);
 
         verify(masterMountPointListener, timeout(5000)).onMountPointRemoved(yangNodeInstanceId);
 
         MasterSalFacade masterSalFacade = masterSalFacadeFuture.get(5, TimeUnit.SECONDS);
+        final ArrayList<String> capabilities = Lists.newArrayList(
+            NetconfMessageTransformUtil.NETCONF_CANDIDATE_URI.toString());
 
         masterSalFacade.onDeviceConnected(new EmptyMountPointContext(deviceSchemaContext),
-                NetconfSessionPreferences.fromStrings(Collections.emptyList()), deviceRpcService.getRpcService());
+                NetconfSessionPreferences.fromStrings(capabilities), deviceRpcService.getRpcService());
 
         verify(masterMountPointListener, timeout(5000)).onMountPointCreated(yangNodeInstanceId);
 
@@ -479,38 +505,40 @@ public class MountPointEndToEndTest {
 
     private void testDOMRpcService(final DOMRpcService domRpcService)
             throws InterruptedException, ExecutionException, TimeoutException {
-        testPutTopRpc(domRpcService, new DefaultDOMRpcResult((NormalizedNode<?, ?>)null));
+        testPutTopRpc(domRpcService, new DefaultDOMRpcResult((NormalizedNode)null));
         testPutTopRpc(domRpcService, null);
         testPutTopRpc(domRpcService, new DefaultDOMRpcResult(ImmutableList.of(
-                RpcResultBuilder.newError(ErrorType.APPLICATION, "tag1", "error1"),
-                RpcResultBuilder.newError(ErrorType.APPLICATION, "tag2", "error2"))));
+                RpcResultBuilder.newError(ErrorType.APPLICATION, new ErrorTag("tag1"), "error1"),
+                RpcResultBuilder.newError(ErrorType.APPLICATION, new ErrorTag("tag2"), "error2"))));
 
         testGetTopRpc(domRpcService, new DefaultDOMRpcResult(bindingToNormalized.toNormalizedNodeRpcData(
-                new GetTopOutputBuilder().setTopLevelList(Arrays.asList(new TopLevelListBuilder().setName("one")
-                        .build())).build())));
+                new GetTopOutputBuilder().setTopLevelList(oneTopLevelList()).build())));
 
-        testFailedRpc(domRpcService, getTopRpcSchemaPath, null);
+        testFailedRpc(domRpcService, getTopRpcSchemaPath, getTopInput);
     }
 
     private void testPutTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result)
             throws InterruptedException, ExecutionException, TimeoutException {
         ContainerNode putTopInput = bindingToNormalized.toNormalizedNodeRpcData(
-                new PutTopInputBuilder().setTopLevelList(Arrays.asList(new TopLevelListBuilder().setName("one")
-                        .build())).build());
+                new PutTopInputBuilder().setTopLevelList(oneTopLevelList()).build());
         testRpc(domRpcService, putTopRpcSchemaPath, putTopInput, result);
     }
 
+    private static Map<TopLevelListKey, TopLevelList> oneTopLevelList() {
+        final TopLevelListKey key = new TopLevelListKey("one");
+        return ImmutableMap.of(key, new TopLevelListBuilder().withKey(key).build());
+    }
+
     private void testGetTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result)
             throws InterruptedException, ExecutionException, TimeoutException {
-        testRpc(domRpcService, getTopRpcSchemaPath, null, result);
+        testRpc(domRpcService, getTopRpcSchemaPath, getTopInput, result);
     }
 
-    private void testRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
-            final NormalizedNode<?, ?> input, final DOMRpcResult result) throws InterruptedException,
-            ExecutionException, TimeoutException {
+    private void testRpc(final DOMRpcService domRpcService, final QName qname, final NormalizedNode input,
+            final DOMRpcResult result) throws InterruptedException, ExecutionException, TimeoutException {
         final FluentFuture<DOMRpcResult> future = result == null ? FluentFutures.immediateNullFluentFuture()
                 : FluentFutures.immediateFluentFuture(result);
-        final DOMRpcResult actual = invokeRpc(domRpcService, schemaPath, input, future);
+        final DOMRpcResult actual = invokeRpc(domRpcService, qname, input, future);
         if (result == null) {
             assertNull(actual);
             return;
@@ -534,10 +562,10 @@ public class MountPointEndToEndTest {
         }
     }
 
-    private void testFailedRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
-            final NormalizedNode<?, ?> input) throws InterruptedException, TimeoutException {
+    private void testFailedRpc(final DOMRpcService domRpcService, final QName qname, final NormalizedNode input)
+            throws InterruptedException, TimeoutException {
         try {
-            invokeRpc(domRpcService, schemaPath, input, FluentFutures.immediateFailedFluentFuture(
+            invokeRpc(domRpcService, qname, input, FluentFutures.immediateFailedFluentFuture(
                     new ClusteringRpcException("mock")));
             fail("Expected exception");
         } catch (ExecutionException e) {
@@ -546,13 +574,13 @@ public class MountPointEndToEndTest {
         }
     }
 
-    private DOMRpcResult invokeRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
-            final NormalizedNode<?, ?> input, final FluentFuture<DOMRpcResult> returnFuture)
-                    throws InterruptedException, ExecutionException, TimeoutException {
+    private DOMRpcResult invokeRpc(final DOMRpcService domRpcService, final QName qname, final NormalizedNode input,
+            final FluentFuture<DOMRpcResult> returnFuture)
+                throws InterruptedException, ExecutionException, TimeoutException {
         topRpcImplementation.init(returnFuture);
-        final ListenableFuture<DOMRpcResult> resultFuture = domRpcService.invokeRpc(schemaPath, input);
+        final ListenableFuture<? extends DOMRpcResult> resultFuture = domRpcService.invokeRpc(qname, input);
 
-        topRpcImplementation.verify(DOMRpcIdentifier.create(schemaPath), input);
+        topRpcImplementation.verify(DOMRpcIdentifier.create(qname), input);
 
         return resultFuture.get(5, TimeUnit.SECONDS);
     }
@@ -589,21 +617,27 @@ public class MountPointEndToEndTest {
 
     private static void writeNetconfNode(final String cacheDir, final DataBroker databroker)
             throws InterruptedException, ExecutionException, TimeoutException {
-        final NetconfNode netconfNode = new NetconfNodeBuilder()
-                .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
-                .setPort(new PortNumber(Uint16.valueOf(1234)))
-                .setActorResponseWaitTime(10)
-                .setTcpOnly(Boolean.TRUE)
-                .setSchemaless(Boolean.FALSE)
-                .setKeepaliveDelay(0L)
-                .setConnectionTimeoutMillis(5000L)
-                .setDefaultRequestTimeoutMillis(5000L)
-                .setMaxConnectionAttempts(1L)
-                .setCredentials(new LoginPwUnencryptedBuilder().setLoginPasswordUnencrypted(
-                        new LoginPasswordUnencryptedBuilder().setUsername("user").setPassword("pass").build()).build())
-                .setSchemaCacheDirectory(cacheDir)
+        final Node node = new NodeBuilder()
+                .withKey(NODE_INSTANCE_ID.getKey())
+                .addAugmentation(new NetconfNodeBuilder()
+                    .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
+                    .setPort(new PortNumber(Uint16.valueOf(1234)))
+                    .setActorResponseWaitTime(Uint16.valueOf(10))
+                    .setTcpOnly(Boolean.TRUE)
+                    .setSchemaless(Boolean.FALSE)
+                    .setKeepaliveDelay(Uint32.ZERO)
+                    .setConnectionTimeoutMillis(Uint32.valueOf(5000))
+                    .setDefaultRequestTimeoutMillis(Uint32.valueOf(5000))
+                    .setMaxConnectionAttempts(Uint32.ONE)
+                    .setCredentials(new LoginPwUnencryptedBuilder()
+                        .setLoginPasswordUnencrypted(new LoginPasswordUnencryptedBuilder()
+                            .setUsername("user")
+                            .setPassword("pass")
+                            .build())
+                        .build())
+                    .setSchemaCacheDirectory(cacheDir)
+                    .build())
                 .build();
-        final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(NetconfNode.class, netconfNode).build();
 
         final WriteTransaction writeTx = databroker.newWriteOnlyTransaction();
         writeTx.put(LogicalDatastoreType.CONFIGURATION, NODE_INSTANCE_ID, node);
@@ -611,8 +645,8 @@ public class MountPointEndToEndTest {
     }
 
     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)
+            final NormalizedNode expNode) throws InterruptedException, ExecutionException, TimeoutException {
+        final Optional<NormalizedNode> read = readTx.read(LogicalDatastoreType.CONFIGURATION, path)
                 .get(5, TimeUnit.SECONDS);
         assertTrue(read.isPresent());
         assertEquals(expNode, read.get());
@@ -651,7 +685,7 @@ public class MountPointEndToEndTest {
 
     private void awaitMountPointNotPresent(final DOMMountPointService mountPointService) {
         await().atMost(5, TimeUnit.SECONDS).until(
-            () -> !mountPointService.getMountPoint(yangNodeInstanceId).isPresent());
+            () -> mountPointService.getMountPoint(yangNodeInstanceId).isEmpty());
     }
 
     private static DOMDataBroker getDOMDataBroker(final DOMMountPoint mountPoint) {
@@ -695,24 +729,23 @@ public class MountPointEndToEndTest {
     }
 
     private static class TopDOMRpcImplementation implements DOMRpcImplementation {
-        private volatile SettableFuture<Entry<DOMRpcIdentifier, NormalizedNode<?, ?>>> rpcInvokedFuture;
+        private volatile SettableFuture<Entry<DOMRpcIdentifier, NormalizedNode>> rpcInvokedFuture;
         private volatile FluentFuture<DOMRpcResult> returnFuture;
 
         @Override
-        public FluentFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc,
-                final NormalizedNode<?, ?> input) {
+        public FluentFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) {
             rpcInvokedFuture.set(new SimpleEntry<>(rpc, input));
             return returnFuture;
         }
 
         void init(final FluentFuture<DOMRpcResult> retFuture) {
-            this.returnFuture = retFuture;
+            returnFuture = retFuture;
             rpcInvokedFuture = SettableFuture.create();
         }
 
-        void verify(final DOMRpcIdentifier expRpc, final NormalizedNode<?, ?> expInput)
+        void verify(final DOMRpcIdentifier expRpc, final NormalizedNode expInput)
                 throws InterruptedException, ExecutionException, TimeoutException {
-            final Entry<DOMRpcIdentifier, NormalizedNode<?, ?>> actual = rpcInvokedFuture.get(5, TimeUnit.SECONDS);
+            final Entry<DOMRpcIdentifier, NormalizedNode> actual = rpcInvokedFuture.get(5, TimeUnit.SECONDS);
             assertEquals(expRpc, actual.getKey());
             assertEquals(expInput, actual.getValue());
         }