use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy 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());
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class DeleteDataTransactionUtilTest method deleteDataNegativeTest.
/**
* Negative test for DELETE operation when data to delete does not exist. Error DATA_MISSING is expected.
*/
@Test
public void deleteDataNegativeTest() {
// assert that data to delete does NOT exist
when(readWrite.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())).thenReturn(immediateFalseFluentFuture());
final NetconfDocumentedException exception = new NetconfDocumentedException("id", ErrorType.RPC, ErrorTag.DATA_MISSING, ErrorSeverity.ERROR);
final SettableFuture<? extends CommitInfo> ret = SettableFuture.create();
ret.setException(new TransactionCommitFailedException(String.format("Commit of transaction %s failed", this), exception));
doReturn(ret).when(this.netconfService).commit();
// test and assert error
deleteFail(new MdsalRestconfStrategy(mockDataBroker));
deleteFail(new NetconfRestconfStrategy(netconfService));
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class DeleteDataTransactionUtilTest method deleteData.
/**
* Test of successful DELETE operation.
*/
@Test
public void deleteData() {
// assert that data to delete exists
when(readWrite.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())).thenReturn(immediateTrueFluentFuture());
// test
delete(new MdsalRestconfStrategy(mockDataBroker));
delete(new NetconfRestconfStrategy(netconfService));
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class PatchDataTransactionUtilTest method testPatchMergePutContainer.
@Test
public void testPatchMergePutContainer() {
final PatchEntity entityMerge = new PatchEntity("edit1", MERGE, this.instanceIdContainer, this.buildBaseContainerForTests);
final List<PatchEntity> entities = new ArrayList<>();
entities.add(entityMerge);
final InstanceIdentifierContext<? extends SchemaNode> iidContext = new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx);
final PatchContext patchContext = new PatchContext(iidContext, entities, "patchM");
patch(patchContext, new MdsalRestconfStrategy(mockDataBroker), false);
patch(patchContext, new NetconfRestconfStrategy(netconfService), false);
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class PutDataTransactionUtilTest method testPutCreateLeafData.
@Test
public void testPutCreateLeafData() {
final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid, schemaNode, null, schema);
final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildLeaf);
doReturn(immediateFluentFuture(Optional.empty())).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());
}
Aggregations