diff options
author | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2024-06-05 23:55:14 +0530 |
---|---|---|
committer | Rudrangi Anupriya <ra00745022@techmahindra.com> | 2024-06-05 23:55:31 +0530 |
commit | 1decb39aa016bdfc7ac870aec738c9c08484c32f (patch) | |
tree | a7d8ddf33a5a57564dd4d37f04644cb997b8f0c7 /cps-service/src/test | |
parent | cfc5f94a00ad352ef44cc745e358f52fc914b3e9 (diff) |
XML content support on update node leaves
Issue-ID: CPS-2071
Change-Id: Ibe7f59fbfcbb03703626132c6d5c2afde0e7ab4b
Signed-off-by: Rudrangi Anupriya <ra00745022@techmahindra.com>
Diffstat (limited to 'cps-service/src/test')
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy index fcbfd0561a..4542ecb673 100644 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy @@ -233,30 +233,32 @@ class CpsDataServiceImplSpec extends Specification { def 'Update data node leaves: #scenario.'() { given: 'schema set for given anchor and dataspace references test-tree model' setupSchemaSetMocks('test-tree.yang') - when: 'update data method is invoked with json data #jsonData and parent node xpath #parentNodeXpath' - objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, jsonData, observedTimestamp) + when: 'update data method is invoked with node data #nodeData and parent node xpath #parentNodeXpath' + objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, nodeData, observedTimestamp, contentType) then: 'the persistence service method is invoked with correct parameters' 1 * mockCpsDataPersistenceService.batchUpdateDataLeaves(dataspaceName, anchorName, {dataNode -> dataNode.keySet()[0] == expectedNodeXpath}) and: 'the CpsValidator is called on the dataspaceName and AnchorName' 1 * mockCpsValidator.validateNameCharacters(dataspaceName, anchorName) where: 'following parameters were used' - scenario | parentNodeXpath | jsonData || expectedNodeXpath - 'top level node' | '/' | '{"test-tree": {"branch": []}}' || '/test-tree' - 'level 2 node' | '/test-tree' | '{"branch": [{"name":"Name"}]}' || '/test-tree/branch[@name=\'Name\']' + scenario | parentNodeXpath | nodeData || expectedNodeXpath | contentType + 'JSON content: top level node' | '/' | '{"test-tree": {"branch": []}}' || '/test-tree' | ContentType.JSON + 'JSON content: level 2 node' | '/test-tree' | '{"branch": [{"name":"Name"}]}' || '/test-tree/branch[@name=\'Name\']' | ContentType.JSON + 'XML content: level 2 node' | '/test-tree' | '<branch><name>Name</name></branch>' || '/test-tree/branch[@name=\'Name\']' | ContentType.XML } def 'Update list-element data node with : #scenario.'() { given: 'schema set for given anchor and dataspace references bookstore model' setupSchemaSetMocks('bookstore.yang') - when: 'update data method is invoked with json data #jsonData and parent node xpath' + when: 'update data method is invoked with node data #nodeData and parent node xpath' objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, '/bookstore/categories[@code=2]', - jsonData, observedTimestamp) + nodeData, observedTimestamp, contentType) then: 'the persistence service method is invoked with correct parameters' thrown(DataValidationException) where: 'following parameters were used' - scenario | jsonData - 'multiple expectedLeaves' | '{"code": "01","name": "some-name"}' - 'one leaf' | '{"name": "some-name"}' + scenario || nodeData | contentType + 'JSON content: multiple expectedLeaves' || '{"code": "03","name": "some-name"}' | ContentType.JSON + 'JSON content: one leaf' || '{"name": "some-name"}' | ContentType.JSON + 'XML content: multiple expectedLeaves' || '<code>1</code><name>some-name</name>' | ContentType.XML } def 'Update data nodes in different containers.' () { @@ -266,7 +268,7 @@ class CpsDataServiceImplSpec extends Specification { def parentNodeXpath = '/' def updatedJsonData = '{"first-container":{"a-leaf":"a-new-Value"},"last-container":{"x-leaf":"x-new-value"}}' when: 'update operation is performed on multiple data nodes' - objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, updatedJsonData, observedTimestamp) + objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, updatedJsonData, observedTimestamp, ContentType.JSON) then: 'the persistence service method is invoked with correct parameters' 1 * mockCpsDataPersistenceService.batchUpdateDataLeaves(dataspaceName, anchorName, {dataNode -> dataNode.keySet()[index] == expectedNodeXpath}) and: 'the CpsValidator is called on the dataspaceName and AnchorName' @@ -486,7 +488,7 @@ class CpsDataServiceImplSpec extends Specification { when: 'publisher set to throw an exception' mockDataUpdateEventsService.publishCpsDataUpdateEvent(_, _, _, _) >> { throw new Exception("publishing failed")} and: 'an update event is performed' - objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, '/', '{"test-tree": {"branch": []}}', observedTimestamp) + objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, '/', '{"test-tree": {"branch": []}}', observedTimestamp, ContentType.JSON) then: 'the exception is not bubbled up' noExceptionThrown() and: "the exception message is logged" |