From dfcc95236daf7d45687fa42446a7d236ac12637e Mon Sep 17 00:00:00 2001 From: Rudrangi Anupriya Date: Wed, 27 Nov 2024 23:49:42 +0530 Subject: XML content support on Replace list content Here to bring Support for XML Response Entity in Replace List content - Add ContentTypeInheadr in cpsData.yml to support application/xml - Add contentTypeInHeader parameter to accept xml in DataRestController.java - Modify the code return xml Data - written testcase for above changes made Issue-ID: CPS-2411 Change-Id: Ibb7ffb66ccdd03703266123c6d5c2eade0e7cb4a Signed-off-by: Rudrangi Anupriya --- .../integration/functional/cps/DataServiceIntegrationSpec.groovy | 8 ++++---- .../onap/cps/integration/performance/cps/UpdatePerfTest.groovy | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'integration-test') diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy index d49931eb7e..6c68a37f81 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/DataServiceIntegrationSpec.groovy @@ -310,9 +310,9 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { def 'Attempt to add empty lists.'() { when: 'the batches of new list element(s) are saved' - objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [ ], now) - then: 'an admin exception is thrown' - thrown(CpsAdminException) + objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [ ] as String, now, ContentType.JSON) + then: 'an data exception is thrown' + thrown(DataValidationException) } def 'Add child error scenario: #scenario.'() { @@ -344,7 +344,7 @@ class DataServiceIntegrationSpec extends FunctionalSpecBase { assert countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="2"]', DIRECT_CHILDREN_ONLY)) > 1 when: 'the categories list is replaced with just category "1" and without child nodes (books)' def json = '{"categories": [ {"code":"' +categoryCode + '"' + childJson + '} ] }' - objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now) + objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now, ContentType.JSON) then: 'the new replaced category can be retrieved but has no children anymore' assert expectedNumberOfDataNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="' +categoryCode + '"]', DIRECT_CHILDREN_ONLY)) when: 'attempt to retrieve a category (code) not in the new list' diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy index 03abdb4b3f..d764029f02 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy @@ -94,7 +94,7 @@ class UpdatePerfTest extends CpsPerfTestBase { def jsonListData = generateJsonForOpenRoadmDevices(startId, totalNodes, changeLeaves) when: 'the container node is updated' resourceMeter.start() - objectUnderTest.replaceListContent(CPS_PERFORMANCE_TEST_DATASPACE, UPDATE_TEST_ANCHOR, '/openroadm-devices', jsonListData, now) + objectUnderTest.replaceListContent(CPS_PERFORMANCE_TEST_DATASPACE, UPDATE_TEST_ANCHOR, '/openroadm-devices', jsonListData, now, ContentType.JSON) resourceMeter.stop() then: 'there are the expected number of total nodes' assert totalNodes == countDataNodes('/openroadm-devices/openroadm-device') @@ -118,7 +118,7 @@ class UpdatePerfTest extends CpsPerfTestBase { def 'Update leaves for 100 data nodes.'() { given: 'there are 200 existing data nodes' def jsonListData = generateJsonForOpenRoadmDevices(1, 200, false) - objectUnderTest.replaceListContent(CPS_PERFORMANCE_TEST_DATASPACE, UPDATE_TEST_ANCHOR, '/openroadm-devices', jsonListData, now) + objectUnderTest.replaceListContent(CPS_PERFORMANCE_TEST_DATASPACE, UPDATE_TEST_ANCHOR, '/openroadm-devices', jsonListData, now, ContentType.JSON) and: 'JSON for updated data leaves of 100 nodes' def jsonDataUpdated = "{'openroadm-device':[" + (1..100).collect {"{'device-id':'C201-7-1A-" + it + "','status':'fail','ne-state':'jeopardy'}" }.join(",") + "]}" when: 'update is performed for leaves' -- cgit 1.2.3-korg