X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRemoteOpsImplementationTest.java;fp=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRemoteOpsImplementationTest.java;h=f2aeb2b0674d06e62e4f77dcc75c7319d4f92192;hb=ba6824307ad4b3c272abefe9682d623adc3b42d2;hp=6a7681223eca790c0b78e40ecb2149f668ea3fa6;hpb=f7e81dfc749e2a95b69ae0bba9064dba2cb531ef;p=controller.git diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteOpsImplementationTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteOpsImplementationTest.java index 6a7681223e..f2aeb2b067 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteOpsImplementationTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteOpsImplementationTest.java @@ -33,7 +33,6 @@ import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult; import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; /** @@ -51,15 +50,11 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { final ContainerNode rpcOutput = makeRPCOutput("bar"); final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput); -// Answer> answer = FluentFutures.immediateFluentFuture(rpcResult); - - final NormalizedNode invokeRpcInput = makeRPCInput("foo"); - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor> inputCaptor = - ArgumentCaptor.forClass(NormalizedNode.class); + final ContainerNode invokeRpcInput = makeRPCInput("foo"); + final ArgumentCaptor inputCaptor = ArgumentCaptor.forClass(ContainerNode.class); - when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn( - FluentFutures.immediateFluentFuture(rpcResult)); + doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2) + .invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture()); final ListenableFuture frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput); assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture); @@ -75,42 +70,18 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { public void testInvokeAction() throws Exception { final ContainerNode actionOutput = makeRPCOutput("bar"); final DOMActionResult actionResult = new SimpleDOMActionResult(actionOutput, Collections.emptyList()); - final NormalizedNode invokeActionInput = makeRPCInput("foo"); - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor inputCaptor = - ArgumentCaptor.forClass(ContainerNode.class); + final ContainerNode invokeActionInput = makeRPCInput("foo"); + final ArgumentCaptor inputCaptor = ArgumentCaptor.forClass(ContainerNode.class); doReturn(FluentFutures.immediateFluentFuture(actionResult)).when(domActionService2).invokeAction( eq(TEST_RPC_TYPE), eq(TEST_DATA_TREE_ID), inputCaptor.capture()); final ListenableFuture frontEndFuture = remoteActionImpl1.invokeAction(TEST_RPC_TYPE, - TEST_DATA_TREE_ID, (ContainerNode) invokeActionInput); + TEST_DATA_TREE_ID, invokeActionInput); assertTrue(frontEndFuture instanceof RemoteDOMActionFuture); final DOMActionResult result = frontEndFuture.get(5, TimeUnit.SECONDS); assertEquals(actionOutput, result.getOutput().get()); } - /** - * This test method invokes and executes the remote rpc. - */ - @Test - public void testInvokeRpcWithNullInput() throws Exception { - final ContainerNode rpcOutput = makeRPCOutput("bar"); - final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput); - - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor> inputCaptor = - (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class); - - when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn( - FluentFutures.immediateFluentFuture(rpcResult)); - - ListenableFuture frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, null); - assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture); - - final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS); - assertEquals(rpcOutput, result.getResult()); - } - /** * This test method invokes and executes the remote action. */ @@ -119,9 +90,7 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { final ContainerNode actionOutput = makeRPCOutput("bar"); final DOMActionResult actionResult = new SimpleDOMActionResult(actionOutput); - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor inputCaptor = - ArgumentCaptor.forClass(ContainerNode.class); + final ArgumentCaptor inputCaptor = ArgumentCaptor.forClass(ContainerNode.class); doReturn(FluentFutures.immediateFluentFuture(actionResult)).when(domActionService2).invokeAction( eq(TEST_RPC_TYPE), eq(TEST_DATA_TREE_ID), inputCaptor.capture()); @@ -141,13 +110,11 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { final ContainerNode rpcOutput = null; final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput); - final NormalizedNode invokeRpcInput = makeRPCInput("foo"); - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor> inputCaptor = - (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class); + final ContainerNode invokeRpcInput = makeRPCInput("foo"); + final ArgumentCaptor inputCaptor = ArgumentCaptor.forClass(ContainerNode.class); - when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn( - FluentFutures.immediateFluentFuture(rpcResult)); + doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2) + .invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture()); final ListenableFuture frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput); assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture); @@ -162,10 +129,8 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { @SuppressWarnings({"checkstyle:AvoidHidingCauseException", "checkstyle:IllegalThrows"}) @Test(expected = DOMRpcException.class) public void testInvokeRpcWithRemoteFailedFuture() throws Throwable { - final NormalizedNode invokeRpcInput = makeRPCInput("foo"); - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor> inputCaptor = - (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class); + final ContainerNode invokeRpcInput = makeRPCInput("foo"); + final ArgumentCaptor inputCaptor = ArgumentCaptor.forClass(ContainerNode.class); when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn( FluentFutures.immediateFailedFluentFuture(new RemoteDOMRpcException("Test Exception", null))); @@ -187,9 +152,7 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { @Test(expected = DOMActionException.class) public void testInvokeActionWithRemoteFailedFuture() throws Throwable { final ContainerNode invokeActionInput = makeRPCInput("foo"); - @SuppressWarnings({"unchecked", "rawtypes"}) - final ArgumentCaptor inputCaptor = - ArgumentCaptor.forClass(ContainerNode.class); + final ArgumentCaptor inputCaptor = ArgumentCaptor.forClass(ContainerNode.class); when(domActionService2.invokeAction(eq(TEST_RPC_TYPE), eq(TEST_DATA_TREE_ID), inputCaptor.capture())).thenReturn(FluentFutures.immediateFailedFluentFuture( @@ -213,7 +176,7 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { @Ignore @Test(expected = RemoteDOMRpcException.class) public void testInvokeRpcWithAkkaTimeoutException() throws Exception { - final NormalizedNode invokeRpcInput = makeRPCInput("foo"); + final ContainerNode invokeRpcInput = makeRPCInput("foo"); final ListenableFuture frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput); assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture); @@ -227,10 +190,10 @@ public class RemoteOpsImplementationTest extends AbstractOpsTest { @Test(expected = DOMRpcException.class) @SuppressWarnings({"checkstyle:AvoidHidingCauseException", "checkstyle:IllegalThrows"}) public void testInvokeRpcWithLookupException() throws Throwable { - final NormalizedNode invokeRpcInput = makeRPCInput("foo"); + final ContainerNode invokeRpcInput = makeRPCInput("foo"); doThrow(new RuntimeException("test")).when(domRpcService2).invokeRpc(any(SchemaPath.class), - any(NormalizedNode.class)); + any(ContainerNode.class)); final ListenableFuture frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput); assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);