Search in sources :

Example 26 with DOMRpcResult

use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.

the class RestconfInvokeOperationsServiceImplTest method invokeRpcTest.

@Test
public void invokeRpcTest() throws InterruptedException, ExecutionException {
    final DOMRpcResult mockResult = new DefaultDOMRpcResult(OUTPUT, List.of());
    doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(RPC, INPUT);
    final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, RPC, rpcService).get();
    assertTrue(rpcResult.getErrors().isEmpty());
    assertEquals(OUTPUT, rpcResult.getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) Test(org.junit.Test)

Example 27 with DOMRpcResult

use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.

the class RestconfInvokeOperationsServiceImplTest method prepNNC.

private NormalizedNodePayload prepNNC(final NormalizedNode result) {
    final InstanceIdentifierContext<?> context = mock(InstanceIdentifierContext.class);
    final RpcDefinition schemaNode = mock(RpcDefinition.class);
    final QName qname = QName.create("invoke:rpc:module", "2013-12-03", "rpcTest");
    doReturn(qname).when(schemaNode).getQName();
    doReturn(schemaNode).when(context).getSchemaNode();
    final NormalizedNode data = mock(NormalizedNode.class);
    final DOMRpcResult domRpcResult = mock(DOMRpcResult.class);
    doReturn(immediateFluentFuture(domRpcResult)).when(rpcService).invokeRpc(qname, data);
    doReturn(result).when(domRpcResult).getResult();
    return NormalizedNodePayload.of(context, data);
}
Also used : RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) QName(org.opendaylight.yangtools.yang.common.QName) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)

Example 28 with DOMRpcResult

use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.

the class CreateStreamUtilTest method createStreamTest.

@Test
public void createStreamTest() {
    payload = prepareDomPayload("create-data-change-event-subscription", RpcDefinition::getInput, "toaster", "path");
    final DOMRpcResult result = CreateStreamUtil.createDataChangeNotifiStream(payload, refSchemaCtx);
    assertEquals(result.getErrors(), Collections.emptyList());
    final NormalizedNode testedNn = result.getResult();
    assertNotNull(testedNn);
    final NormalizedNodePayload contextRef = prepareDomPayload("create-data-change-event-subscription", RpcDefinition::getOutput, "data-change-event-subscription/toaster:toaster/datastore=CONFIGURATION/scope=BASE", "stream-name");
    assertEquals(contextRef.getData(), testedNn);
}
Also used : DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 29 with DOMRpcResult

use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.

the class CreateStreamUtilTest method createStreamWrongInputRpcTest.

@Test(expected = RestconfDocumentedException.class)
public void createStreamWrongInputRpcTest() {
    payload = prepareDomPayload("create-data-change-event-subscription2", RpcDefinition::getInput, "toaster", "path2");
    final DOMRpcResult result = CreateStreamUtil.createDataChangeNotifiStream(payload, refSchemaCtx);
    assertEquals(result.getErrors(), Collections.emptyList());
}
Also used : DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) Test(org.junit.Test)

Example 30 with DOMRpcResult

use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project controller by opendaylight.

the class RemoteOpsImplementationTest method testInvokeRpcWithAkkaTimeoutException.

/**
 * This test method invokes and tests exceptions when akka timeout occured
 * Currently ignored since this test with current config takes around 15 seconds to complete.
 */
@Ignore
@Test(expected = RemoteDOMRpcException.class)
public void testInvokeRpcWithAkkaTimeoutException() throws Exception {
    final NormalizedNode invokeRpcInput = makeRPCInput("foo");
    final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
    assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
    frontEndFuture.get(20, TimeUnit.SECONDS);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)61 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)39 Test (org.junit.Test)38 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)21 QName (org.opendaylight.yangtools.yang.common.QName)18 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)16 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)10 RpcError (org.opendaylight.yangtools.yang.common.RpcError)8 ExecutionException (java.util.concurrent.ExecutionException)7 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)7 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)7 ClusteringRpcException (org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException)6 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)5 InvokeRpcMessageReply (org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply)5 DOMRpcImplementationNotAvailableException (org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException)4 NormalizedNodeContext (org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3