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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations