Search in sources :

Example 6 with DOMRpcImplementationNotAvailableException

use of org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException 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 7 with DOMRpcImplementationNotAvailableException

use of org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException 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)

Example 8 with DOMRpcImplementationNotAvailableException

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

the class InvokeRpcMethodTest method testInvokeRpcWithNoPayloadRpc_FailNoErrors.

@Test
public void testInvokeRpcWithNoPayloadRpc_FailNoErrors() {
    final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast");
    doReturn(immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("testExeption"))).when(brokerFacade).invokeRpc(eq(qname), any());
    final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class, () -> this.restconfImpl.invokeRpc("toaster:cancel-toast", null, uriInfo));
    verifyRestconfDocumentedException(ex, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED, Optional.empty(), Optional.empty());
}
Also used : RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) QName(org.opendaylight.yangtools.yang.common.QName) DOMRpcImplementationNotAvailableException(org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException) Test(org.junit.Test)

Aggregations

DOMRpcImplementationNotAvailableException (org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException)8 Test (org.junit.Test)4 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)4 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)4 QName (org.opendaylight.yangtools.yang.common.QName)4 DOMRpcException (org.opendaylight.mdsal.dom.api.DOMRpcException)3 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)2 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 Failure (akka.actor.Status.Failure)1 Collections2 (com.google.common.collect.Collections2)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collection (java.util.Collection)1 Set (java.util.Set)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ExecuteRpc (org.opendaylight.controller.remote.rpc.messages.ExecuteRpc)1 RpcProviderService (org.opendaylight.mdsal.binding.api.RpcProviderService)1 DOMRpcIdentifier (org.opendaylight.mdsal.dom.api.DOMRpcIdentifier)1