use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.
the class RestconfDataServiceImplTest method testPatchData.
@Test
public void testPatchData() {
final InstanceIdentifierContext<? extends SchemaNode> iidContext = new InstanceIdentifierContext<>(iidBase, schemaNode, null, contextRef);
final List<PatchEntity> entity = new ArrayList<>();
final YangInstanceIdentifier iidleaf = YangInstanceIdentifier.builder(iidBase).node(containerPlayerQname).node(leafQname).build();
entity.add(new PatchEntity("create data", CREATE, iidBase, buildBaseCont));
entity.add(new PatchEntity("replace data", REPLACE, iidBase, buildBaseCont));
entity.add(new PatchEntity("delete data", DELETE, iidleaf));
final PatchContext patch = new PatchContext(iidContext, entity, "test patch id");
doNothing().when(readWrite).delete(LogicalDatastoreType.CONFIGURATION, iidleaf);
doReturn(immediateFalseFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION, iidBase);
doReturn(immediateTrueFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION, iidleaf);
final PatchStatusContext status = dataService.patchData(patch, uriInfo);
assertTrue(status.isOk());
assertEquals(3, status.getEditCollection().size());
assertEquals("replace data", status.getEditCollection().get(1).getEditId());
}
use of org.opendaylight.restconf.common.patch.PatchContext 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.common.patch.PatchContext in project netconf by opendaylight.
the class JsonPatchBodyReaderTest method modulePatchMergeOperationOnListTest.
/**
* Test of Yang Patch merge operation on list. Test consists of two edit operations - replace and merge.
*/
@Test
public void modulePatchMergeOperationOnListTest() throws Exception {
final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnList.json");
final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
checkPatchContext(returnValue);
}
use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.
the class JsonPatchBodyReaderTest method modulePatchMergeOperationOnContainerTest.
/**
* Test of Yang Patch merge operation on container. Test consists of two edit operations - create and merge.
*/
@Test
public void modulePatchMergeOperationOnContainerTest() throws Exception {
final String uri = "instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json");
final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
checkPatchContext(returnValue);
}
use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.
the class JsonPatchBodyReaderTest method modulePatchSimpleLeafValueTest.
/**
* Test reading simple leaf value.
*/
@Test
public void modulePatchSimpleLeafValueTest() throws Exception {
final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHSimpleLeafValue.json");
final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
checkPatchContext(returnValue);
}
Aggregations