use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class PutDataTransactionUtilTest method testPutReplaceListData.
@Test
public void testPutReplaceListData() {
final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iid2, schemaNode2, null, schema);
final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, buildBaseContWithList);
doReturn(immediateFluentFuture(Optional.of(mock(NormalizedNode.class)))).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());
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class RestconfDataServiceImplTest method testGetRestconfStrategy.
@Test
public void testGetRestconfStrategy() {
RestconfStrategy restconfStrategy = dataService.getRestconfStrategy(mountPoint);
assertTrue(restconfStrategy instanceof MdsalRestconfStrategy);
doReturn(Optional.of(netconfService)).when(mountPoint).getService(NetconfDataTreeService.class);
restconfStrategy = dataService.getRestconfStrategy(mountPoint);
assertTrue(restconfStrategy instanceof NetconfRestconfStrategy);
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class PatchDataTransactionUtilTest method testPatchDataReplaceMergeAndRemove.
@Test
public void testPatchDataReplaceMergeAndRemove() {
final PatchEntity entityReplace = new PatchEntity("edit1", REPLACE, this.targetNodeMerge, this.buildArtistList);
final PatchEntity entityMerge = new PatchEntity("edit2", MERGE, this.targetNodeMerge, this.buildArtistList);
final PatchEntity entityRemove = new PatchEntity("edit3", REMOVE, this.targetNodeMerge);
final List<PatchEntity> entities = new ArrayList<>();
entities.add(entityReplace);
entities.add(entityMerge);
entities.add(entityRemove);
final InstanceIdentifierContext<? extends SchemaNode> iidContext = new InstanceIdentifierContext<>(this.instanceIdMerge, null, null, this.refSchemaCtx);
final PatchContext patchContext = new PatchContext(iidContext, entities, "patchRMRm");
doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(this.netconfService).remove(LogicalDatastoreType.CONFIGURATION, targetNodeMerge);
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 PlainPatchDataTransactionUtilTest method testPatchContainerData.
@Test
public void testPatchContainerData() {
final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iidJukebox, schemaNodeForJukebox, null, schema);
final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, jukeboxContainerWithPlayer);
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, payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
PlainPatchDataTransactionUtil.patchData(payload, new NetconfRestconfStrategy(netconfService), schema);
verify(netconfService).merge(LogicalDatastoreType.CONFIGURATION, payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData(), Optional.empty());
}
use of org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy in project netconf by opendaylight.
the class PlainPatchDataTransactionUtilTest method testPatchLeafData.
@Test
public void testPatchLeafData() {
final InstanceIdentifierContext<DataSchemaNode> iidContext = new InstanceIdentifierContext<>(iidGap, schemaNodeForGap, null, schema);
final NormalizedNodePayload payload = NormalizedNodePayload.of(iidContext, leafGap);
doReturn(readWrite).when(mockDataBroker).newReadWriteTransaction();
doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(), any(), any());
doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
PlainPatchDataTransactionUtil.patchData(payload, new MdsalRestconfStrategy(mockDataBroker), schema);
verify(readWrite).merge(LogicalDatastoreType.CONFIGURATION, payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData());
PlainPatchDataTransactionUtil.patchData(payload, new NetconfRestconfStrategy(netconfService), schema);
verify(netconfService).lock();
verify(netconfService).merge(LogicalDatastoreType.CONFIGURATION, payload.getInstanceIdentifierContext().getInstanceIdentifier(), payload.getData(), Optional.empty());
}
Aggregations