From 76676aa6d9b4a1336b8d1f392296995bcdde3439 Mon Sep 17 00:00:00 2001 From: mpriyank Date: Wed, 10 Jul 2024 14:46:46 +0100 Subject: 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 --- ...DmiCmSubscriptionDetailsPerDmiMapperSpec.groovy | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/dmi/DmiCmSubscriptionDetailsPerDmiMapperSpec.groovy (limited to 'cps-ncmp-service/src/test') 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') + } +} -- cgit 1.2.3-korg