Search in sources :

Example 11 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class NetconfDataTreeServiceActorTest method testDelete.

@Test
public void testDelete() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(netconfService).delete(STORE, PATH);
    actorRef.tell(new DeleteEditConfigRequest(STORE, PATH), probe.ref());
    verify(netconfService).delete(STORE, PATH);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DeleteEditConfigRequest(org.opendaylight.netconf.topology.singleton.messages.netconf.DeleteEditConfigRequest) Test(org.junit.Test)

Example 12 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class NetconfDataTreeServiceActorTest method testIdleTimeout.

@Test
public void testIdleTimeout() {
    final TestProbe testProbe = new TestProbe(system);
    testProbe.watch(actorRef);
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).unlock();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).discardChanges();
    verify(netconfService, timeout(3000)).discardChanges();
    verify(netconfService, timeout(3000)).unlock();
    testProbe.expectTerminated(actorRef, TIMEOUT.duration());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) TestProbe(akka.testkit.TestProbe) Test(org.junit.Test)

Example 13 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class ActorProxyNetconfServiceFacade method createResult.

private ListenableFuture<? extends DOMRpcResult> createResult() {
    final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
    settableFuture.set(new DefaultDOMRpcResult());
    return settableFuture;
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult)

Example 14 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class FieldsAwareReadOnlyTxTest method testReadWithFields.

@Test
public void testReadWithFields() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(mockedNode))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
    try (FieldsAwareReadOnlyTx readOnlyTx = new FieldsAwareReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)))) {
        readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty(), List.of(YangInstanceIdentifier.empty()));
        verify(rpc).invokeRpc(eq(NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
        readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
        verify(rpc).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class));
    }
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) QName(org.opendaylight.yangtools.yang.common.QName) InetSocketAddress(java.net.InetSocketAddress) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 15 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class NetconfMessageTransformer method toRpcResult.

@Override
public synchronized DOMRpcResult toRpcResult(final NetconfMessage message, final QName rpc) {
    final NormalizedNode normalizedNode;
    if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpc)) {
        normalizedNode = Builders.containerBuilder().withNodeIdentifier(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_NODEID).withChild(Builders.anyXmlBuilder().withNodeIdentifier(NetconfMessageTransformUtil.NETCONF_DATA_NODEID).withValue(new DOMSource(NetconfMessageTransformUtil.getDataSubtree(message.getDocument()))).build()).build();
    } else {
        // Determine whether a base netconf operation is being invoked
        // and also check if the device exposed model for base netconf.
        // If no, use pre built base netconf operations model
        final ImmutableMap<QName, ? extends RpcDefinition> currentMappedRpcs;
        if (mappedRpcs.get(rpc) == null && isBaseOrNotificationRpc(rpc)) {
            currentMappedRpcs = baseSchema.getMappedRpcs();
        } else {
            currentMappedRpcs = mappedRpcs;
        }
        final RpcDefinition rpcDefinition = currentMappedRpcs.get(rpc);
        Preconditions.checkArgument(rpcDefinition != null, "Unable to parse response of %s, the rpc is unknown", rpc);
        // In case no input for rpc is defined, we can simply construct the payload here
        normalizedNode = parseResult(message, rpcDefinition);
    }
    return new DefaultDOMRpcResult(normalizedNode);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMSource(javax.xml.transform.dom.DOMSource) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) QName(org.opendaylight.yangtools.yang.common.QName) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)

Aggregations

DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)72 Test (org.junit.Test)51 QName (org.opendaylight.yangtools.yang.common.QName)27 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)25 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)25 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)16 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)15 NetconfRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy)15 NormalizedNodePayload (org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload)12 Before (org.junit.Before)10 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)10 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)10 NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)9 MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)9 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)5 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)5 RpcError (org.opendaylight.yangtools.yang.common.RpcError)5 ArrayList (java.util.ArrayList)4 NormalizedNodeMessage (org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage)4