Make createTopologyNodeListPath() a bit more useful 86/97386/3
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 4 Sep 2021 00:10:59 +0000 (02:10 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 4 Sep 2021 01:10:35 +0000 (03:10 +0200)
We are taking an explicit key to construct a KeyedInstanceIdentifier,
which can easily return it back. Expose this functionality to others,
which is useful at least for a test.

Change-Id: I82fab42271adcdbb75f03aaccc750ae5a0b32384
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologyUtils.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java

index 6d44d74174fb9f937f94faa1770e08863b54e05c..b492e93bcdf8a3c3eeefe171fe2ed2341c60fbae 100644 (file)
@@ -73,7 +73,8 @@ public final class NetconfTopologyUtils {
         return networkTopology.child(Topology.class, new TopologyKey(new TopologyId(topologyId)));
     }
 
-    public static InstanceIdentifier<Node> createTopologyNodeListPath(final NodeKey key, final String topologyId) {
+    public static KeyedInstanceIdentifier<Node, NodeKey> createTopologyNodeListPath(final NodeKey key,
+            final String topologyId) {
         return createTopologyListPath(topologyId)
                 .child(Node.class, new NodeKey(new NodeId(key.getNodeId().getValue())));
     }
index 2bccd69783d0431a70f314e2ecf4857f85f2b0da..59f8f167684376022bc523032af9b0ff7d5c9e34 100644 (file)
@@ -136,6 +136,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 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.QName;
 import org.opendaylight.yangtools.yang.common.RpcError;
@@ -172,9 +173,8 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest {
     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";
@@ -616,7 +616,7 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest {
     private static void writeNetconfNode(final String cacheDir, final DataBroker databroker)
             throws InterruptedException, ExecutionException, TimeoutException {
         final Node node = new NodeBuilder()
-                .setNodeId(NODE_ID)
+                .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)))