Search in sources :

Example 1 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.

the class RemoteOpsImplementationTest method testInvokeRpcWithNoOutput.

/**
 * This test method invokes and executes the remote rpc.
 */
@Test
public void testInvokeRpcWithNoOutput() throws Exception {
    final ContainerNode rpcOutput = null;
    final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput);
    final NormalizedNode invokeRpcInput = makeRPCInput("foo");
    @SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<NormalizedNode> inputCaptor = (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class);
    doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2).invokeRpc(eq(TEST_RPC), inputCaptor.capture());
    final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
    assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
    final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
    assertNull(result.getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) ArgumentCaptor(org.mockito.ArgumentCaptor) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 2 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.

the class RemoteOpsImplementationTest method testInvokeRpc.

/**
 * This test method invokes and executes the remote rpc.
 */
@Test
public void testInvokeRpc() throws Exception {
    final ContainerNode rpcOutput = makeRPCOutput("bar");
    final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput);
    final NormalizedNode invokeRpcInput = makeRPCInput("foo");
    @SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<NormalizedNode> inputCaptor = ArgumentCaptor.forClass(NormalizedNode.class);
    doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2).invokeRpc(eq(TEST_RPC), inputCaptor.capture());
    final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
    assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
    final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
    assertEquals(rpcOutput, result.getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 3 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.

the class RemoteOpsImplementationTest method testInvokeRpcWithNullInput.

/**
 * 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<NormalizedNode> inputCaptor = (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class);
    doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2).invokeRpc(eq(TEST_RPC), inputCaptor.capture());
    ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, null);
    assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
    final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
    assertEquals(rpcOutput, result.getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) ArgumentCaptor(org.mockito.ArgumentCaptor) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 4 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.

the class OpsBrokerTest method testExecuteRpc.

@Test
public void testExecuteRpc() {
    final ContainerNode invokeRpcResult = makeRPCOutput("bar");
    final DOMRpcResult rpcResult = new DefaultDOMRpcResult(invokeRpcResult);
    doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService1).invokeRpc(eq(TEST_RPC), any());
    final ExecuteRpc executeRpc = ExecuteRpc.from(TEST_RPC_ID, null);
    rpcInvoker1.tell(executeRpc, rpcRegistry1Probe.getRef());
    final RpcResponse rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), RpcResponse.class);
    assertEquals(rpcResult.getResult(), rpcResponse.getOutput());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) ExecuteRpc(org.opendaylight.controller.remote.rpc.messages.ExecuteRpc) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) RpcResponse(org.opendaylight.controller.remote.rpc.messages.RpcResponse) Test(org.junit.Test)

Example 5 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project mdsal by opendaylight.

the class Mdsal500Test method testDOMRegistrationWithBindingInvocation.

@Test
public void testDOMRegistrationWithBindingInvocation() throws InterruptedException, ExecutionException, TimeoutException {
    SwitchOutput baSwitchOutput = new SwitchOutputBuilder().build();
    biRpcProviderService.registerRpcImplementation((rpc, input) -> FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(testContext.getCodec().currentSerializer().toNormalizedNodeRpcData(baSwitchOutput))), DOMRpcIdentifier.create(SWITCH_QNAME));
    final Mdsal500Service baSwitchService = baRpcConsumerService.getRpcService(Mdsal500Service.class);
    Future<RpcResult<SwitchOutput>> baResult = baSwitchService.switch$(switchBuilder(FOO).build());
    assertNotNull(baResult);
    assertEquals(baSwitchOutput, baResult.get(5, TimeUnit.SECONDS).getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) Mdsal500Service(org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service) SwitchOutputBuilder(org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) SwitchOutput(org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutput) Test(org.junit.Test)

Aggregations

DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)72 Test (org.junit.Test)51 QName (org.opendaylight.yangtools.yang.common.QName)27 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)25 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)25 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)16 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)15 NetconfRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy)15 NormalizedNodePayload (org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload)12 Before (org.junit.Before)10 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)10 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)10 NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)9 MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)9 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)5 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)5 RpcError (org.opendaylight.yangtools.yang.common.RpcError)5 ArrayList (java.util.ArrayList)4 NormalizedNodeMessage (org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage)4