diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2023-08-08 15:27:18 +0100 |
---|---|---|
committer | Priyank Maheshwari <priyank.maheshwari@est.tech> | 2023-08-09 14:40:31 +0000 |
commit | 2fe802a8bdda1e628c4558f9079439893e7bd52e (patch) | |
tree | e34309179a2bc5098b5fc9240943a4f3a8e842f1 /cps-ncmp-service/src/test | |
parent | c38ada1f4b44cf5dcc9f8cc4fb49cd9a8568a774 (diff) |
Refactoring Subscription Create LCM use case
- Client to NCMP: CmSubscriptionNcmpInEvent
- NCMP to DMI: CmSubscriptionDmiInEvent
- DMI to NCMP: CmSubscriptionDmiOutEvent
- NCMP to Client: CmSubscriptionNcmpOutEvent
- code package changed from avcsubscription to cmsubscription
- Other classes name as per the events naming above
- Test classes refactored
- NO LOGIC changes incorporated in this patch
Issue-ID: CPS-1831
Change-Id: Id5ad5f799007deaaf6d6fc0f402c130339263d09
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/ClientSubscriptionEventMapperSpec.groovy) | 14 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseConsumerSpec.groovy) | 16 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionOutcomeMapperSpec.groovy) | 28 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseMapperSpec.groovy) | 12 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventConsumerSpec.groovy) | 30 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventForwarderSpec.groovy) | 51 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventMapperSpec.groovy) | 15 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseOutcomeSpec.groovy) | 38 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventCloudMapperSpec.groovy) | 27 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapperSpec.groovy | 10 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy | 12 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/resources/cmSubscriptionDmiInEvent.json (renamed from cps-ncmp-service/src/test/resources/avcSubscriptionCreationEventNcmpVersion.json) | 0 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/resources/cmSubscriptionDmiOutEvent.json (renamed from cps-ncmp-service/src/test/resources/avcSubscriptionEventResponse.json) | 0 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/resources/cmSubscriptionNcmpInEvent.json (renamed from cps-ncmp-service/src/test/resources/avcSubscriptionCreationEvent.json) | 0 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent.json (renamed from cps-ncmp-service/src/test/resources/avcSubscriptionOutcomeEvent.json) | 0 | ||||
-rw-r--r-- | cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent2.json (renamed from cps-ncmp-service/src/test/resources/avcSubscriptionOutcomeEvent2.json) | 0 |
16 files changed, 127 insertions, 126 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/ClientSubscriptionEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy index b3d81e33c6..b08b51ba23 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/ClientSubscriptionEventMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import org.mapstruct.factory.Mappers -import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent; +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 @@ -30,19 +30,19 @@ import org.springframework.boot.test.context.SpringBootTest import spock.lang.Specification @SpringBootTest(classes = [JsonObjectMapper, ObjectMapper]) -class ClientSubscriptionEventMapperSpec extends Specification { +class ClientCmSubscriptionNcmpInEventMapperSpec extends Specification { - ClientSubscriptionEventMapper objectUnderTest = Mappers.getMapper(ClientSubscriptionEventMapper) + 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('avcSubscriptionCreationEvent.json') - def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json') + def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class) when: 'the client event is mapped to a ncmp subscription event' - def result = objectUnderTest.toNcmpSubscriptionEvent(testEventToMap) + 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' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy index 3e6d7a82d3..29defbeccc 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseConsumerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import com.hazelcast.map.IMap @@ -28,7 +28,7 @@ import org.apache.kafka.clients.consumer.ConsumerRecord import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistenceImpl import org.onap.cps.ncmp.api.impl.utils.SubscriptionEventResponseCloudMapper import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse +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 @@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @SpringBootTest(classes = [ObjectMapper, JsonObjectMapper]) -class SubscriptionEventResponseConsumerSpec extends MessagingBaseSpec { +class CmSubscriptionDmiOutEventConsumerSpec extends MessagingBaseSpec { @Autowired JsonObjectMapper jsonObjectMapper @@ -46,11 +46,11 @@ class SubscriptionEventResponseConsumerSpec extends MessagingBaseSpec { IMap<String, Set<String>> mockForwardedSubscriptionEventCache = Mock(IMap<String, Set<String>>) def mockSubscriptionPersistence = Mock(SubscriptionPersistenceImpl) - def mockSubscriptionEventResponseMapper = Mock(SubscriptionEventResponseMapper) - def mockSubscriptionEventResponseOutcome = Mock(SubscriptionEventResponseOutcome) + def mockSubscriptionEventResponseMapper = Mock(CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper) + def mockSubscriptionEventResponseOutcome = Mock(CmSubscriptionNcmpOutEventPublisher) def mockSubscriptionEventResponseCloudMapper = new SubscriptionEventResponseCloudMapper(new ObjectMapper()) - def objectUnderTest = new SubscriptionEventResponseConsumer(mockForwardedSubscriptionEventCache, + def objectUnderTest = new CmSubscriptionDmiOutEventConsumer(mockForwardedSubscriptionEventCache, mockSubscriptionPersistence, mockSubscriptionEventResponseMapper, mockSubscriptionEventResponseOutcome, mockSubscriptionEventResponseCloudMapper) def 'Consume Subscription Event Response where all DMIs have responded'() { @@ -117,8 +117,8 @@ class SubscriptionEventResponseConsumerSpec extends MessagingBaseSpec { } def getSubscriptionResponseEvent() { - def subscriptionResponseJsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - return jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, SubscriptionEventResponse.class) + def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + return jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionDmiOutEvent.class) } def getCloudEventHavingSubscriptionResponseEvent() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionOutcomeMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapperSpec.groovy index ea1b9e7712..df5167da94 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionOutcomeMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapperSpec.groovy @@ -18,12 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import org.mapstruct.factory.Mappers -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus +import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent +import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.SubscriptionStatus import org.onap.cps.ncmp.utils.TestUtils import org.onap.cps.spi.exceptions.DataValidationException import org.onap.cps.utils.JsonObjectMapper @@ -33,19 +33,19 @@ import spock.lang.Specification @SpringBootTest(classes = [JsonObjectMapper, ObjectMapper]) -class SubscriptionOutcomeMapperSpec extends Specification { +class CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapperSpec extends Specification { - SubscriptionOutcomeMapper objectUnderTest = Mappers.getMapper(SubscriptionOutcomeMapper) + CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper) @Autowired JsonObjectMapper jsonObjectMapper def 'Map subscription event response to subscription event outcome'() { given: 'a Subscription Response Event' - def subscriptionResponseJsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, SubscriptionEventResponse.class) + def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionDmiOutEvent.class) when: 'the subscription response event is mapped to a subscription event outcome' - def result = objectUnderTest.toSubscriptionEventOutcome(subscriptionResponseEvent) + def result = objectUnderTest.toCmSubscriptionNcmpOutEvent(subscriptionResponseEvent) then: 'the resulting subscription event outcome contains expected pending targets per details grouping' def pendingCmHandleTargetsPerDetails = result.getData().getAdditionalInfo().getPending() assert pendingCmHandleTargetsPerDetails.get(0).getDetails() == 'No reply from DMI yet' @@ -60,12 +60,12 @@ class SubscriptionOutcomeMapperSpec extends Specification { def 'Map subscription event response with null of subscription status list to subscription event outcome causes an exception'() { given: 'a Subscription Response Event' - def subscriptionResponseJsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, SubscriptionEventResponse.class) + def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionDmiOutEvent.class) and: 'set subscription status list to null' subscriptionResponseEvent.getData().setSubscriptionStatus(subscriptionStatusList) when: 'the subscription response event is mapped to a subscription event outcome' - objectUnderTest.toSubscriptionEventOutcome(subscriptionResponseEvent) + objectUnderTest.toCmSubscriptionNcmpOutEvent(subscriptionResponseEvent) then: 'a DataValidationException is thrown with an expected exception details' def exception = thrown(DataValidationException) exception.details == 'SubscriptionStatus list cannot be null or empty' @@ -77,10 +77,10 @@ class SubscriptionOutcomeMapperSpec extends Specification { def 'Map subscription event response with subscription status list to subscription event outcome without any exception'() { given: 'a Subscription Response Event' - def subscriptionResponseJsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, SubscriptionEventResponse.class) + def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionDmiOutEvent.class) when: 'the subscription response event is mapped to a subscription event outcome' - objectUnderTest.toSubscriptionEventOutcome(subscriptionResponseEvent) + objectUnderTest.toCmSubscriptionNcmpOutEvent(subscriptionResponseEvent) then: 'no exception thrown' noExceptionThrown() } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy index d07d9bb993..036bedb8af 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy @@ -18,12 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import org.mapstruct.factory.Mappers import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse; +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 @@ -32,17 +32,17 @@ import spock.lang.Specification @SpringBootTest(classes = [JsonObjectMapper, ObjectMapper]) -class SubscriptionEventResponseMapperSpec extends Specification { +class CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec extends Specification { - SubscriptionEventResponseMapper objectUnderTest = Mappers.getMapper(SubscriptionEventResponseMapper) + CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper) @Autowired JsonObjectMapper jsonObjectMapper def 'Map subscription response event to yang model subscription event'() { given: 'a Subscription Response Event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEventResponse.class) + def jsonData = TestUtils.getResourceFileContent('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' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy index 430d12207c..24e829e280 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventConsumerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy @@ -18,30 +18,30 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.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.subscriptions.SubscriptionPersistence -import org.onap.cps.ncmp.api.impl.utils.SubscriptionEventCloudMapper +import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec -import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent; +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 SubscriptionEventConsumerSpec extends MessagingBaseSpec { +class CmSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpec { - def mockSubscriptionEventForwarder = Mock(SubscriptionEventForwarder) - def mockSubscriptionEventMapper = Mock(SubscriptionEventMapper) + def mockCmSubscriptionNcmpInEventForwarder = Mock(CmSubscriptionNcmpInEventForwarder) + def mockCmSubscriptionNcmpInEventMapper = Mock(CmSubscriptionNcmpInEventMapper) def mockSubscriptionPersistence = Mock(SubscriptionPersistence) - def subscriptionEventCloudMapper = new SubscriptionEventCloudMapper(new ObjectMapper()) - def objectUnderTest = new SubscriptionEventConsumer(mockSubscriptionEventForwarder, mockSubscriptionEventMapper, mockSubscriptionPersistence, subscriptionEventCloudMapper) + def cmSubscriptionEventCloudMapper = new CmSubscriptionEventCloudMapper(new ObjectMapper()) + def objectUnderTest = new CmSubscriptionNcmpInEventConsumer(mockCmSubscriptionNcmpInEventForwarder, mockCmSubscriptionNcmpInEventMapper, mockSubscriptionPersistence, cmSubscriptionEventCloudMapper) def yangModelSubscriptionEvent = new YangModelSubscriptionEvent() @@ -54,8 +54,8 @@ class SubscriptionEventConsumerSpec extends MessagingBaseSpec { def 'Consume, persist and forward valid CM create message'() { given: 'an event with data category CM' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') - def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json') + def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class) testEventSent.getData().getDataType().setDataCategory(dataCategory) def testCloudEventSent = CloudEventBuilder.v1() .withData(objectMapper.writeValueAsBytes(testEventSent)) @@ -71,11 +71,11 @@ class SubscriptionEventConsumerSpec extends MessagingBaseSpec { when: 'the valid event is consumed' objectUnderTest.consumeSubscriptionEvent(consumerRecord) then: 'the event is mapped to a yangModelSubscription' - numberOfTimesToPersist * mockSubscriptionEventMapper.toYangModelSubscriptionEvent(testEventSent) >> yangModelSubscriptionEvent + numberOfTimesToPersist * mockCmSubscriptionNcmpInEventMapper.toYangModelSubscriptionEvent(testEventSent) >> yangModelSubscriptionEvent and: 'the event is persisted' numberOfTimesToPersist * mockSubscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent) and: 'the event is forwarded' - numberOfTimesToForward * mockSubscriptionEventForwarder.forwardCreateSubscriptionEvent(testEventSent, 'subscriptionCreated') + 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 @@ -88,8 +88,8 @@ class SubscriptionEventConsumerSpec extends MessagingBaseSpec { def 'Consume event with wrong datastore causes an exception'() { given: 'an event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') - def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('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() @@ -98,7 +98,7 @@ class SubscriptionEventConsumerSpec extends MessagingBaseSpec { .withType('some-event-type') .withSource(URI.create('some-resource')) .withExtension('correlationid', 'test-cmhandle1').build() - def consumerRecord = new ConsumerRecord<String, SubscriptionEvent>('topic-name', 0, 0, 'event-key', testCloudEventSent) + 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' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventForwarderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy index dd93bf6f03..29cf8be8b6 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventForwarderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import com.hazelcast.map.IMap @@ -30,15 +30,16 @@ import org.mapstruct.factory.Mappers import org.onap.cps.ncmp.api.impl.events.EventsPublisher import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus -import org.onap.cps.ncmp.api.impl.utils.SubscriptionEventCloudMapper +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.inventory.InventoryPersistence import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec -import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.Data -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse -import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.CmHandle; +import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent +import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent +import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.Data +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 @@ -47,11 +48,11 @@ import org.springframework.boot.test.context.SpringBootTest import spock.util.concurrent.BlockingVariable import java.util.concurrent.TimeUnit -@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper, SubscriptionEventForwarder]) -class SubscriptionEventForwarderSpec extends MessagingBaseSpec { +@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper, CmSubscriptionNcmpInEventForwarder]) +class CmSubscriptionNcmpInEventForwarderSpec extends MessagingBaseSpec { @Autowired - SubscriptionEventForwarder objectUnderTest + CmSubscriptionNcmpInEventForwarder objectUnderTest @SpringBean InventoryPersistence mockInventoryPersistence = Mock(InventoryPersistence) @@ -60,15 +61,15 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { @SpringBean IMap<String, Set<String>> mockForwardedSubscriptionEventCache = Mock(IMap<String, Set<String>>) @SpringBean - SubscriptionEventCloudMapper subscriptionEventCloudMapper = new SubscriptionEventCloudMapper(new ObjectMapper()) + CmSubscriptionEventCloudMapper subscriptionEventCloudMapper = new CmSubscriptionEventCloudMapper(new ObjectMapper()) @SpringBean - SubscriptionEventResponseOutcome mockSubscriptionEventResponseOutcome = Mock(SubscriptionEventResponseOutcome) + CmSubscriptionNcmpOutEventPublisher mockCmSubscriptionNcmpOutEventPublisher = Mock(CmSubscriptionNcmpOutEventPublisher) @SpringBean SubscriptionPersistence mockSubscriptionPersistence = Mock(SubscriptionPersistence) @SpringBean - SubscriptionEventMapper subscriptionEventMapper = Mappers.getMapper(SubscriptionEventMapper) + CmSubscriptionNcmpInEventMapper cmSubscriptionNcmpInEventMapper = Mappers.getMapper(CmSubscriptionNcmpInEventMapper) @SpringBean - ClientSubscriptionEventMapper clientSubscriptionEventMapper = Mappers.getMapper(ClientSubscriptionEventMapper) + CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper cmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper = Mappers.getMapper(CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper) @Autowired JsonObjectMapper jsonObjectMapper @Autowired @@ -76,8 +77,8 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { def 'Forward valid CM create subscription and simulate timeout'() { given: 'an event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') - def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json') + def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class) and: 'the InventoryPersistence returns private properties for the supplied CM Handles' 1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> [ createYangModelCmHandleWithDmiProperty(1, 1,"shape","circle"), @@ -104,15 +105,15 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { ) and: 'a separate thread has been created where the map is polled' 1 * mockForwardedSubscriptionEventCache.containsKey("SCO-9989752cm-subscription-001") >> true - 1 * mockSubscriptionEventResponseOutcome.sendResponse(*_) + 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: 'an event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') - def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json') + def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class) and: 'the target CMHandles are set to #scenario' testEventSent.getData().getPredicates().setTargets(invalidTargets) when: 'the event is forwarded' @@ -128,10 +129,10 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { def 'Forward valid CM create subscription where targets are not associated to any existing CMHandles'() { given: 'an event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') - def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json') + def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class) and: 'a subscription event response' - def emptySubscriptionEventResponse = new SubscriptionEventResponse().withData(new Data()); + def emptySubscriptionEventResponse = new CmSubscriptionDmiOutEvent().withData(new Data()); emptySubscriptionEventResponse.getData().setSubscriptionName('cm-subscription-001'); emptySubscriptionEventResponse.getData().setClientId('SCO-9989752'); and: 'the cm handles will be rejected' @@ -139,7 +140,7 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { 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 = subscriptionEventMapper.toYangModelSubscriptionEvent(testEventSent) + def yangModelSubscriptionEvent = cmSubscriptionNcmpInEventMapper.toYangModelSubscriptionEvent(testEventSent) yangModelSubscriptionEvent.getPredicates().setTargetCmHandles(rejectedCmHandles) and: 'the InventoryPersistence returns no private properties for the supplied CM Handles' 1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> [] @@ -175,7 +176,7 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { 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 * mockSubscriptionEventResponseOutcome.sendResponse(emptySubscriptionEventResponse, 'subscriptionCreatedStatus') + 1 * mockCmSubscriptionNcmpOutEventPublisher.sendResponse(emptySubscriptionEventResponse, 'subscriptionCreatedStatus') } static def createYangModelCmHandleWithDmiProperty(id, dmiId,propertyName, propertyValue) { @@ -190,9 +191,9 @@ class SubscriptionEventForwarderSpec extends MessagingBaseSpec { } def toSubscriptionEvent(cloudEvent) { - final PojoCloudEventData<org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent> deserializedCloudEvent = CloudEventUtils + final PojoCloudEventData<CmSubscriptionDmiInEvent> deserializedCloudEvent = CloudEventUtils .mapData(cloudEvent, PojoCloudEventDataMapper.from(objectMapper, - org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent.class)); + CmSubscriptionDmiInEvent.class)); if (deserializedCloudEvent == null) { return null; } else { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy index a2a80e854b..3d034fcdcc 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy @@ -18,13 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import org.mapstruct.factory.Mappers -import org.onap.cps.ncmp.api.impl.events.avcsubscription.SubscriptionEventMapper import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus -import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent +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 @@ -33,17 +32,17 @@ import spock.lang.Specification @SpringBootTest(classes = [JsonObjectMapper, ObjectMapper]) -class SubscriptionEventMapperSpec extends Specification { +class CmSubscriptionNcmpInEventMapperSpec extends Specification { - SubscriptionEventMapper objectUnderTest = Mappers.getMapper(SubscriptionEventMapper) + 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('avcSubscriptionCreationEvent.json') - def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('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' @@ -62,7 +61,7 @@ class SubscriptionEventMapperSpec extends Specification { def 'Map empty subscription event to yang model subscription event'() { given: 'a new Subscription Event with no data' - def testEventToMap = new SubscriptionEvent() + 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' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseOutcomeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy index a6c8712a3d..07e2e3f6a5 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avcsubscription/SubscriptionEventResponseOutcomeSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.ncmp.api.impl.events.avcsubscription +package org.onap.cps.ncmp.api.impl.events.cmsubscription import com.fasterxml.jackson.databind.ObjectMapper import io.cloudevents.CloudEvent @@ -29,26 +29,26 @@ import org.onap.cps.ncmp.api.impl.events.EventsPublisher import org.onap.cps.ncmp.api.impl.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.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse -import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome; +import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent +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, SubscriptionOutcomeMapper, SubscriptionEventResponseOutcome]) -class SubscriptionEventResponseOutcomeSpec extends DataNodeBaseSpec { +@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper, CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper, CmSubscriptionNcmpOutEventPublisher]) +class CmSubscriptionNcmpOutEventPublisherSpec extends DataNodeBaseSpec { @Autowired - SubscriptionEventResponseOutcome objectUnderTest + CmSubscriptionNcmpOutEventPublisher objectUnderTest @SpringBean SubscriptionPersistence mockSubscriptionPersistence = Mock(SubscriptionPersistence) @SpringBean - EventsPublisher<CloudEvent> mockSubscriptionEventOutcomePublisher = Mock(EventsPublisher<CloudEvent>) + EventsPublisher<CloudEvent> mockCmSubscriptionNcmpOutEventPublisher = Mock(EventsPublisher<CloudEvent>) @SpringBean - SubscriptionOutcomeMapper subscriptionOutcomeMapper = Mappers.getMapper(SubscriptionOutcomeMapper) + CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper cmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper = Mappers.getMapper(CmSubscriptionDmiOutEventToCmSubscriptionNcmpOutEventMapper) @SpringBean SubscriptionOutcomeCloudMapper subscriptionOutcomeCloudMapper = new SubscriptionOutcomeCloudMapper(new ObjectMapper()) @@ -60,11 +60,11 @@ class SubscriptionEventResponseOutcomeSpec extends DataNodeBaseSpec { def 'Send response to the client apps successfully'() { given: 'a subscription response event' - def subscriptionResponseJsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, SubscriptionEventResponse.class) + def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionDmiOutEvent.class) and: 'a subscription outcome event' - def subscriptionOutcomeJsonData = TestUtils.getResourceFileContent('avcSubscriptionOutcomeEvent2.json') - def subscriptionOutcomeEvent = jsonObjectMapper.convertJsonString(subscriptionOutcomeJsonData, SubscriptionEventOutcome.class) + def subscriptionOutcomeJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent2.json') + def subscriptionOutcomeEvent = jsonObjectMapper.convertJsonString(subscriptionOutcomeJsonData, CmSubscriptionNcmpOutEvent.class) and: 'a random id for the cloud event' SubscriptionOutcomeCloudMapper.randomId = 'some-id' and: 'a cloud event containing the outcome event' @@ -72,7 +72,7 @@ class SubscriptionEventResponseOutcomeSpec extends DataNodeBaseSpec { .withData(objectMapper.writeValueAsBytes(subscriptionOutcomeEvent)) .withId('some-id') .withType('subscriptionCreatedStatus') - .withDataSchema(URI.create('urn:cps:' + 'org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome' + ':1.0.0')) + .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' @@ -80,21 +80,21 @@ class SubscriptionEventResponseOutcomeSpec extends DataNodeBaseSpec { when: 'the response is being sent' objectUnderTest.sendResponse(subscriptionResponseEvent, 'subscriptionCreatedStatus') then: 'the publisher publish the cloud event with itself and expected parameters' - 1 * mockSubscriptionEventOutcomePublisher.publishCloudEvent('subscription-response', 'SCO-9989752cm-subscription-001', testCloudEventSent) + 1 * mockCmSubscriptionNcmpOutEventPublisher.publishCloudEvent('subscription-response', 'SCO-9989752cm-subscription-001', testCloudEventSent) } def 'Create subscription outcome message as expected'() { given: 'a subscription response event' - def subscriptionResponseJsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, SubscriptionEventResponse.class) + def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionDmiOutEvent.class) and: 'a subscription outcome event' - def subscriptionOutcomeJsonData = TestUtils.getResourceFileContent('avcSubscriptionOutcomeEvent.json') - def subscriptionOutcomeEvent = jsonObjectMapper.convertJsonString(subscriptionOutcomeJsonData, SubscriptionEventOutcome.class) + def subscriptionOutcomeJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json') + def subscriptionOutcomeEvent = jsonObjectMapper.convertJsonString(subscriptionOutcomeJsonData, CmSubscriptionNcmpOutEvent.class) and: 'a status code and status message a per #scenarios' subscriptionOutcomeEvent.getData().setStatusCode(statusCode) subscriptionOutcomeEvent.getData().setStatusMessage(statusMessage) when: 'a subscription event outcome message is being formed' - def result = objectUnderTest.fromSubscriptionEventResponse(subscriptionResponseEvent, ncmpEventResponseCode) + def result = objectUnderTest.fromDmiOutEvent(subscriptionResponseEvent, ncmpEventResponseCode) then: 'the result will be equal to event outcome' result == subscriptionOutcomeEvent where: 'the following values are used' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapperSpec.groovy index ae61749644..4f5d3b19da 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventCloudMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapperSpec.groovy @@ -23,7 +23,8 @@ package org.onap.cps.ncmp.api.impl.utils import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.databind.ObjectMapper import io.cloudevents.core.builder.CloudEventBuilder -import org.onap.cps.ncmp.events.avcsubscription1_0_0.client_to_ncmp.SubscriptionEvent +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.CmSubscriptionDmiInEvent import org.onap.cps.ncmp.utils.TestUtils import org.onap.cps.utils.JsonObjectMapper import org.springframework.beans.factory.annotation.Autowired @@ -31,7 +32,7 @@ import org.springframework.boot.test.context.SpringBootTest import spock.lang.Specification @SpringBootTest(classes = [ObjectMapper, JsonObjectMapper]) -class SubscriptionEventCloudMapperSpec extends Specification { +class CmSubscriptionEventCloudMapperSpec extends Specification { @Autowired JsonObjectMapper jsonObjectMapper @@ -41,12 +42,12 @@ class SubscriptionEventCloudMapperSpec extends Specification { def spyObjectMapper = Spy(ObjectMapper) - def objectUnderTest = new SubscriptionEventCloudMapper(spyObjectMapper) + def objectUnderTest = new CmSubscriptionEventCloudMapper(spyObjectMapper) def 'Map the data of the cloud event to subscription event'() { given: 'a cloud event having a subscription event in the data part' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json') - def testEventData = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json') + def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class) def testCloudEvent = CloudEventBuilder.v1() .withData(objectMapper.writeValueAsBytes(testEventData)) .withId('some-event-id') @@ -54,7 +55,7 @@ class SubscriptionEventCloudMapperSpec extends Specification { .withSource(URI.create('some-resource')) .withExtension('correlationid', 'test-cmhandle1').build() when: 'the cloud event map to subscription event' - def resultSubscriptionEvent = objectUnderTest.toSubscriptionEvent(testCloudEvent) + def resultSubscriptionEvent = objectUnderTest.toCmSubscriptionNcmpInEvent(testCloudEvent) then: 'the subscription event resulted having expected values' resultSubscriptionEvent.getData() == testEventData.getData() } @@ -68,16 +69,16 @@ class SubscriptionEventCloudMapperSpec extends Specification { .withSource(URI.create('some-resource')) .withExtension('correlationid', 'test-cmhandle1').build() when: 'the cloud event map to subscription event' - def resultSubscriptionEvent = objectUnderTest.toSubscriptionEvent(testCloudEvent) + def resultSubscriptionEvent = objectUnderTest.toCmSubscriptionNcmpInEvent(testCloudEvent) then: 'the subscription event resulted having a null value' resultSubscriptionEvent == null } def 'Map the subscription event to data of the cloud event'() { given: 'a subscription event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEventNcmpVersion.json') + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiInEvent.json') def testEventData = jsonObjectMapper.convertJsonString(jsonData, - org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent.class) + CmSubscriptionDmiInEvent.class) def testCloudEvent = CloudEventBuilder.v1() .withData(objectMapper.writeValueAsBytes(testEventData)) .withId('some-id') @@ -85,14 +86,14 @@ class SubscriptionEventCloudMapperSpec extends Specification { .withSource(URI.create('SCO-9989752')) .withExtension('correlationid', 'test-cmhandle1').build() when: 'the subscription event map to data of cloud event' - SubscriptionEventCloudMapper.randomId = 'some-id' + 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.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent:1.0.0') + 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'() { @@ -100,9 +101,9 @@ class SubscriptionEventCloudMapperSpec extends Specification { 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('avcSubscriptionCreationEventNcmpVersion.json') + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiInEvent.json') def testEventData = jsonObjectMapper.convertJsonString(jsonData, - org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_dmi.SubscriptionEvent.class) + 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' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapperSpec.groovy index 9dcd0a6459..89b13e26e5 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionEventResponseCloudMapperSpec.groovy @@ -22,7 +22,7 @@ package org.onap.cps.ncmp.api.impl.utils import com.fasterxml.jackson.databind.ObjectMapper import io.cloudevents.core.builder.CloudEventBuilder -import org.onap.cps.ncmp.events.avcsubscription1_0_0.dmi_to_ncmp.SubscriptionEventResponse +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 @@ -44,8 +44,8 @@ class SubscriptionEventResponseCloudMapperSpec extends Specification { def 'Map the cloud event to subscription event response'() { given: 'a cloud event having a subscription event response in the data part' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionEventResponse.json') - def testEventData = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEventResponse.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json') + def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionDmiOutEvent.class) def testCloudEvent = CloudEventBuilder.v1() .withData(objectMapper.writeValueAsBytes(testEventData)) .withId('some-event-id') @@ -53,7 +53,7 @@ class SubscriptionEventResponseCloudMapperSpec extends Specification { .withSource(URI.create('some-resource')) .withExtension('correlationid', 'test-cmhandle1').build() when: 'the cloud event map to subscription event response' - def resultSubscriptionEvent = objectUnderTest.toSubscriptionEventResponse(testCloudEvent) + def resultSubscriptionEvent = objectUnderTest.toCmSubscriptionDmiOutEvent(testCloudEvent) then: 'the subscription event resulted having expected values' resultSubscriptionEvent.getData() == testEventData.getData() } @@ -67,7 +67,7 @@ class SubscriptionEventResponseCloudMapperSpec extends Specification { .withSource(URI.create('some-resource')) .withExtension('correlationid', 'test-cmhandle1').build() when: 'the cloud event map to subscription event response' - def resultSubscriptionEvent = objectUnderTest.toSubscriptionEventResponse(testCloudEvent) + def resultSubscriptionEvent = objectUnderTest.toCmSubscriptionDmiOutEvent(testCloudEvent) then: 'the subscription event response resulted having a null value' resultSubscriptionEvent == null } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy index ac055b5f6e..d5670eb40d 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy @@ -23,7 +23,7 @@ package org.onap.cps.ncmp.api.impl.utils import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.databind.ObjectMapper import io.cloudevents.core.builder.CloudEventBuilder -import org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome +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 @@ -45,8 +45,8 @@ class SubscriptionOutcomeCloudMapperSpec extends Specification { def 'Map the subscription outcome to cloud event'() { given: 'a subscription event' - def jsonData = TestUtils.getResourceFileContent('avcSubscriptionOutcomeEvent.json') - def testEventData = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEventOutcome.class) + def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json') + def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class) def testCloudEvent = CloudEventBuilder.v1() .withData(objectMapper.writeValueAsBytes(testEventData)) .withId('some-id') @@ -61,7 +61,7 @@ class SubscriptionOutcomeCloudMapperSpec extends Specification { resultCloudEvent.getId() == testCloudEvent.getId() resultCloudEvent.getType() == testCloudEvent.getType() resultCloudEvent.getSource() == testCloudEvent.getSource() - resultCloudEvent.getDataSchema() == URI.create('urn:cps:org.onap.cps.ncmp.events.avcsubscription1_0_0.ncmp_to_client.SubscriptionEventOutcome:1.0.0') + 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'() { @@ -69,8 +69,8 @@ class SubscriptionOutcomeCloudMapperSpec extends Specification { 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('avcSubscriptionOutcomeEvent.json') - def testEventData = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEventOutcome.class) + def jsonData = TestUtils.getResourceFileContent('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' diff --git a/cps-ncmp-service/src/test/resources/avcSubscriptionCreationEventNcmpVersion.json b/cps-ncmp-service/src/test/resources/cmSubscriptionDmiInEvent.json index f31362a1c6..f31362a1c6 100644 --- a/cps-ncmp-service/src/test/resources/avcSubscriptionCreationEventNcmpVersion.json +++ b/cps-ncmp-service/src/test/resources/cmSubscriptionDmiInEvent.json diff --git a/cps-ncmp-service/src/test/resources/avcSubscriptionEventResponse.json b/cps-ncmp-service/src/test/resources/cmSubscriptionDmiOutEvent.json index dfe8f50466..dfe8f50466 100644 --- a/cps-ncmp-service/src/test/resources/avcSubscriptionEventResponse.json +++ b/cps-ncmp-service/src/test/resources/cmSubscriptionDmiOutEvent.json diff --git a/cps-ncmp-service/src/test/resources/avcSubscriptionCreationEvent.json b/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpInEvent.json index 803fa48bdf..803fa48bdf 100644 --- a/cps-ncmp-service/src/test/resources/avcSubscriptionCreationEvent.json +++ b/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpInEvent.json diff --git a/cps-ncmp-service/src/test/resources/avcSubscriptionOutcomeEvent.json b/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent.json index 14e8cbb4c4..14e8cbb4c4 100644 --- a/cps-ncmp-service/src/test/resources/avcSubscriptionOutcomeEvent.json +++ b/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent.json diff --git a/cps-ncmp-service/src/test/resources/avcSubscriptionOutcomeEvent2.json b/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent2.json index 35ff0241df..35ff0241df 100644 --- a/cps-ncmp-service/src/test/resources/avcSubscriptionOutcomeEvent2.json +++ b/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent2.json |