Peel bierman02 local RPC test invocations 58/100258/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Mar 2022 14:21:39 +0000 (15:21 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Mar 2022 14:25:07 +0000 (15:25 +0100)
We have a few callers dealing with RPCs. Peel them to a new factory
method. Also fixes and enables a previously-disabled test.

JIRA: NETCONF-818
Change-Id: I888069dee94307003905bfa615b03ecccc202c11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/InstanceIdentifierContext.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java

index 26e3a4314caf01f7d5f28ec691a9453ba119f62d..ff290ce001162f99cbb2f248bab935435df4b5b0 100644 (file)
@@ -62,6 +62,13 @@ public final class InstanceIdentifierContext {
         return new InstanceIdentifierContext(context, null);
     }
 
+    // Legacy bierman02 invokeRpc()
+    public static @NonNull InstanceIdentifierContext ofLocalRpc(final EffectiveModelContext context,
+        // FIXME: this this method really needed?
+            final RpcDefinition rpc) {
+        return new InstanceIdentifierContext(context, rpc, null);
+    }
+
     public static @NonNull InstanceIdentifierContext ofLocalRpcInput(final EffectiveModelContext context,
             // FIXME: this this method really needed?
             final RpcDefinition rpc) {
index f4909eb24c9e7ceb4c3c90f418f9c56902934d17..4aa1c8ade8da5ec93c32794e523e7c4af3ffce41 100644 (file)
@@ -64,6 +64,7 @@ import org.opendaylight.yangtools.yang.model.api.ContainerLike;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.api.InputSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
@@ -104,7 +105,6 @@ public class InvokeRpcMethodTest {
      * string - first argument).
      */
     @Test
-    @Ignore
     public void invokeRpcMethodTest() {
         controllerContext.findModuleNameByNamespace(XMLNamespace.of("invoke:rpc:module"));
 
@@ -122,15 +122,15 @@ public class InvokeRpcMethodTest {
         final Module rpcModule = schema.findModules("invoke-rpc-module").iterator().next();
         assertNotNull(rpcModule);
         final QName rpcQName = QName.create(rpcModule.getQNameModule(), "rpc-test");
-        ContainerLike rpcInputSchemaNode = null;
+        RpcDefinition rpcSchemaNode = null;
         for (final RpcDefinition rpc : rpcModule.getRpcs()) {
             if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
-                rpcInputSchemaNode = rpc.getInput();
+                rpcSchemaNode = rpc;
                 break;
             }
         }
-        assertNotNull(rpcInputSchemaNode);
-
+        assertNotNull(rpcSchemaNode);
+        final InputSchemaNode rpcInputSchemaNode = rpcSchemaNode.getInput();
         final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> container =
                 SchemaAwareBuilders.containerBuilder(rpcInputSchemaNode);
 
@@ -148,8 +148,8 @@ public class InvokeRpcMethodTest {
         contNode.withChild(lfNode);
         container.withChild(contNode.build());
 
-        return new NormalizedNodeContext(
-                new InstanceIdentifierContext(null, rpcInputSchemaNode, null, schema), container.build());
+        return new NormalizedNodeContext(InstanceIdentifierContext.ofLocalRpc(schema, rpcSchemaNode),
+            container.build());
     }
 
     @Test
index 552850396e72f1d20ad573cb4fc945de3e49d035..ff3c32335fa94252727b75f104d2ac1a44f7aa0b 100644 (file)
@@ -174,7 +174,7 @@ public class RestconfImplTest {
 
         final RpcDefinition schemaNode = mock(RpcDefinition.class);
         doReturn(mock(SchemaPath.class)).when(schemaNode).getPath();
-        doReturn(new InstanceIdentifierContext(null, schemaNode, null, null)).when(payload)
+        doReturn(InstanceIdentifierContext.ofLocalRpc(schemaContext, schemaNode)).when(payload)
                 .getInstanceIdentifierContext();
 
         doReturn(QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote",
index 13459ed317f9cb2c3638f933460b3349d6a00655..a022c0e789e24848ed2a1992a4b6175a882737e9 100644 (file)
@@ -169,7 +169,6 @@ public class URIParametersParsing {
         when(rpcDef.getPath()).thenReturn(SchemaPath.create(true, rpcQName));
         when(rpcDef.getQName()).thenReturn(rpcQName);
 
-        return new NormalizedNodeContext(new InstanceIdentifierContext(null, rpcDef, null, schema),
-                container.build());
+        return new NormalizedNodeContext(InstanceIdentifierContext.ofLocalRpc(schema, rpcDef), container.build());
     }
 }