summaryrefslogtreecommitdiffstats
path: root/dmi-service/src/test/groovy/org
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2024-09-06 10:44:47 +0100
committermpriyank <priyank.maheshwari@est.tech>2024-09-06 10:44:54 +0100
commit204c4e90c58aae5b72aa4085265be8dd8fc6a57c (patch)
tree0b8fa6e42a4306a12051d4120c8c5ffb0e6f5580 /dmi-service/src/test/groovy/org
parent77fd08845b489fb7880b2c51e62a3548c4b0a947 (diff)
Update cps version in DMI plugin
- updated cps version to 3.5.2 i.e the latest released version - updated corresponding dependant code from cps ncmp - Fixed the testware Issue-ID: CPS-2401 Change-Id: I8c3ed7cbdef11a195b86088006fd0e1e7642a572 Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'dmi-service/src/test/groovy/org')
-rw-r--r--dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiInEventConsumerSpec.groovy (renamed from dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy)33
-rw-r--r--dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiOutEventToCloudEventMapperSpec.groovy (renamed from dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiOutEventToCloudEventMapperSpec.groovy)16
-rw-r--r--dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/mapper/CloudEventMapperSpec.groovy6
3 files changed, 27 insertions, 28 deletions
diff --git a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiInEventConsumerSpec.groovy
index f1f476f6..52fa3794 100644
--- a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy
+++ b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiInEventConsumerSpec.groovy
@@ -32,12 +32,11 @@ import org.onap.cps.ncmp.dmi.TestUtils
import org.onap.cps.ncmp.dmi.api.kafka.MessagingBaseSpec
import org.onap.cps.ncmp.dmi.notifications.cmsubscription.model.CmNotificationSubscriptionStatus
import org.onap.cps.ncmp.dmi.notifications.mapper.CloudEventMapper
-import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.CmNotificationSubscriptionDmiOutEvent
-import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.Data
-import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.ncmp_to_dmi.CmNotificationSubscriptionDmiInEvent
+import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.Data
+import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.DmiOutEvent
+import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.ncmp_to_dmi.DmiInEvent
import org.slf4j.LoggerFactory
import org.spockframework.spring.SpringBean
-import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.annotation.DirtiesContext
import org.testcontainers.spock.Testcontainers
@@ -49,13 +48,13 @@ import java.time.ZoneId
@Testcontainers
@DirtiesContext
-class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec {
+class DmiInEventConsumerSpec extends MessagingBaseSpec {
def objectMapper = new ObjectMapper()
def testTopic = 'dmi-ncmp-cm-avc-subscription'
def testDmiName = 'test-ncmp-dmi'
@SpringBean
- CmNotificationSubscriptionDmiInEventConsumer objectUnderTest = new CmNotificationSubscriptionDmiInEventConsumer(cloudEventKafkaTemplate)
+ DmiInEventConsumer objectUnderTest = new DmiInEventConsumer(cloudEventKafkaTemplate)
def logger = Spy(ListAppender<ILoggingEvent>)
@@ -71,11 +70,11 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
def 'Sends subscription cloud event response successfully.'() {
given: 'an subscription event response'
objectUnderTest.dmiName = testDmiName
- objectUnderTest.cmNotificationSubscriptionDmiOutTopic = testTopic
+ objectUnderTest.dmoOutEventTopic = testTopic
def correlationId = 'test-subscriptionId#test-ncmp-dmi'
def cmSubscriptionDmiOutEventData = new Data(statusCode: subscriptionStatusCode, statusMessage: subscriptionStatusMessage)
def subscriptionEventResponse =
- new CmNotificationSubscriptionDmiOutEvent().withData(cmSubscriptionDmiOutEventData)
+ new DmiOutEvent().withData(cmSubscriptionDmiOutEventData)
and: 'consumer has a subscription'
kafkaConsumer.subscribe([testTopic] as List<String>)
when: 'an event is published'
@@ -92,9 +91,9 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
assert expectedValue == record.value
assert eventKey == record.key
where: 'given #scenario'
- scenario | subscriptionAcceptanceType | subscriptionStatusCode | subscriptionStatusMessage
- 'Subscription is Accepted' | CmNotificationSubscriptionStatus.ACCEPTED | '1' | 'ACCEPTED'
- 'Subscription is Rejected' | CmNotificationSubscriptionStatus.REJECTED | '104' | 'REJECTED'
+ scenario | subscriptionAcceptanceType | subscriptionStatusCode | subscriptionStatusMessage
+ 'Subscription is Accepted' | CmNotificationSubscriptionStatus.ACCEPTED | '1' | 'ACCEPTED'
+ 'Subscription is Rejected' | CmNotificationSubscriptionStatus.REJECTED | '104' | 'REJECTED'
}
def 'Consume valid message.'() {
@@ -103,17 +102,17 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
def eventKey = UUID.randomUUID().toString()
def timestamp = new Timestamp(1679521929511)
def jsonData = TestUtils.getResourceFileContent('cmNotificationSubscriptionCreationEvent.json')
- def subscriptionEvent = objectMapper.readValue(jsonData, CmNotificationSubscriptionDmiInEvent.class)
- objectUnderTest.cmNotificationSubscriptionDmiOutTopic = testTopic
+ def subscriptionEvent = objectMapper.readValue(jsonData, DmiInEvent.class)
+ objectUnderTest.dmoOutEventTopic = testTopic
def cloudEvent = CloudEventBuilder.v1().withId(UUID.randomUUID().toString()).withSource(URI.create('test-ncmp-dmi'))
.withType(subscriptionType)
- .withDataSchema(URI.create("urn:cps:" + CmNotificationSubscriptionDmiInEvent.class.getName() + ":1.0.0"))
+ .withDataSchema(URI.create("urn:cps:" + DmiInEvent.class.getName() + ":1.0.0"))
.withExtension("correlationid", eventKey)
.withTime(OffsetDateTime.ofInstant(timestamp.toInstant(), ZoneId.of("UTC")))
.withData(objectMapper.writeValueAsBytes(subscriptionEvent)).build()
def testEventSent = new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, eventKey, cloudEvent)
when: 'the valid event is consumed'
- objectUnderTest.consumeCmNotificationSubscriptionDmiInEvent(testEventSent)
+ objectUnderTest.consumeDmiInEvent(testEventSent)
then: 'no exception is thrown'
noExceptionThrown()
where: 'given #scenario'
@@ -128,7 +127,7 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
def eventKey = UUID.randomUUID().toString()
def timestamp = new Timestamp(1679521929511)
def invalidJsonBody = "/////"
- objectUnderTest.cmNotificationSubscriptionDmiOutTopic = testTopic
+ objectUnderTest.dmoOutEventTopic = testTopic
def cloudEvent = CloudEventBuilder.v1().withId(UUID.randomUUID().toString()).withSource(URI.create('test-ncmp-dmi'))
.withType("subscriptionCreated")
.withDataSchema(URI.create("urn:cps:org.onap.ncmp.dmi.cm.subscription:1.0.0"))
@@ -136,7 +135,7 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
.withExtension("correlationid", eventKey).withData(objectMapper.writeValueAsBytes(invalidJsonBody)).build()
def testEventSent = new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, eventKey, cloudEvent)
when: 'the invalid event is consumed'
- objectUnderTest.consumeCmNotificationSubscriptionDmiInEvent(testEventSent)
+ objectUnderTest.consumeDmiInEvent(testEventSent)
then: 'exception is thrown and event is logged'
def loggingEvent = getLoggingEvent()
assert loggingEvent.level == Level.ERROR
diff --git a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiOutEventToCloudEventMapperSpec.groovy b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiOutEventToCloudEventMapperSpec.groovy
index 8ca629f1..95ac93f0 100644
--- a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiOutEventToCloudEventMapperSpec.groovy
+++ b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/DmiOutEventToCloudEventMapperSpec.groovy
@@ -23,21 +23,21 @@ package org.onap.cps.ncmp.dmi.notifications.cmsubscription
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.core.builder.CloudEventBuilder
import org.onap.cps.ncmp.dmi.exception.CloudEventConstructionException
-import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.CmNotificationSubscriptionDmiOutEvent
-import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.dmi_to_ncmp.Data
+import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.Data
+import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.dmi_to_ncmp.DmiOutEvent
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import spock.lang.Specification
@SpringBootTest(classes = [ObjectMapper])
-class CmNotificationSubscriptionDmiOutEventToCloudEventMapperSpec extends Specification {
+class DmiOutEventToCloudEventMapperSpec extends Specification {
@Autowired
def objectMapper = new ObjectMapper()
@SpringBean
- CmNotificationSubscriptionDmiOutEventToCloudEventMapper objectUnderTest = new CmNotificationSubscriptionDmiOutEventToCloudEventMapper()
+ DmiOutEventToCloudEventMapper objectUnderTest = new DmiOutEventToCloudEventMapper()
def 'Convert a Cm Subscription DMI Out Event to CloudEvent successfully.'() {
given: 'a Cm Subscription DMI Out Event and an event key'
@@ -45,13 +45,13 @@ class CmNotificationSubscriptionDmiOutEventToCloudEventMapperSpec extends Specif
def correlationId = 'subscription1#test-ncmp-dmi'
def cmSubscriptionDmiOutEventData = new Data(statusCode: "1", statusMessage: "accepted")
def cmSubscriptionDmiOutEvent =
- new CmNotificationSubscriptionDmiOutEvent().withData(cmSubscriptionDmiOutEventData)
+ new DmiOutEvent().withData(cmSubscriptionDmiOutEventData)
when: 'a Cm Subscription DMI Out Event is converted'
def result = objectUnderTest.toCloudEvent(cmSubscriptionDmiOutEvent, "subscriptionCreatedStatus", dmiName, correlationId)
then: 'Cm Subscription DMI Out Event is converted as expected'
def expectedCloudEvent = CloudEventBuilder.v1().withId(UUID.randomUUID().toString()).withSource(URI.create('test-ncmp-dmi'))
.withType("subscriptionCreated")
- .withDataSchema(URI.create("urn:cps:" + CmNotificationSubscriptionDmiOutEvent.class.getName() + ":1.0.0"))
+ .withDataSchema(URI.create("urn:cps:" + DmiOutEvent.class.getName() + ":1.0.0"))
.withExtension("correlationid", correlationId)
.withData(objectMapper.writeValueAsBytes(cmSubscriptionDmiOutEvent)).build()
assert expectedCloudEvent.data == result.data
@@ -60,9 +60,9 @@ class CmNotificationSubscriptionDmiOutEventToCloudEventMapperSpec extends Specif
def 'Map the Cloud Event to data of the subscription event with null parameters causes an exception'() {
given: 'an empty subscription response event and event key'
def correlationId = 'subscription1#test-ncmp-dmi'
- def cmSubscriptionDmiOutEvent = new CmNotificationSubscriptionDmiOutEvent()
+ def dmiOutEvent = new DmiOutEvent()
when: 'the cm subscription dmi out Event map to data of cloud event'
- objectUnderTest.toCloudEvent(cmSubscriptionDmiOutEvent, "subscriptionCreatedStatus", null , correlationId)
+ objectUnderTest.toCloudEvent(dmiOutEvent, "subscriptionCreatedStatus", null , correlationId)
then: 'a run time exception is thrown'
thrown(CloudEventConstructionException)
}
diff --git a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/mapper/CloudEventMapperSpec.groovy b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/mapper/CloudEventMapperSpec.groovy
index 0b404776..7393b669 100644
--- a/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/mapper/CloudEventMapperSpec.groovy
+++ b/dmi-service/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/mapper/CloudEventMapperSpec.groovy
@@ -22,7 +22,7 @@ package org.onap.cps.ncmp.dmi.notifications.mapper
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.core.builder.CloudEventBuilder
-import org.onap.cps.ncmp.events.cmnotificationsubscription_merge1_0_0.client_to_ncmp.CmNotificationSubscriptionNcmpInEvent
+import org.onap.cps.ncmp.impl.cmnotificationsubscription_1_0_0.client_to_ncmp.NcmpInEvent
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import spock.lang.Specification
@@ -38,12 +38,12 @@ class CloudEventMapperSpec extends Specification {
assert mappedCloudEvent == (CloudEventMapper.toTargetEvent(testCloudEvent(), targetClass) != null)
where: 'below are the scenarios'
scenario | targetClass || mappedCloudEvent
- 'valid concrete type' | CmNotificationSubscriptionNcmpInEvent.class || true
+ 'valid concrete type' | NcmpInEvent.class || true
'invalid concrete type' | ArrayList.class || false
}
def testCloudEvent() {
- return CloudEventBuilder.v1().withData(objectMapper.writeValueAsBytes(new CmNotificationSubscriptionNcmpInEvent()))
+ return CloudEventBuilder.v1().withData(objectMapper.writeValueAsBytes(new NcmpInEvent()))
.withId("cmhandle1")
.withSource(URI.create('test-source'))
.withDataSchema(URI.create('test'))