From 743b20ba20032dc09f992e9c381da8c866657af8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 25 Mar 2022 15:21:39 +0100 Subject: [PATCH] Peel bierman02 local RPC test invocations 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 --- .../common/context/InstanceIdentifierContext.java | 7 +++++++ .../restconf/impl/test/InvokeRpcMethodTest.java | 14 +++++++------- .../sal/restconf/impl/test/RestconfImplTest.java | 2 +- .../restconf/impl/test/URIParametersParsing.java | 3 +-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/InstanceIdentifierContext.java b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/InstanceIdentifierContext.java index 26e3a4314c..ff290ce001 100644 --- a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/InstanceIdentifierContext.java +++ b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/InstanceIdentifierContext.java @@ -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) { diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java index f4909eb24c..4aa1c8ade8 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java @@ -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 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 diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java index 552850396e..ff3c32335f 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java @@ -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", diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java index 13459ed317..a022c0e789 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java @@ -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()); } } -- 2.36.6