X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2Futils%2FDataNodeHelperSpec.groovy;h=819f1fa08ecaf6c59283c471dae7add72cc4a327;hb=9965f958530e0341b109a7df20c88103bdd83862;hp=e527ae12bb2dd14f08ec15671ea45182a38f370a;hpb=6da07ba45c3eaae70fcb124e598445cb9fa3a30a;p=cps.git diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataNodeHelperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataNodeHelperSpec.groovy index e527ae12b..819f1fa08 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataNodeHelperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataNodeHelperSpec.groovy @@ -20,6 +20,7 @@ package org.onap.cps.ncmp.api.impl.utils +import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus import org.onap.cps.spi.model.DataNodeBuilder class DataNodeHelperSpec extends DataNodeBaseSpec { @@ -51,8 +52,35 @@ class DataNodeHelperSpec extends DataNodeBaseSpec { and: 'the nested data node is flatten and retrieves the leaves ' def leaves = DataNodeHelper.getDataNodeLeaves([dataNode]) when:'cm handle id to status is retrieved' - def result = DataNodeHelper.getCmHandleIdToStatus(leaves); + def result = DataNodeHelper.getCmHandleIdToStatus(leaves) then: 'the result list size is 3' result.size() == 3 + and: 'the result contains expected values' + result[0] as List == ['PENDING', 'CMHandle3'] + result[1] as List == ['ACCEPTED', 'CMHandle2'] + result[2] as List == ['REJECTED', 'CMHandle1'] + } + + def 'Get cm handle id to status map as expected from list of collection' () { + given: 'a list of collection' + def cmHandleCollection = [['PENDING', 'CMHandle3'], ['ACCEPTED', 'CMHandle2'], ['REJECTED', 'CMHandle1']] + when: 'the map is formed up with a method call' + def result = DataNodeHelper.getCmHandleIdToStatusMap(cmHandleCollection) + then: 'the map values are as expected' + result.keySet() == ['CMHandle3', 'CMHandle2', 'CMHandle1'] as Set + result.values() as List == [SubscriptionStatus.PENDING, SubscriptionStatus.ACCEPTED, SubscriptionStatus.REJECTED] + } + + + def 'Get cm handle id to status map as expected from a nested data node.'() { + given: 'a nested data node' + def dataNode = new DataNodeBuilder().withDataspace('NCMP-Admin') + .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription') + .withLeaves([clientID:'SCO-9989752', isTagged:false, subscriptionName:'cm-subscription-001']) + .withChildDataNodes([dataNode4]).build() + when:'cm handle id to status is being extracted' + def result = DataNodeHelper.getCmHandleIdToStatusMapFromDataNodes([dataNode]); + then: 'the keys are retrieved as expected' + result.keySet() == ['CMHandle3','CMHandle2','CMHandle1'] as Set } }