summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2024-07-10 14:46:46 +0100
committerPriyank Maheshwari <priyank.maheshwari@est.tech>2024-07-15 11:49:33 +0000
commit76676aa6d9b4a1336b8d1f392296995bcdde3439 (patch)
tree2b47b6ab9328c3ab9f6c3f13b16cb049b3d13c7e /cps-ncmp-service/src/test/groovy
parent964c5f68ab2b70074fc22de01e9229d1f5ee7a3d (diff)
Mapper to group Subscription Details for DMI
- introduced a mapper to group a collection of subscription keys(datastore cmhandle and xpath ) based on datastore and xpath - the information will be used to send out to the dmi plugin Issue-ID: CPS-2312 Change-Id: I99f509eb5b4a8c3a7fb1078ae86490d894f22b6c Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiCmSubscriptionDetailsPerDmiMapperSpec.groovy52
1 files changed, 52 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiCmSubscriptionDetailsPerDmiMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiCmSubscriptionDetailsPerDmiMapperSpec.groovy
new file mode 100644
index 0000000000..5d74f45bb9
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiCmSubscriptionDetailsPerDmiMapperSpec.groovy
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi
+
+import org.onap.cps.ncmp.impl.cmnotificationsubscription.models.DmiCmSubscriptionKey
+import spock.lang.Specification
+
+class DmiCmSubscriptionDetailsPerDmiMapperSpec extends Specification {
+
+ def objectUnderTest = new DmiCmSubscriptionDetailsPerDmiMapper()
+
+ def 'Check for grouping of Dmi Subscription Details'() {
+ given: 'details in the form of datastore , cmhandle and xpath'
+ def subscribersPerDmi = [
+ 'dmi-1': [
+ new DmiCmSubscriptionKey('ncmp-datastore:passthrough-operational', 'ch-1', '/a/b'),
+ new DmiCmSubscriptionKey('ncmp-datastore:passthrough-operational', 'ch-2', '/a/b')
+ ],
+ 'dmi-2': [
+ new DmiCmSubscriptionKey('ncmp-datastore:passthrough-running', 'ch-3', '/c/d'),
+ new DmiCmSubscriptionKey('ncmp-datastore:passthrough-running', 'ch-3', '/e/f')
+ ]
+ ]
+ when: 'we try to map the values based on datastore and xpath'
+ def result = objectUnderTest.toDmiCmSubscriptionsPerDmi(subscribersPerDmi)
+ then: 'the mapped values are grouped as expected for dmi-1'
+ assert result['dmi-1'].dmiCmSubscriptionPredicates.size() == 1
+ assert result['dmi-1'].dmiCmSubscriptionPredicates[0].targetCmHandleIds.containsAll(['ch-1', 'ch-2'])
+ and: 'similarly for dmi-2'
+ assert result['dmi-2'].dmiCmSubscriptionPredicates.size() == 2
+ assert result['dmi-2'].dmiCmSubscriptionPredicates[0].targetCmHandleIds.contains('ch-3')
+ assert result['dmi-2'].dmiCmSubscriptionPredicates[1].targetCmHandleIds.contains('ch-3')
+ }
+}