Search in sources :

Example 11 with PatchContext

use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.

the class TestJsonPatchBodyReaderMountPoint method modulePatchDataTest.

@Test
public void modulePatchDataTest() throws Exception {
    final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json");
    final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
    checkPatchContextMountPoint(returnValue);
}
Also used : PatchContext(org.opendaylight.restconf.common.patch.PatchContext) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 12 with PatchContext

use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.

the class TestJsonPatchBodyReaderMountPoint 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, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json");
    final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
    checkPatchContextMountPoint(returnValue);
}
Also used : PatchContext(org.opendaylight.restconf.common.patch.PatchContext) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 13 with PatchContext

use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.

the class TestJsonPatchBodyReaderMountPoint method modulePatchCreateAndDeleteTest.

/**
 * Test of successful Patch consisting of create and delete Patch operations.
 */
@Test
public void modulePatchCreateAndDeleteTest() throws Exception {
    final String uri = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json");
    final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
    checkPatchContextMountPoint(returnValue);
}
Also used : PatchContext(org.opendaylight.restconf.common.patch.PatchContext) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 14 with PatchContext

use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.

the class TestJsonPatchBodyReaderMountPoint 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 = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont/my-list1/leaf1";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnList.json");
    final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
    checkPatchContextMountPoint(returnValue);
}
Also used : PatchContext(org.opendaylight.restconf.common.patch.PatchContext) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 15 with PatchContext

use of org.opendaylight.restconf.common.patch.PatchContext in project netconf by opendaylight.

the class TestJsonPatchBodyReaderMountPoint 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 = MOUNT_POINT + "/instance-identifier-patch-module:patch-cont";
    mockBodyReader(uri, jsonToPatchBodyReader, false);
    final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json");
    final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
    checkPatchContextMountPoint(returnValue);
}
Also used : PatchContext(org.opendaylight.restconf.common.patch.PatchContext) InputStream(java.io.InputStream) Test(org.junit.Test)

Aggregations

PatchContext (org.opendaylight.restconf.common.patch.PatchContext)42 Test (org.junit.Test)36 InputStream (java.io.InputStream)31 PatchEntity (org.opendaylight.restconf.common.patch.PatchEntity)11 ArrayList (java.util.ArrayList)9 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)9 PatchStatusContext (org.opendaylight.restconf.common.patch.PatchStatusContext)7 AbstractBodyReaderTest (org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest)7 JsonBodyReaderTest (org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest)6 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)5 IOException (java.io.IOException)4 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)4 MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)4 NetconfRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy)4 URISyntaxException (java.net.URISyntaxException)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)3 Verify.verify (com.google.common.base.Verify.verify)2