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