Search in sources :

Example 21 with DefaultDOMRpcResult

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

the class PlainPatchDataTransactionUtilTest method testPatchListData.

@Test
public void testPatchListData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iidJukebox, schemaNodeForJukebox, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, jukeboxContainerWithPlaylist);
    doReturn(readWrite).when(mockDataBroker).newReadWriteTransaction();
    doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(), any(), any());
    PlainPatchDataTransactionUtil.patchData(payload, new MdsalRestconfStrategy(mockDataBroker), schema);
    verify(readWrite).merge(LogicalDatastoreType.CONFIGURATION, iidJukebox, payload.getData());
    PlainPatchDataTransactionUtil.patchData(payload, new NetconfRestconfStrategy(netconfService), schema);
    verify(netconfService).merge(LogicalDatastoreType.CONFIGURATION, iidJukebox, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) MdsalRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 22 with DefaultDOMRpcResult

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

the class PutDataTransactionUtilTest method testPutCreateContainerData.

@Test
public void testPutCreateContainerData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid2, schemaNode2, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildBaseCont);
    doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(iid2);
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid2, payload.getData(), Optional.empty());
    PutDataTransactionUtil.putData(payload, schema, new NetconfRestconfStrategy(netconfService), WriteDataParams.empty());
    verify(netconfService).lock();
    verify(netconfService).getConfig(iid2);
    verify(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid2, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 23 with DefaultDOMRpcResult

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

the class PutDataTransactionUtilTest method testPutCreateListData.

@Test
public void testPutCreateListData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid2, schemaNode2, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildBaseContWithList);
    doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(iid2);
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid2, payload.getData(), Optional.empty());
    PutDataTransactionUtil.putData(payload, schema, new NetconfRestconfStrategy(netconfService), WriteDataParams.empty());
    verify(netconfService).getConfig(iid2);
    verify(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid2, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 24 with DefaultDOMRpcResult

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

the class PutDataTransactionUtilTest method testPutReplaceLeafData.

@Test
public void testPutReplaceLeafData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid, schemaNode, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildLeaf);
    doReturn(immediateFluentFuture(Optional.of(mock(NormalizedNode.class)))).when(netconfService).getConfig(iid);
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
    doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid, payload.getData(), Optional.empty());
    PutDataTransactionUtil.putData(payload, schema, new NetconfRestconfStrategy(netconfService), WriteDataParams.empty());
    verify(netconfService).getConfig(iid);
    verify(netconfService).replace(LogicalDatastoreType.CONFIGURATION, iid, payload.getData(), Optional.empty());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 25 with DefaultDOMRpcResult

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

the class RestconfInvokeOperationsServiceImplTest method invokeRpcTest.

@Test
public void invokeRpcTest() throws InterruptedException, ExecutionException {
    final DOMRpcResult mockResult = new DefaultDOMRpcResult(OUTPUT, List.of());
    doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(RPC, INPUT);
    final DOMRpcResult rpcResult = RestconfInvokeOperationsServiceImpl.invokeRpc(INPUT, RPC, rpcService).get();
    assertTrue(rpcResult.getErrors().isEmpty());
    assertEquals(OUTPUT, rpcResult.getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) Test(org.junit.Test)

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