summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2024-01-12 11:12:13 +0000
committermpriyank <priyank.maheshwari@est.tech>2024-01-17 15:36:12 +0000
commit58d3763eb70a1f857f1b434965037c9d4916c4a2 (patch)
tree11344534fff99eb5c58c5004689201ebae7facb1 /cps-ncmp-service/src/test/groovy
parent2dce7ab2fd627450550666e3993e28e10f6a8548 (diff)
Remove deprecated cmSubscription code
- Newer approach for cm subscription is in progress so removing the deprecated code now - Also deleted the old cache config - Changes to trust level csit to fix the kafka unknown partition issue Issue-ID: CPS-2028 Change-Id: Ieb19669e53f3f64cca876fa67d0b6409a97b2a09 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/api/impl/config/embeddedcache/ForwardedSubscriptionEventCacheConfigSpec.groovy77
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy99
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy60
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy140
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy60
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy89
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy106
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy209
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy78
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy128
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapperSpec.groovy67
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy85
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy83
13 files changed, 0 insertions, 1281 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/ForwardedSubscriptionEventCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/ForwardedSubscriptionEventCacheConfigSpec.groovy
deleted file mode 100644
index 879525e572..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/ForwardedSubscriptionEventCacheConfigSpec.groovy
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023 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.api.impl.config.embeddedcache
-
-import com.hazelcast.config.Config
-import com.hazelcast.core.Hazelcast
-import com.hazelcast.map.IMap
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-@SpringBootTest(classes = [ForwardedSubscriptionEventCacheConfig])
-class ForwardedSubscriptionEventCacheConfigSpec extends Specification {
-
- @Autowired
- private IMap<String, Set<String>> forwardedSubscriptionEventCache
-
- def 'Embedded (hazelcast) cache for Forwarded Subscription Event Cache.'() {
- expect: 'system is able to create an instance of the Forwarded Subscription Event Cache'
- assert null != forwardedSubscriptionEventCache
- and: 'there is at least 1 instance'
- assert Hazelcast.allHazelcastInstances.size() > 0
- and: 'Forwarded Subscription Event Cache is present'
- assert Hazelcast.allHazelcastInstances.name.contains('hazelCastInstanceSubscriptionEvents')
- }
-
- def 'Verify configs for Distributed Caches'(){
- given: 'the Forwarded Subscription Event Cache config'
- def forwardedSubscriptionEventCacheConfig = Hazelcast.getHazelcastInstanceByName('hazelCastInstanceSubscriptionEvents').config
- def forwardedSubscriptionEventCacheMapConfig = forwardedSubscriptionEventCacheConfig.mapConfigs.get('forwardedSubscriptionEventCacheMapConfig')
- expect: 'system created instance with correct config'
- assert forwardedSubscriptionEventCacheConfig.clusterName == 'cps-and-ncmp-test-caches'
- assert forwardedSubscriptionEventCacheMapConfig.backupCount == 3
- assert forwardedSubscriptionEventCacheMapConfig.asyncBackupCount == 3
- }
-
- def 'Verify deployment network configs for Distributed Caches'() {
- given: 'the Forwarded Subscription Event Cache config'
- def forwardedSubscriptionEventCacheNetworkConfig = Hazelcast.getHazelcastInstanceByName('hazelCastInstanceSubscriptionEvents').config.networkConfig
- expect: 'system created instance with correct config'
- assert forwardedSubscriptionEventCacheNetworkConfig.join.autoDetectionConfig.enabled
- assert !forwardedSubscriptionEventCacheNetworkConfig.join.kubernetesConfig.enabled
- }
-
- def 'Verify network config'() {
- given: 'Synchronization config object and test configuration'
- def objectUnderTest = new ForwardedSubscriptionEventCacheConfig()
- def testConfig = new Config()
- when: 'kubernetes properties are enabled'
- objectUnderTest.cacheKubernetesEnabled = true
- objectUnderTest.cacheKubernetesServiceName = 'test-service-name'
- and: 'method called to update the discovery mode'
- objectUnderTest.updateDiscoveryMode(testConfig)
- then: 'applied properties are reflected'
- assert testConfig.networkConfig.join.kubernetesConfig.enabled
- assert testConfig.networkConfig.join.kubernetesConfig.properties.get('service-name') == 'test-service-name'
-
- }
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy
deleted file mode 100644
index da1a122359..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023 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.api.impl.deprecated.subscriptions
-
-import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
-import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NO_TIMESTAMP
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.api.CpsDataService
-import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent
-import org.onap.cps.spi.model.DataNodeBuilder
-import org.onap.cps.utils.JsonObjectMapper
-import org.onap.cps.api.CpsModuleService
-import org.onap.cps.spi.utils.CpsValidator
-import spock.lang.Specification
-
-class SubscriptionPersistenceSpec extends Specification {
-
- private static final String SUBSCRIPTION_ANCHOR_NAME = "AVC-Subscriptions";
- private static final String SUBSCRIPTION_REGISTRY_PARENT = "/subscription-registry";
- private static final String SUBSCRIPTION_REGISTRY_PREDICATES_XPATH = "/subscription-registry/subscription[@clientID='some-client-id' and @subscriptionName='some-subscription-name']/predicates";
-
- def spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper()))
- def mockCpsDataService = Mock(CpsDataService)
- def mockCpsModuleService = Mock(CpsModuleService)
- def mockCpsValidator = Mock(CpsValidator)
-
- def objectUnderTest = new SubscriptionPersistenceImpl(spiedJsonObjectMapper, mockCpsDataService,
- mockCpsModuleService, mockCpsValidator)
-
- def predicates = new YangModelSubscriptionEvent.Predicates(datastore: 'some-datastore',
- targetCmHandles: [new YangModelSubscriptionEvent.TargetCmHandle('cmhandle1'),
- new YangModelSubscriptionEvent.TargetCmHandle('cmhandle2')])
- def yangModelSubscriptionEvent = new YangModelSubscriptionEvent(clientId: 'some-client-id',
- subscriptionName: 'some-subscription-name', tagged: true, topic: 'some-topic', predicates: predicates)
-
- def 'save a subscription event as yang model into db for the #scenarios' () {
- given: 'a blank data node that exist in db'
- def blankDataNode = new DataNodeBuilder().withDataspace(NCMP_DATASPACE_NAME)
- .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry').build()
- and: 'cps data service return an empty data node'
- mockCpsDataService.getDataNodes(*_) >> [blankDataNode]
- when: 'the yangModelSubscriptionEvent is saved into db'
- objectUnderTest.saveSubscriptionEvent(yangModelSubscriptionEvent)
- then: 'the cpsDataService save operation is called with the correct data'
- 1 * mockCpsDataService.saveListElements(NCMP_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME,
- SUBSCRIPTION_REGISTRY_PARENT,
- '{"subscription":[{' +
- '"topic":"some-topic",' +
- '"predicates":{"datastore":"some-datastore","targetCmHandles":[{"cmHandleId":"cmhandle1","status":"PENDING","details":"Subscription forwarded to dmi plugin"},' +
- '{"cmHandleId":"cmhandle2","status":"PENDING","details":"Subscription forwarded to dmi plugin"}]},' +
- '"clientID":"some-client-id","subscriptionName":"some-subscription-name","isTagged":true}]}',
- NO_TIMESTAMP)
- }
-
- def 'add or replace cm handle list element into db' () {
- given: 'a data node with child node exist in db'
- def leaves1 = [status:'REJECTED', cmHandleId:'cmhandle1', details:'Cm handle does not exist'] as Map
- def childDataNode = new DataNodeBuilder().withDataspace(NCMP_DATASPACE_NAME)
- .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription')
- .withLeaves(leaves1).build()
- def engagedDataNode = new DataNodeBuilder().withDataspace(NCMP_DATASPACE_NAME)
- .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry')
- .withChildDataNodes([childDataNode]).build()
- and: 'cps data service return data node including a child data node'
- mockCpsDataService.getDataNodes(*_) >> [engagedDataNode]
- and: 'cps data service return data node for querying by xpaths'
- mockCpsDataService.getDataNodesForMultipleXpaths(*_) >> [engagedDataNode]
- when: 'the yang model subscription event is saved into db'
- objectUnderTest.saveSubscriptionEvent(yangModelSubscriptionEvent)
- then: 'the cpsDataService save non-existing cm handle with the correct data'
- 1 * mockCpsDataService.saveListElements(NCMP_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME,
- SUBSCRIPTION_REGISTRY_PREDICATES_XPATH, '{"targetCmHandles":[{"cmHandleId":"cmhandle2","status":"PENDING","details":"Subscription forwarded to dmi plugin"}]}',
- NO_TIMESTAMP)
- and: 'the cpsDataService update existing cm handle with the correct data'
- 1 * mockCpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME,
- SUBSCRIPTION_REGISTRY_PREDICATES_XPATH, '{"targetCmHandles":[{"cmHandleId":"cmhandle1","status":"PENDING","details":"Subscription forwarded to dmi plugin"}]}',
- NO_TIMESTAMP)
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy
deleted file mode 100644
index 468a402c00..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-@SpringBootTest(classes = [JsonObjectMapper, ObjectMapper])
-class ClientCmSubscriptionNcmpInEventMapperSpec extends Specification {
-
- CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper)
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- def 'Map clients subscription event to ncmps subscription event'() {
- given: 'a Subscription Event'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
- when: 'the client event is mapped to a ncmp subscription event'
- def result = objectUnderTest.toCmSubscriptionDmiInEvent(testEventToMap)
- then: 'the resulting ncmp subscription event contains the correct clientId'
- assert result.getData().getSubscription().getClientID() == "SCO-9989752"
- and: 'subscription name'
- assert result.getData().getSubscription().getName() == "cm-subscription-001"
- and: 'is tagged value is false'
- assert result.getData().getSubscription().getIsTagged() == false
- and: 'data category is CM'
- assert result.getData().getDataType().getDataCategory() == 'CM'
- and: 'predicate targets is null'
- assert result.getData().getPredicates().getTargets() == []
- and: 'datastore is passthrough-running'
- assert result.getData().getPredicates().getDatastore() == 'ncmp-datastore:passthrough-running'
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy
deleted file mode 100644
index 1d38d3f023..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.hazelcast.map.IMap
-import io.cloudevents.CloudEvent
-import io.cloudevents.core.builder.CloudEventBuilder
-import org.apache.kafka.clients.consumer.ConsumerRecord
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistenceImpl
-import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.spi.model.DataNodeBuilder
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper])
-class CmSubscriptionDmiOutEventConsumerSpec extends MessagingBaseSpec {
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- @Autowired
- ObjectMapper objectMapper
-
- IMap<String, Set<String>> mockForwardedSubscriptionEventCache = Mock(IMap<String, Set<String>>)
- def mockSubscriptionPersistence = Mock(SubscriptionPersistenceImpl)
- def mockSubscriptionEventResponseMapper = Mock(CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper)
- def mockCmSubscriptionNcmpOutEventPublisher = Mock(CmSubscriptionNcmpOutEventPublisher)
-
- def objectUnderTest = new CmSubscriptionDmiOutEventConsumer(mockForwardedSubscriptionEventCache,
- mockSubscriptionPersistence, mockSubscriptionEventResponseMapper, mockCmSubscriptionNcmpOutEventPublisher)
-
- def 'Consume dmi out event where all DMIs have responded'() {
- given: 'a consumer record including cloud event having dmi out event'
- def dmiOutConsumerRecord = getDmiOutConsumerRecord()
- and: 'notifications are enabled'
- objectUnderTest.notificationFeatureEnabled = notificationEnabled
- and: 'subscription model loader is enabled'
- objectUnderTest.subscriptionModelLoaderEnabled = modelLoaderEnabled
- and: 'subscription persistence service returns data node includes no pending cm handle'
- mockSubscriptionPersistence.getCmHandlesForSubscriptionEvent(*_) >> [getDataNode()]
- when: 'the valid event is consumed'
- objectUnderTest.consumeDmiOutEvent(dmiOutConsumerRecord)
- then: 'the forwarded subscription event cache returns only the received dmiName existing for the subscription create event'
- 1 * mockForwardedSubscriptionEventCache.containsKey('SCO-9989752cm-subscription-001') >> true
- 1 * mockForwardedSubscriptionEventCache.get('SCO-9989752cm-subscription-001') >> (['some-dmi-name'] as Set)
- and: 'the forwarded subscription event cache returns an empty Map when the dmiName has been removed'
- 1 * mockForwardedSubscriptionEventCache.get('SCO-9989752cm-subscription-001') >> ([] as Set)
- and: 'the response event is map to yang model'
- numberOfTimeToPersist * mockSubscriptionEventResponseMapper.toYangModelSubscriptionEvent(_)
- and: 'the response event is persisted into the db'
- numberOfTimeToPersist * mockSubscriptionPersistence.saveSubscriptionEvent(_)
- and: 'the subscription event is removed from the map'
- numberOfTimeToRemove * mockForwardedSubscriptionEventCache.remove('SCO-9989752cm-subscription-001')
- and: 'a response outcome has been created'
- numberOfTimeToResponse * mockCmSubscriptionNcmpOutEventPublisher.sendResponse(_, 'subscriptionCreated')
- where: 'the following values are used'
- scenario | modelLoaderEnabled | notificationEnabled || numberOfTimeToPersist || numberOfTimeToRemove || numberOfTimeToResponse
- 'Both model loader and notification are enabled' | true | true || 1 || 1 || 1
- 'Both model loader and notification are disabled' | false | false || 0 || 0 || 0
- 'Model loader enabled and notification disabled' | true | false || 1 || 0 || 0
- 'Model loader disabled and notification enabled' | false | true || 0 || 1 || 1
- }
-
- def 'Consume dmi out event where another DMI has not yet responded'() {
- given: 'a subscription event response and notifications are enabled'
- objectUnderTest.notificationFeatureEnabled = notificationEnabled
- and: 'subscription model loader is enabled'
- objectUnderTest.subscriptionModelLoaderEnabled = modelLoaderEnabled
- when: 'the valid event is consumed'
- objectUnderTest.consumeDmiOutEvent(getDmiOutConsumerRecord())
- then: 'the forwarded subscription event cache returns only the received dmiName existing for the subscription create event'
- 1 * mockForwardedSubscriptionEventCache.containsKey('SCO-9989752cm-subscription-001') >> true
- 1 * mockForwardedSubscriptionEventCache.get('SCO-9989752cm-subscription-001') >> (['responded-dmi', 'non-responded-dmi'] as Set)
- and: 'the forwarded subscription event cache returns an empty Map when the dmiName has been removed'
- 1 * mockForwardedSubscriptionEventCache.get('SCO-9989752cm-subscription-001') >> (['non-responded-dmi'] as Set)
- and: 'the response event is map to yang model'
- numberOfTimeToPersist * mockSubscriptionEventResponseMapper.toYangModelSubscriptionEvent(_)
- and: 'the response event is persisted into the db'
- numberOfTimeToPersist * mockSubscriptionPersistence.saveSubscriptionEvent(_)
- and: 'the subscription event is removed from the map'
- and: 'the subscription event is not removed from the map'
- 0 * mockForwardedSubscriptionEventCache.remove(_)
- and: 'a response outcome has not been created'
- 0 * mockCmSubscriptionNcmpOutEventPublisher.sendResponse(*_)
- where: 'the following values are used'
- scenario | modelLoaderEnabled | notificationEnabled || numberOfTimeToPersist
- 'Both model loader and notification are enabled' | true | true || 1
- 'Both model loader and notification are disabled' | false | false || 0
- 'Model loader enabled and notification disabled' | true | false || 1
- 'Model loader disabled and notification enabled' | false | true || 0
- }
-
- def getDmiOutEvent() {
- def cmSubscriptionDmiOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json')
- return jsonObjectMapper.convertJsonString(cmSubscriptionDmiOutEventJsonData, CmSubscriptionDmiOutEvent.class)
- }
-
- def getCloudEvent() {
- return CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(getDmiOutEvent()))
- .withId('some-id')
- .withType('subscriptionCreated')
- .withSource(URI.create('NCMP')).build()
- }
-
- def getDmiOutConsumerRecord() {
- return new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, 'event-key', getCloudEvent())
- }
-
- def getDataNode() {
- def leaves = [status:'ACCEPTED', cmHandleId:'cmhandle1'] as Map
- return new DataNodeBuilder().withDataspace(NCMP_DATASPACE_NAME)
- .withAnchor('AVC-Subscriptions').withXpath('/subscription-registry/subscription')
- .withLeaves(leaves).build()
- }
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy
deleted file mode 100644
index 1c91cb5d57..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-
-@SpringBootTest(classes = [JsonObjectMapper, ObjectMapper])
-class CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec extends Specification {
-
- CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper)
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- def 'Map dmi out event to yang model subscription event'() {
- given: 'a dmi out event'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json')
- def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionDmiOutEvent.class)
- when: 'the event is mapped to a yang model subscription'
- def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
- then: 'the resulting yang model subscription event contains the correct clientId'
- assert result.clientId == "SCO-9989752"
- and: 'subscription name'
- assert result.subscriptionName == "cm-subscription-001"
- and: 'predicate targets cm handle size as expected'
- assert result.predicates.targetCmHandles.size() == 2
- and: 'predicate targets cm handle ids as expected'
- assert result.predicates.targetCmHandles.cmHandleId == ["CMHandle1", "CMHandle2"]
- and: 'the status for these targets is set to expected values'
- assert result.predicates.targetCmHandles.status == [SubscriptionStatus.REJECTED, SubscriptionStatus.REJECTED]
- }
-
-} \ No newline at end of file
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy
deleted file mode 100644
index 17b0984eb9..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.models.CmSubscriptionEvent
-import org.onap.cps.ncmp.api.models.CmSubscriptionStatus
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.spi.exceptions.DataValidationException
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-
-@SpringBootTest(classes = [JsonObjectMapper, ObjectMapper])
-class CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec extends Specification {
-
- CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper)
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- def 'Map cm subscription event to ncmp out event'() {
- given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
- def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
- when: 'cm subscription event is mapped to ncmp out event'
- def result = objectUnderTest.toCmSubscriptionNcmpOutEvent(cmSubscriptionEvent)
- then: 'the resulting ncmp out event contains expected pending targets per details grouping'
- def pendingCmHandleTargetsPerDetails = result.getData().getAdditionalInfo().getPending()
- assert pendingCmHandleTargetsPerDetails.get(0).getDetails() == 'Some other error happened'
- assert pendingCmHandleTargetsPerDetails.get(0).getTargets() == ['CMHandle4','CMHandle5']
- assert pendingCmHandleTargetsPerDetails.get(1).getDetails() == 'Some error causes pending'
- assert pendingCmHandleTargetsPerDetails.get(1).getTargets() == ['CMHandle3']
- and: 'the resulting ncmp out event contains expected rejected targets per details grouping'
- def rejectedCmHandleTargetsPerDetails = result.getData().getAdditionalInfo().getRejected()
- assert rejectedCmHandleTargetsPerDetails.get(0).getDetails() == 'Some other error message from the DMI'
- assert rejectedCmHandleTargetsPerDetails.get(0).getTargets() == ['CMHandle2']
- assert rejectedCmHandleTargetsPerDetails.get(1).getDetails() == 'Some error message from the DMI'
- assert rejectedCmHandleTargetsPerDetails.get(1).getTargets() == ['CMHandle1']
- }
-
- def 'Map cm subscription event to ncmp out event with the given scenarios causes an exception'() {
- given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
- def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
- and: 'set cm subscription status with given scenarios'
- cmSubscriptionEvent.setCmSubscriptionStatus(subscriptionStatusList)
- when: 'cm subscription event is mapped to ncmp out event'
- objectUnderTest.toCmSubscriptionNcmpOutEvent(cmSubscriptionEvent)
- then: 'a DataValidationException is thrown with an expected exception details'
- def exception = thrown(DataValidationException)
- exception.details == 'CmSubscriptionStatus list cannot be null or empty'
- where: 'the following values are used'
- scenario || subscriptionStatusList
- 'A null subscription status list' || null
- 'An empty subscription status list' || new ArrayList<CmSubscriptionStatus>()
- }
-
- def 'Map cm subscription event to ncmp out event without any exception'() {
- given: 'a cm subscription Event'
- def subscriptionResponseJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
- def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionEvent.class)
- when: 'cm subscription event is mapped to ncmp out event'
- objectUnderTest.toCmSubscriptionNcmpOutEvent(subscriptionResponseEvent)
- then: 'no exception thrown'
- noExceptionThrown()
- }
-} \ No newline at end of file
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy
deleted file mode 100644
index 9484e19a49..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2022-2023 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.api.impl.events.deprecated.cmsubscription
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import io.cloudevents.CloudEvent
-import io.cloudevents.core.builder.CloudEventBuilder
-import org.apache.kafka.clients.consumer.ConsumerRecord
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence
-import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent
-import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper])
-class CmSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpec {
-
- def mockCmSubscriptionNcmpInEventForwarder = Mock(CmSubscriptionNcmpInEventForwarder)
- def mockCmSubscriptionNcmpInEventMapper = Mock(CmSubscriptionNcmpInEventMapper)
- def mockSubscriptionPersistence = Mock(SubscriptionPersistence)
- def objectUnderTest = new CmSubscriptionNcmpInEventConsumer(mockCmSubscriptionNcmpInEventForwarder, mockCmSubscriptionNcmpInEventMapper, mockSubscriptionPersistence)
-
- def yangModelSubscriptionEvent = new YangModelSubscriptionEvent()
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- @Autowired
- ObjectMapper objectMapper
-
-
- def 'Consume, persist and forward valid CM create message'() {
- given: 'an event with data category CM'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
- testEventSent.getData().getDataType().setDataCategory(dataCategory)
- def testCloudEventSent = CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(testEventSent))
- .withId('subscriptionCreated')
- .withType(dataType)
- .withSource(URI.create('some-resource'))
- .withExtension('correlationid', 'test-cmhandle1').build()
- def consumerRecord = new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, 'event-key', testCloudEventSent)
- and: 'notifications are enabled'
- objectUnderTest.notificationFeatureEnabled = isNotificationEnabled
- and: 'subscription model loader is enabled'
- objectUnderTest.subscriptionModelLoaderEnabled = isModelLoaderEnabled
- when: 'the valid event is consumed'
- objectUnderTest.consumeSubscriptionEvent(consumerRecord)
- then: 'the event is mapped to a yangModelSubscription'
- numberOfTimesToPersist * mockCmSubscriptionNcmpInEventMapper.toYangModelSubscriptionEvent(testEventSent) >> yangModelSubscriptionEvent
- and: 'the event is persisted'
- numberOfTimesToPersist * mockSubscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent)
- and: 'the event is forwarded'
- numberOfTimesToForward * mockCmSubscriptionNcmpInEventForwarder.forwardCreateSubscriptionEvent(testEventSent, 'subscriptionCreated')
- where: 'given values are used'
- scenario | dataCategory | dataType | isNotificationEnabled | isModelLoaderEnabled || numberOfTimesToForward || numberOfTimesToPersist
- 'Both model loader and notification are enabled' | 'CM' | 'subscriptionCreated' | true | true || 1 || 1
- 'Both model loader and notification are disabled' | 'CM' | 'subscriptionCreated' | false | false || 0 || 0
- 'Model loader enabled and notification disabled' | 'CM' | 'subscriptionCreated' | false | true || 0 || 1
- 'Model loader disabled and notification enabled' | 'CM' | 'subscriptionCreated' | true | false || 1 || 0
- 'Flags are enabled but data category is FM' | 'FM' | 'subscriptionCreated' | true | true || 0 || 0
- 'Flags are enabled but data type is UPDATE' | 'CM' | 'subscriptionUpdated' | true | true || 0 || 1
- }
-
- def 'Consume event with wrong datastore causes an exception'() {
- given: 'an event'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
- and: 'datastore is set to a passthrough-running datastore'
- testEventSent.getData().getPredicates().setDatastore('operational')
- def testCloudEventSent = CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(testEventSent))
- .withId('some-event-id')
- .withType('some-event-type')
- .withSource(URI.create('some-resource'))
- .withExtension('correlationid', 'test-cmhandle1').build()
- def consumerRecord = new ConsumerRecord<String, CmSubscriptionNcmpInEvent>('topic-name', 0, 0, 'event-key', testCloudEventSent)
- when: 'the valid event is consumed'
- objectUnderTest.consumeSubscriptionEvent(consumerRecord)
- then: 'an operation not supported exception is thrown'
- thrown(UnsupportedOperationException)
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy
deleted file mode 100644
index ef3ea88bbd..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.hazelcast.map.IMap
-import io.cloudevents.CloudEvent
-import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.events.EventsPublisher
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus
-import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper
-import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
-import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent.TargetCmHandle
-import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence
-import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmHandle
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.spockframework.spring.SpringBean
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.util.concurrent.BlockingVariable
-import java.util.concurrent.TimeUnit
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper, CmSubscriptionNcmpInEventForwarder])
-class CmSubscriptionNcmpInEventForwarderSpec extends MessagingBaseSpec {
-
- @Autowired
- CmSubscriptionNcmpInEventForwarder objectUnderTest
- @SpringBean
- InventoryPersistence mockInventoryPersistence = Mock(InventoryPersistence)
- @SpringBean
- EventsPublisher<CloudEvent> mockSubscriptionEventPublisher = Mock(EventsPublisher<CloudEvent>)
- @SpringBean
- IMap<String, Set<String>> mockForwardedSubscriptionEventCache = Mock(IMap<String, Set<String>>)
- @SpringBean
- CmSubscriptionEventCloudMapper subscriptionEventCloudMapper = new CmSubscriptionEventCloudMapper(new ObjectMapper())
- @SpringBean
- CmSubscriptionNcmpOutEventPublisher mockCmSubscriptionNcmpOutEventPublisher = Mock(CmSubscriptionNcmpOutEventPublisher)
- @SpringBean
- SubscriptionPersistence mockSubscriptionPersistence = Mock(SubscriptionPersistence)
- @SpringBean
- CmSubscriptionNcmpInEventMapper cmSubscriptionNcmpInEventMapper = Mappers.getMapper(CmSubscriptionNcmpInEventMapper)
- @SpringBean
- CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper cmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper = Mappers.getMapper(CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper)
- @Autowired
- JsonObjectMapper jsonObjectMapper
- @Autowired
- ObjectMapper objectMapper
-
- def 'Forward valid CM create subscription and simulate timeout'() {
- given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
- and: 'the InventoryPersistence returns private properties for the supplied CM Handles'
- 1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> [
- createYangModelCmHandleWithDmiProperty(1, 1,"shape","circle"),
- createYangModelCmHandleWithDmiProperty(2, 1,"shape","square"),
- createYangModelCmHandleWithDmiProperty(3, 2,"shape","triangle")
- ]
- and: 'the thread creation delay is reduced to 2 seconds for testing'
- objectUnderTest.dmiResponseTimeoutInMs = 2000
- and: 'a Blocking Variable is used for the Asynchronous call with a timeout of 5 seconds'
- def block = new BlockingVariable<Object>(5)
- when: 'the valid event is forwarded'
- objectUnderTest.forwardCreateSubscriptionEvent(ncmpInEventJson, 'subscriptionCreated')
- then: 'An asynchronous call is made to the blocking variable'
- block.get()
- then: 'the event is added to the forwarded subscription event cache'
- 1 * mockForwardedSubscriptionEventCache.put("SCO-9989752cm-subscription-001", ["DMIName1","DMIName2"] as Set, 600, TimeUnit.SECONDS)
- and: 'the event is forwarded twice with the CMHandle private properties and provides a valid listenable future'
- 1 * mockSubscriptionEventPublisher.publishCloudEvent("ncmp-dmi-cm-avc-subscription-DMIName1", "SCO-9989752-cm-subscription-001-DMIName1",
- cloudEvent -> {
- def targets = toTargetEvent(cloudEvent, CmSubscriptionDmiInEvent.class).getData().getPredicates().getTargets()
- def cmHandle2 = createCmHandle('CMHandle2', ['shape': 'square'] as Map)
- def cmHandle1 = createCmHandle('CMHandle1', ['shape': 'circle'] as Map)
- targets == [cmHandle2, cmHandle1]
- }
- )
- 1 * mockSubscriptionEventPublisher.publishCloudEvent("ncmp-dmi-cm-avc-subscription-DMIName2", "SCO-9989752-cm-subscription-001-DMIName2",
- cloudEvent -> {
- def targets = toTargetEvent(cloudEvent, CmSubscriptionDmiInEvent.class).getData().getPredicates().getTargets()
- def cmHandle3 = createCmHandle('CMHandle3', ['shape':'triangle'] as Map)
- targets == [cmHandle3]
- }
- )
- and: 'a separate thread has been created where the map is polled'
- 1 * mockForwardedSubscriptionEventCache.containsKey("SCO-9989752cm-subscription-001") >> true
- 1 * mockCmSubscriptionNcmpOutEventPublisher.sendResponse(*_)
- and: 'the subscription id is removed from the event cache map returning the asynchronous blocking variable'
- 1 * mockForwardedSubscriptionEventCache.remove("SCO-9989752cm-subscription-001") >> { block.set(_) }
- }
-
- def 'Forward CM create subscription where target CM Handles are #scenario'() {
- given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
- and: 'the target CMHandles are set to #scenario'
- ncmpInEventJson.getData().getPredicates().setTargets(invalidTargets)
- when: 'the event is forwarded'
- objectUnderTest.forwardCreateSubscriptionEvent(ncmpInEventJson, 'some-event-type')
- then: 'an operation not supported exception is thrown'
- thrown(UnsupportedOperationException)
- where:
- scenario | invalidTargets
- 'null' | null
- 'empty' | []
- 'wildcard' | ['CMHandle*']
- }
-
- def 'Forward valid CM create subscription where targets are not associated to any existing CMHandles'() {
- given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
- and: 'the InventoryPersistence returns no private properties for the supplied CM Handles'
- 1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> []
- and: 'some rejected cm handles'
- def rejectedCmHandles = [new TargetCmHandle('CMHandle1', SubscriptionStatus.REJECTED, 'Cm handle does not exist'),
- new TargetCmHandle('CMHandle2', SubscriptionStatus.REJECTED, 'Cm handle does not exist'),
- new TargetCmHandle('CMHandle3', SubscriptionStatus.REJECTED, 'Cm handle does not exist')]
- and: 'a yang model subscription event will be saved into the db with rejected cm handles'
- def yangModelSubscriptionEvent = cmSubscriptionNcmpInEventMapper.toYangModelSubscriptionEvent(ncmpInEventJson)
- yangModelSubscriptionEvent.getPredicates().setTargetCmHandles(rejectedCmHandles)
- and: 'the thread creation delay is reduced to 2 seconds for testing'
- objectUnderTest.dmiResponseTimeoutInMs = 2000
- and: 'a Blocking Variable is used for the Asynchronous call with a timeout of 5 seconds'
- def block = new BlockingVariable<Object>(5)
- when: 'the valid event is forwarded'
- objectUnderTest.forwardCreateSubscriptionEvent(ncmpInEventJson, 'subscriptionCreatedStatus')
- then: 'the event is not added to the forwarded subscription event cache'
- 0 * mockForwardedSubscriptionEventCache.put("SCO-9989752cm-subscription-001", ["DMIName1", "DMIName2"] as Set)
- and: 'the event is not being forwarded with the CMHandle private properties and does not provides a valid listenable future'
- 0 * mockSubscriptionEventPublisher.publishCloudEvent("ncmp-dmi-cm-avc-subscription-DMIName1", "SCO-9989752-cm-subscription-001-DMIName1",
- cloudEvent -> {
- def targets = toTargetEvent(cloudEvent, CmSubscriptionDmiInEvent.class).getData().getPredicates().getTargets()
- def cmHandle2 = createCmHandle('CMHandle2', ['shape': 'square'] as Map)
- def cmHandle1 = createCmHandle('CMHandle1', ['shape': 'circle'] as Map)
- targets == [cmHandle2, cmHandle1]
- }
- )
- 0 * mockSubscriptionEventPublisher.publishCloudEvent("ncmp-dmi-cm-avc-subscription-DMIName2", "SCO-9989752-cm-subscription-001-DMIName2",
- cloudEvent -> {
- def targets = toTargetEvent(cloudEvent, CmSubscriptionDmiInEvent.class).getData().getPredicates().getTargets()
- def cmHandle3 = createCmHandle('CMHandle3', ['shape': 'triangle'] as Map)
- targets == [cmHandle3]
- }
- )
- and: 'a separate thread has been created where the map is polled'
- 0 * mockForwardedSubscriptionEventCache.containsKey("SCO-9989752cm-subscription-001") >> true
- 0 * mockForwardedSubscriptionEventCache.get(_)
- and: 'the subscription id is removed from the event cache map returning the asynchronous blocking variable'
- 0 * mockForwardedSubscriptionEventCache.remove("SCO-9989752cm-subscription-001") >> {block.set(_)}
- and: 'the persistence service save target cm handles of the yang model subscription event as rejected'
- 1 * mockSubscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent)
- and: 'subscription outcome has been sent'
- 1 * mockCmSubscriptionNcmpOutEventPublisher.sendResponse(_, 'subscriptionCreatedStatus')
- }
-
- def 'Extract domain name from URL for #scenario'() {
- when: 'a valid dmi name is provided'
- def domainName = objectUnderTest.toValidTopicSuffix(dmiName)
- then: 'domain name is as expected with no port information'
- assert domainName == expectedDomainName
- where: ''
- scenario | dmiName || expectedDomainName
- 'insecure http url with port' | 'http://www.onap-dmi:8080/xyz=123' || 'onap-dmi'
- 'insecure http url without port' | 'http://www.onap-dmi/xyz=123' || 'onap-dmi'
- 'secure https url with port' | 'https://127.0.0.1:8080/xyz=123' || '127.0.0.1'
- 'secure https url without port' | 'https://127.0.0.1/xyz=123' || '127.0.0.1'
- 'servername without protocol and port' | 'dminame1' || 'dminame1'
- 'servername without protocol' | 'www.onap-dmi:8080/xyz=123' || 'www.onap-dmi:8080/xyz=123'
-
- }
-
- static def createYangModelCmHandleWithDmiProperty(id, dmiId, propertyName, propertyValue) {
- return new YangModelCmHandle(id: "CMHandle" + id, dmiDataServiceName: "DMIName" + dmiId, dmiProperties: [new YangModelCmHandle.Property(propertyName, propertyValue)])
- }
-
- static def createCmHandle(id, additionalProperties) {
- def cmHandle = new CmHandle();
- cmHandle.setId(id)
- cmHandle.setAdditionalProperties(additionalProperties)
- return cmHandle
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy
deleted file mode 100644
index 6dcc997ec2..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-
-@SpringBootTest(classes = [JsonObjectMapper, ObjectMapper])
-class CmSubscriptionNcmpInEventMapperSpec extends Specification {
-
- CmSubscriptionNcmpInEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionNcmpInEventMapper)
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- def 'Map subscription event to yang model subscription event where #scenario'() {
- given: 'a Subscription Event'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
- def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
- when: 'the event is mapped to a yang model subscription'
- def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
- then: 'the resulting yang model subscription event contains the correct clientId'
- assert result.clientId == "SCO-9989752"
- and: 'subscription name'
- assert result.subscriptionName == "cm-subscription-001"
- and: 'is tagged value is false'
- assert !result.isTagged
- and: 'predicate targets '
- assert result.predicates.targetCmHandles.cmHandleId == ["CMHandle1", "CMHandle2", "CMHandle3"]
- and: 'the status for these targets is set to pending'
- assert result.predicates.targetCmHandles.status == [SubscriptionStatus.PENDING, SubscriptionStatus.PENDING, SubscriptionStatus.PENDING]
- and: 'the topic is null'
- assert result.topic == null
- }
-
- def 'Map empty subscription event to yang model subscription event'() {
- given: 'a new Subscription Event with no data'
- def testEventToMap = new CmSubscriptionNcmpInEvent()
- when: 'the event is mapped to a yang model subscription'
- def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
- then: 'the resulting yang model subscription event contains null clientId'
- assert result.clientId == null
- and: 'subscription name is null'
- assert result.subscriptionName == null
- and: 'is tagged value is false'
- assert result.isTagged == false
- and: 'predicates is null'
- assert result.predicates == null
- and: 'the topic is null'
- assert result.topic == null
- }
-} \ No newline at end of file
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
deleted file mode 100644
index 725d32437e..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (c) 2023 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.api.impl.events.deprecated.cmsubscription
-
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUCCESSFULLY_APPLIED_SUBSCRIPTION
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_PENDING
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_NOT_APPLICABLE
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.PARTIALLY_APPLIED_SUBSCRIPTION
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import io.cloudevents.CloudEvent
-import io.cloudevents.core.builder.CloudEventBuilder
-import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.events.EventsPublisher
-import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence
-import org.onap.cps.ncmp.api.impl.utils.DataNodeBaseSpec
-import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper
-import org.onap.cps.ncmp.api.models.CmSubscriptionEvent
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.spockframework.spring.SpringBean
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper, CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper, CmSubscriptionNcmpOutEventPublisher])
-class CmSubscriptionNcmpOutEventPublisherSpec extends DataNodeBaseSpec {
-
- @Autowired
- CmSubscriptionNcmpOutEventPublisher objectUnderTest
-
- @SpringBean
- SubscriptionPersistence mockSubscriptionPersistence = Mock(SubscriptionPersistence)
- @SpringBean
- EventsPublisher<CloudEvent> mockCmSubscriptionNcmpOutEventPublisher = Mock(EventsPublisher<CloudEvent>)
- @SpringBean
- CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper cmSubscriptionEventToCmSubscriptionNcmpOutEventMapper = Mappers.getMapper(CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper)
- @SpringBean
- SubscriptionOutcomeCloudMapper subscriptionOutcomeCloudMapper = new SubscriptionOutcomeCloudMapper(new ObjectMapper())
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- @Autowired
- ObjectMapper objectMapper
-
- def 'Send response to the client apps successfully'() {
- given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
- def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
- and: 'a ncmp out event'
- def ncmpOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent2.json')
- def ncmpOutEvent = jsonObjectMapper.convertJsonString(ncmpOutEventJsonData, CmSubscriptionNcmpOutEvent.class)
- and: 'a random id for the cloud event'
- SubscriptionOutcomeCloudMapper.randomId = 'some-id'
- and: 'a cloud event containing the outcome event'
- def testCloudEventSent = CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(ncmpOutEvent))
- .withId('some-id')
- .withType('subscriptionCreatedStatus')
- .withDataSchema(URI.create('urn:cps:' + 'org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent' + ':1.0.0'))
- .withExtension("correlationid", 'SCO-9989752cm-subscription-001')
- .withSource(URI.create('NCMP')).build()
- and: 'the persistence service return a data node that includes pending cm handles that makes it partial success'
- mockSubscriptionPersistence.getCmHandlesForSubscriptionEvent(*_) >> [dataNode4]
- when: 'the response is being sent'
- objectUnderTest.sendResponse(cmSubscriptionEvent, 'subscriptionCreatedStatus')
- then: 'the publisher publish the cloud event with itself and expected parameters'
- 1 * mockCmSubscriptionNcmpOutEventPublisher.publishCloudEvent('subscription-response', 'SCO-9989752cm-subscription-001', testCloudEventSent)
- }
-
- def 'Create ncmp out message as expected'() {
- given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
- def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
- and: 'a ncmp out event'
- def ncmpOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
- def ncmpOutEvent = jsonObjectMapper.convertJsonString(ncmpOutEventJsonData, CmSubscriptionNcmpOutEvent.class)
- and: 'a status code and status message a per #scenarios'
- ncmpOutEvent.getData().setStatusCode(statusCode)
- ncmpOutEvent.getData().setStatusMessage(statusMessage)
- when: 'a cm subscription event is being formed'
- def expectedResult = objectUnderTest.fromCmSubscriptionEvent(cmSubscriptionEvent, ncmpEventResponseCode)
- then: 'the result will be equal to ncmp out event'
- expectedResult == ncmpOutEvent
- where: 'the following values are used'
- scenario | ncmpEventResponseCode || statusMessage || statusCode
- 'is full outcome' | SUCCESSFULLY_APPLIED_SUBSCRIPTION || 'successfully applied subscription' || 1
- 'is partial outcome' | PARTIALLY_APPLIED_SUBSCRIPTION || 'partially applied subscription' || 104
- }
-
- def 'Check cm handle id to status map to see if it is a full outcome response'() {
- when: 'is full outcome response evaluated'
- def response = objectUnderTest.decideOnNcmpEventResponseCodeForSubscription(cmHandleIdToStatusAndDetailsAsMap)
- then: 'the result will be as expected'
- response == expectedOutcomeResponseDecision
- where: 'the following values are used'
- scenario | cmHandleIdToStatusAndDetailsAsMap || expectedOutcomeResponseDecision
- 'The map contains PENDING status' | [CMHandle1: [details: 'Subscription forwarded to dmi plugin', status: 'PENDING'] as Map] as Map || SUBSCRIPTION_PENDING
- 'The map contains ACCEPTED status' | [CMHandle1: [details: '', status: 'ACCEPTED'] as Map] as Map || SUCCESSFULLY_APPLIED_SUBSCRIPTION
- 'The map contains REJECTED status' | [CMHandle1: [details: 'Cm handle does not exist', status: 'REJECTED'] as Map] as Map || SUBSCRIPTION_NOT_APPLICABLE
- 'The map contains PENDING and PENDING statuses' | [CMHandle1: [details: 'Some details', status: 'PENDING'] as Map, CMHandle2: [details: 'Some details', status: 'PENDING'] as Map as Map] as Map || SUBSCRIPTION_PENDING
- 'The map contains ACCEPTED and ACCEPTED statuses' | [CMHandle1: [details: '', status: 'ACCEPTED'] as Map, CMHandle2: [details: '', status: 'ACCEPTED'] as Map as Map] as Map || SUCCESSFULLY_APPLIED_SUBSCRIPTION
- 'The map contains REJECTED and REJECTED statuses' | [CMHandle1: [details: 'Reject details', status: 'REJECTED'] as Map, CMHandle2: [details: 'Reject details', status: 'REJECTED'] as Map as Map] as Map || SUBSCRIPTION_NOT_APPLICABLE
- 'The map contains PENDING and ACCEPTED statuses' | [CMHandle1: [details: 'Some details', status: 'PENDING'] as Map, CMHandle2: [details: '', status: 'ACCEPTED'] as Map as Map] as Map || PARTIALLY_APPLIED_SUBSCRIPTION
- 'The map contains REJECTED and ACCEPTED statuses' | [CMHandle1: [details: 'Cm handle does not exist', status: 'REJECTED'] as Map, CMHandle2: [details: '', status: 'ACCEPTED'] as Map as Map] as Map || PARTIALLY_APPLIED_SUBSCRIPTION
- 'The map contains PENDING and REJECTED statuses' | [CMHandle1: [details: 'Subscription forwarded to dmi plugin', status: 'PENDING'] as Map, CMHandle2: [details: 'Cm handle does not exist', status: 'REJECTED'] as Map as Map] as Map || PARTIALLY_APPLIED_SUBSCRIPTION
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapperSpec.groovy
deleted file mode 100644
index e6d383128d..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/mapper/CloudEventMapperSpec.groovy
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * ============LICENSE_START========================================================
- * Copyright (c) 2023 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.api.impl.events.mapper
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import io.cloudevents.core.builder.CloudEventBuilder
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper])
-class CloudEventMapperSpec extends Specification {
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- def 'Cloud event to target event type'() {
- given: 'a cloud event with valid payload'
- def cloudEvent = testCloudEvent(new CmSubscriptionNcmpInEvent())
- when: 'the cloud event mapped to target event'
- def result = CloudEventMapper.toTargetEvent((cloudEvent), CmSubscriptionNcmpInEvent.class)
- then: 'the cloud event is mapped'
- assert result instanceof CmSubscriptionNcmpInEvent
- }
-
- def 'Cloud event to target event type when it is #scenario'() {
- given: 'a cloud event with invalid payload'
- def cloudEvent = testCloudEvent(payload)
- when: 'the cloud event mapped to target event'
- def result = CloudEventMapper.toTargetEvent(cloudEvent, CmSubscriptionNcmpInEvent.class)
- then: 'result is null'
- assert result == null
- where: 'below are the scenarios'
- scenario | payload
- 'invalid payload type' | ArrayList.class
- 'without payload' | null
- }
-
- def testCloudEvent(payload) {
- return CloudEventBuilder.v1().withData(jsonObjectMapper.asJsonBytes(payload))
- .withId("cmhandle1")
- .withSource(URI.create('test-source'))
- .withDataSchema(URI.create('test'))
- .withType('org.onap.cm.events.cm-subscription')
- .build()
- }
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy
deleted file mode 100644
index d61a026b73..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START========================================================
- * Copyright (c) 2023 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.api.impl.util.deprecated
-
-import com.fasterxml.jackson.core.JsonProcessingException
-import com.fasterxml.jackson.databind.ObjectMapper
-import io.cloudevents.core.builder.CloudEventBuilder
-import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper])
-class CmSubscriptionEventCloudMapperSpec extends Specification {
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- @Autowired
- ObjectMapper objectMapper
-
- def spyObjectMapper = Spy(ObjectMapper)
-
- def objectUnderTest = new CmSubscriptionEventCloudMapper(spyObjectMapper)
-
- def 'Map the subscription event to data of the cloud event'() {
- given: 'a subscription event'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiInEvent.json')
- def testEventData = jsonObjectMapper.convertJsonString(jsonData,
- CmSubscriptionDmiInEvent.class)
- def testCloudEvent = CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(testEventData))
- .withId('some-id')
- .withType('subscriptionCreated')
- .withSource(URI.create('SCO-9989752'))
- .withExtension('correlationid', 'test-cmhandle1').build()
- when: 'the subscription event map to data of cloud event'
- CmSubscriptionEventCloudMapper.randomId = 'some-id'
- def resultCloudEvent = objectUnderTest.toCloudEvent(testEventData, 'some-event-key', 'subscriptionCreated')
- then: 'the subscription event resulted having expected values'
- resultCloudEvent.getData() == testCloudEvent.getData()
- resultCloudEvent.getId() == testCloudEvent.getId()
- resultCloudEvent.getType() == testCloudEvent.getType()
- resultCloudEvent.getSource() == URI.create('SCO-9989752')
- resultCloudEvent.getDataSchema() == URI.create('urn:cps:org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent:1.0.0')
- }
-
- def 'Map the subscription event to cloud event with JSON processing exception'() {
- given: 'a json processing exception during process'
- def jsonProcessingException = new JsonProcessingException('The Cloud Event could not be constructed')
- spyObjectMapper.writeValueAsBytes(_) >> { throw jsonProcessingException }
- and: 'a subscription event of ncmp version'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiInEvent.json')
- def testEventData = jsonObjectMapper.convertJsonString(jsonData,
- CmSubscriptionDmiInEvent.class)
- when: 'the subscription event map to cloud event'
- def expectedResult = objectUnderTest.toCloudEvent(testEventData, 'some-key', 'some-event-type')
- then: 'no exception is thrown since it has been handled already'
- noExceptionThrown()
- and: 'expected result should be null'
- expectedResult == null
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy
deleted file mode 100644
index 9d79a8b4bb..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * ============LICENSE_START========================================================
- * Copyright (c) 2023 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.api.impl.util.deprecated
-
-import com.fasterxml.jackson.core.JsonProcessingException
-import com.fasterxml.jackson.databind.ObjectMapper
-import io.cloudevents.core.builder.CloudEventBuilder
-import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper
-import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent
-import org.onap.cps.ncmp.utils.TestUtils
-import org.onap.cps.utils.JsonObjectMapper
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import spock.lang.Specification
-
-@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper])
-class SubscriptionOutcomeCloudMapperSpec extends Specification {
-
- @Autowired
- JsonObjectMapper jsonObjectMapper
-
- @Autowired
- ObjectMapper objectMapper
-
- def spyObjectMapper = Spy(ObjectMapper)
-
- def objectUnderTest = new SubscriptionOutcomeCloudMapper(spyObjectMapper)
-
- def 'Map the subscription outcome to cloud event'() {
- given: 'a subscription event'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
- def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class)
- def testCloudEvent = CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(testEventData))
- .withId('some-id')
- .withType('subscriptionCreatedStatus')
- .withSource(URI.create('NCMP'))
- .withExtension('correlationid', 'test-cmhandle1').build()
- when: 'the subscription event map to data of cloud event'
- SubscriptionOutcomeCloudMapper.randomId = 'some-id'
- def resultCloudEvent = objectUnderTest.toCloudEvent(testEventData, 'some-event-key', 'subscriptionCreatedStatus')
- then: 'the subscription event resulted having expected values'
- resultCloudEvent.getData() == testCloudEvent.getData()
- resultCloudEvent.getId() == testCloudEvent.getId()
- resultCloudEvent.getType() == testCloudEvent.getType()
- resultCloudEvent.getSource() == testCloudEvent.getSource()
- resultCloudEvent.getDataSchema() == URI.create('urn:cps:org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent:1.0.0')
- }
-
- def 'Map the subscription outcome to cloud event with JSON processing exception'() {
- given: 'a json processing exception during process'
- def jsonProcessingException = new JsonProcessingException('The Cloud Event could not be constructed')
- spyObjectMapper.writeValueAsBytes(_) >> { throw jsonProcessingException }
- and: 'a cloud event having a subscription outcome in the data part'
- def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
- def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class)
- when: 'the subscription outcome map to cloud event'
- def expectedResult = objectUnderTest.toCloudEvent(testEventData, 'some-key', 'some-event-type')
- then: 'no exception is thrown since it has been handled already'
- noExceptionThrown()
- and: 'expected result should be null'
- expectedResult == null
- }
-
-}