use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.
the class TestXmlPatchBodyReaderMountPoint method modulePatchCompleteTargetInURITest.
/**
* Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
*/
@Test
public void modulePatchCompleteTargetInURITest() throws Exception {
final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, xmlToPatchBodyReader, false);
final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml");
final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
checkPatchContextMountPoint(returnValue);
}
use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.
the class JsonPatchBodyReaderTest method modulePatchCompleteTargetInURITest.
/**
* Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
*/
@Test
public void modulePatchCompleteTargetInURITest() throws Exception {
final String uri = "instance-identifier-patch-module:patch-cont";
mockBodyReader(uri, jsonToPatchBodyReader, false);
final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.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 modulePatchDataTest.
@Test
public void modulePatchDataTest() 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/jsonPATCHdata.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 modulePatchCreateAndDeleteTest.
/**
* Test of successful Patch consisting of create and delete Patch operations.
*/
@Test
public void modulePatchCreateAndDeleteTest() 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/jsonPATCHdataCreateAndDelete.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 PatchDataTransactionUtilTest method testPatchDataCreateAndDelete.
@Test
public void testPatchDataCreateAndDelete() {
doReturn(immediateFalseFluentFuture()).when(this.rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.instanceIdContainer);
doReturn(immediateTrueFluentFuture()).when(this.rwTransaction).exists(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(this.netconfService).create(LogicalDatastoreType.CONFIGURATION, this.instanceIdContainer, this.buildBaseContainerForTests, Optional.empty());
doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(this.netconfService).delete(LogicalDatastoreType.CONFIGURATION, this.targetNodeForCreateAndDelete);
final PatchEntity entityCreate = new PatchEntity("edit1", CREATE, this.instanceIdContainer, this.buildBaseContainerForTests);
final PatchEntity entityDelete = new PatchEntity("edit2", DELETE, this.targetNodeForCreateAndDelete);
final List<PatchEntity> entities = new ArrayList<>();
entities.add(entityCreate);
entities.add(entityDelete);
final InstanceIdentifierContext<? extends SchemaNode> iidContext = new InstanceIdentifierContext<>(this.instanceIdCreateAndDelete, null, null, this.refSchemaCtx);
final PatchContext patchContext = new PatchContext(iidContext, entities, "patchCD");
patch(patchContext, new MdsalRestconfStrategy(mockDataBroker), true);
patch(patchContext, new NetconfRestconfStrategy(netconfService), true);
}
Aggregations