Search in sources :

Example 1 with DOMRpcException

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

the class OpsBrokerTest method testExecuteRpcFailureWithException.

@Test
public void testExecuteRpcFailureWithException() {
    when(domRpcService1.invokeRpc(eq(TEST_RPC), any())).thenReturn(FluentFutures.immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("NOT FOUND")));
    final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
    rpcInvoker1.tell(executeMsg, rpcRegistry1Probe.getRef());
    final Failure rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), Failure.class);
    assertTrue(rpcResponse.cause() instanceof DOMRpcException);
}
Also used : DOMRpcImplementationNotAvailableException(org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException) ExecuteRpc(org.opendaylight.controller.remote.rpc.messages.ExecuteRpc) DOMRpcException(org.opendaylight.mdsal.dom.api.DOMRpcException) Failure(akka.actor.Status.Failure) Test(org.junit.Test)

Example 2 with DOMRpcException

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

the class JSONRestconfServiceImplTest method testInvokeRpcFailure.

@Test(expected = OperationFailedException.class)
public void testInvokeRpcFailure() throws Exception {
    final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption");
    doReturn(immediateFailedFluentFuture(exception)).when(brokerFacade).invokeRpc(any(QName.class), any(NormalizedNode.class));
    final String uriPath = "toaster:cancel-toast";
    this.service.invokeRpc(uriPath, Optional.empty());
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) DOMRpcImplementationNotAvailableException(org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DOMRpcException(org.opendaylight.mdsal.dom.api.DOMRpcException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 3 with DOMRpcException

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

the class RestconfInvokeOperationsServiceImplTest method invokeRpcErrorsAndCheckTestTest.

@Test
public void invokeRpcErrorsAndCheckTestTest() throws InterruptedException, ExecutionException {
    final QName errorRpc = QName.create(RPC, "error-rpc");
    final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("No implementation of RPC " + errorRpc + " available.");
    doReturn(immediateFailedFluentFuture(exception)).when(rpcService).invokeRpc(errorRpc, INPUT);
    final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, errorRpc, rpcService).get();
    assertNull(rpcResult.getResult());
    final Collection<? extends RpcError> errorList = rpcResult.getErrors();
    assertEquals(1, errorList.size());
    final RpcError actual = errorList.iterator().next();
    assertEquals("No implementation of RPC " + errorRpc + " available.", actual.getMessage());
    assertEquals("operation-failed", actual.getTag());
    assertEquals(RpcError.ErrorType.RPC, actual.getErrorType());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) QName(org.opendaylight.yangtools.yang.common.QName) DOMRpcImplementationNotAvailableException(org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException) RpcError(org.opendaylight.yangtools.yang.common.RpcError) DOMRpcException(org.opendaylight.mdsal.dom.api.DOMRpcException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 DOMRpcException (org.opendaylight.mdsal.dom.api.DOMRpcException)3 DOMRpcImplementationNotAvailableException (org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException)3 QName (org.opendaylight.yangtools.yang.common.QName)2 Failure (akka.actor.Status.Failure)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ExecuteRpc (org.opendaylight.controller.remote.rpc.messages.ExecuteRpc)1 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)1 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1