Search in sources :

Example 16 with MdsalRestconfStrategy

use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy in project netconf by opendaylight.

the class PutDataTransactionUtilTest method testPutLeafData.

@Test
public void testPutLeafData() {
    final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid, schemaNode, null, schema);
    final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildLeaf);
    doReturn(readWrite).when(mockDataBroker).newReadWriteTransaction();
    doReturn(read).when(mockDataBroker).newReadOnlyTransaction();
    doReturn(immediateFalseFluentFuture()).when(read).exists(LogicalDatastoreType.CONFIGURATION, iid);
    doNothing().when(readWrite).put(LogicalDatastoreType.CONFIGURATION, iid, payload.getData());
    doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
    PutDataTransactionUtil.putData(payload, schema, new MdsalRestconfStrategy(mockDataBroker), WriteDataParams.empty());
    verify(read).exists(LogicalDatastoreType.CONFIGURATION, iid);
    verify(readWrite).put(LogicalDatastoreType.CONFIGURATION, iid, payload.getData());
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) MdsalRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy) InstanceIdentifierContext(org.opendaylight.restconf.common.context.InstanceIdentifierContext) NormalizedNodePayload(org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload) Test(org.junit.Test)

Example 17 with MdsalRestconfStrategy

use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy in project netconf by opendaylight.

the class ReadDataTransactionUtilTest method setUp.

@Before
public void setUp() {
    // FIXME: these tests need to be parameterized somehow. The trouble is we need mocking before we invoke
    // the strategy. This needs some more thought.
    doReturn(read).when(mockDataBroker).newReadOnlyTransaction();
    mdsalStrategy = new MdsalRestconfStrategy(mockDataBroker);
    netconfStrategy = new NetconfRestconfStrategy(netconfService);
}
Also used : MdsalRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy) NetconfRestconfStrategy(org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy) Before(org.junit.Before)

Aggregations

MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)17 Test (org.junit.Test)16 NetconfRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy)14 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)13 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)9 NormalizedNodePayload (org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload)9 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)6 ArrayList (java.util.ArrayList)4 PatchContext (org.opendaylight.restconf.common.patch.PatchContext)4 PatchEntity (org.opendaylight.restconf.common.patch.PatchEntity)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 Collection (java.util.Collection)2 Response (javax.ws.rs.core.Response)2 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)2 NetconfDocumentedException (org.opendaylight.netconf.api.NetconfDocumentedException)2 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)2 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)2 Before (org.junit.Before)1 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)1 RestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy)1