diff options
author | tragait <rahul.tyagi@est.tech> | 2021-10-04 16:02:57 +0100 |
---|---|---|
committer | tragait <rahul.tyagi@est.tech> | 2021-10-06 15:21:12 +0100 |
commit | 907e3785a7cbaba28f5d4bf7ce3c4a7b47dff39e (patch) | |
tree | f726e5dcdd5e485dc3e840cb850504bc7c5df78e /src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy | |
parent | 9ee0feb24f8f75ce05cf9e34e4621cf2b226657e (diff) |
fix query param to options
Issue-ID: CPS-678
Signed-off-by: tragait <rahul.tyagi@est.tech>
Change-Id: I4ac72da512e2c7883920907137b8834ce20d4528
Diffstat (limited to 'src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy')
-rw-r--r-- | src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy index 95a9c0a7..4411971a 100644 --- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy +++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy @@ -61,10 +61,10 @@ class SdncOperationsSpec extends Specification { def 'Get resource data from node to SDNC.'() { given: 'expected url, topology-id, sdncOperation object' - def expectedUrl = '/rests/data/network-topology:network-topology/topology=test-topology/node=node1/yang-ext:mount/testResourceId?fields=testFields&depth=10&content=testContent' + def expectedUrl = '/rests/data/network-topology:network-topology/topology=test-topology/node=node1/yang-ext:mount/testResourceId?a=1&b=2&content=testContent' when: 'called get modules from node' objectUnderTest.getResouceDataForOperationalAndRunning('node1', 'testResourceId', - 'testFields', 10, 'testAcceptParam', 'content=testContent') + '(a=1,b=2)', 'testAcceptParam', 'content=testContent') then: 'the get operation is executed with the correct URL' 1 * mockSdncRestClient.getOperation(expectedUrl, _ as HttpHeaders) } @@ -77,4 +77,33 @@ class SdncOperationsSpec extends Specification { then: 'the post operation is executed with the correct URL and data' 1 * mockSdncRestClient.postOperationWithJsonData(expectedUrl, 'requestData', _ as HttpHeaders) } + + def 'build query param list for SDNC where options contains a #scenario'() { + when: 'build query param list is called with #scenario' + def result = objectUnderTest.buildQueryParamList(optionsParamInQuery,'d=4') + then: 'result equals to expected result' + result == expectedResult + where: 'following parameters are used' + scenario | optionsParamInQuery || expectedResult + 'single key-value pair' | '(a=x)' || ['a=x','d=4'] + 'multiple key-value pairs'| '(a=x,b=y,c=z)' || ['a=x','b=y','c=z','d=4'] + '/ as special char' | '(a=x,b=y,c=t/z)' || ['a=x','b=y','c=t/z','d=4'] + '" as special char' | '(a=x,b=y,c="z")' || ['a=x','b=y','c="z"','d=4'] + '[] as special char' | '(a=x,b=y,c=[z])' || ['a=x','b=y','c=[z]','d=4'] + '= in value' | '(a=(x=y),b=x=y)' || ['a=(x=y)','b=x=y','d=4'] + } + + def 'options parameters contains a comma #scenario'() { + // https://jira.onap.org/browse/CPS-719 + when: 'build query param list is called with #scenario' + def result = objectUnderTest.buildQueryParamList(optionsParamInQuery,'d=4') + then: 'expect 2 elements from options +1 from content query param (2+1) = 3 elements' + def expectedNoOfElements = 3 + and: 'results contains more elements than expected' + result.size() > expectedNoOfElements + where: 'following parameters are used' + scenario | optionsParamInQuery + '"," in value' | '(a=(x,y),b=y)' + '"," in string value' | '(a="x,y",b=y)' + } } |