Search in sources :

Example 6 with DOMActionResult

use of org.opendaylight.mdsal.dom.api.DOMActionResult in project mdsal by opendaylight.

the class DOMRpcRouterTest method assertAvailable.

private static void assertAvailable(final DOMActionService actionService, final YangInstanceIdentifier path) {
    final DOMActionResult result;
    try {
        result = Futures.getDone(invokeBaz(actionService, path));
    } catch (ExecutionException e) {
        throw new AssertionError("Unexpected invocation failure", e);
    }
    assertEquals(List.of(), result.getErrors());
}
Also used : DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) SimpleDOMActionResult(org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 7 with DOMActionResult

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

the class NetconfMessageTransformerTest method toActionEmptyBodyWithoutOutputDefinedResultTest.

@Test
public void toActionEmptyBodyWithoutOutputDefinedResultTest() throws Exception {
    NetconfMessage message = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<ok/>" + "</rpc-reply>"));
    DOMActionResult actionResult = actionNetconfMessageTransformer.toActionResult(CHECK_WITHOUT_OUTPUT_INTERFACE_PATH, message);
    assertNotNull(actionResult);
    assertTrue(actionResult.getOutput().isEmpty());
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) AbstractBaseSchemasTest(org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest) Test(org.junit.Test)

Example 8 with DOMActionResult

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

the class RemoteOpsImplementationTest method testInvokeActionWithRemoteFailedFuture.

/**
 * This test method invokes and executes the remote rpc.
 */
@SuppressWarnings({ "checkstyle:AvoidHidingCauseException", "checkstyle:IllegalThrows" })
@Test(expected = DOMActionException.class)
public void testInvokeActionWithRemoteFailedFuture() throws Throwable {
    final ContainerNode invokeActionInput = makeRPCInput("foo");
    @SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<ContainerNode> inputCaptor = ArgumentCaptor.forClass(ContainerNode.class);
    when(domActionService2.invokeAction(eq(TEST_RPC_TYPE), eq(TEST_DATA_TREE_ID), inputCaptor.capture())).thenReturn(FluentFutures.immediateFailedFluentFuture(new RemoteDOMRpcException("Test Exception", null)));
    final ListenableFuture<DOMActionResult> frontEndFuture = remoteActionImpl1.invokeAction(TEST_RPC_TYPE, TEST_DATA_TREE_ID, invokeActionInput);
    assertTrue(frontEndFuture instanceof RemoteDOMActionFuture);
    try {
        frontEndFuture.get(5, TimeUnit.SECONDS);
    } catch (ExecutionException e) {
        throw e.getCause();
    }
}
Also used : ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) SimpleDOMActionResult(org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 9 with DOMActionResult

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

the class NetconfMessageTransformerTest method toActionResultTest.

@Test
public void toActionResultTest() throws Exception {
    NetconfMessage message = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<reset-finished-at xmlns=\"urn:example:server-farm\">" + "now" + "</reset-finished-at>" + "</rpc-reply>"));
    DOMActionResult actionResult = actionNetconfMessageTransformer.toActionResult(RESET_SERVER_PATH, message);
    assertNotNull(actionResult);
    ContainerNode containerNode = actionResult.getOutput().get();
    assertNotNull(containerNode);
    assertEquals("now", containerNode.body().iterator().next().body());
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) AbstractBaseSchemasTest(org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest) Test(org.junit.Test)

Example 10 with DOMActionResult

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

the class NetconfMessageTransformerTest method toActionEmptyBodyWithOutputDefinedResultTest.

@Test
public void toActionEmptyBodyWithOutputDefinedResultTest() throws Exception {
    NetconfMessage message = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<ok/>" + "</rpc-reply>"));
    DOMActionResult actionResult = actionNetconfMessageTransformer.toActionResult(CHECK_WITH_OUTPUT_INTERFACE_PATH, message);
    assertNotNull(actionResult);
    assertTrue(actionResult.getOutput().isEmpty());
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) AbstractBaseSchemasTest(org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest) Test(org.junit.Test)

Aggregations

DOMActionResult (org.opendaylight.mdsal.dom.api.DOMActionResult)14 SimpleDOMActionResult (org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult)9 Test (org.junit.Test)8 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)7 ExecutionException (java.util.concurrent.ExecutionException)6 Absolute (org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute)5 DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)4 DOMActionService (org.opendaylight.mdsal.dom.api.DOMActionService)3 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)3 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)3 RpcError (org.opendaylight.yangtools.yang.common.RpcError)3 Futures (com.google.common.util.concurrent.Futures)2 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)2 Collection (java.util.Collection)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)2 DOMActionException (org.opendaylight.mdsal.dom.api.DOMActionException)2 ClusteringActionException (org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringActionException)2 QName (org.opendaylight.yangtools.yang.common.QName)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2