summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseanbeirne <sean.beirne@est.tech>2024-05-24 15:51:02 +0100
committerseanbeirne <sean.beirne@est.tech>2024-05-27 14:54:22 +0100
commite3ac8892ef9707e5cb22a158592be0c715d19aa4 (patch)
treec4833f03d6ac12543376ee73625783d43d263d66
parent2a83a1ea0fc341225829915078308fca2a39d646 (diff)
DMI CmSubscription topic params update
Issue-ID: CPS-2242 Change-Id: I4628e28a14bab7b15c615d13d6aea7ae97409f5a Signed-off-by: seanbeirne <sean.beirne@est.tech>
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java14
-rw-r--r--src/main/resources/application.yml6
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy16
3 files changed, 18 insertions, 18 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java b/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java
index da6243ca..3a9838b0 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumer.java
@@ -38,8 +38,8 @@ import org.springframework.stereotype.Service;
public class CmNotificationSubscriptionDmiInEventConsumer {
- @Value("${app.dmi.avc.subscription-response-topic}")
- private String cmNotificationSubscriptionResponseTopic;
+ @Value("${app.dmi.avc.cm-subscription-dmi-out}")
+ private String cmNotificationSubscriptionDmiOutTopic;
@Value("${dmi.service.name}")
private String dmiName;
private final KafkaTemplate<String, CloudEvent> cloudEventKafkaTemplate;
@@ -49,7 +49,7 @@ public class CmNotificationSubscriptionDmiInEventConsumer {
*
* @param cmNotificationSubscriptionDmiInCloudEvent the event to be consumed
*/
- @KafkaListener(topics = "${app.dmi.avc.subscription-topic}",
+ @KafkaListener(topics = "${app.dmi.avc.cm-subscription-dmi-in}",
containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory")
public void consumeCmNotificationSubscriptionDmiInEvent(
final ConsumerRecord<String, CloudEvent> cmNotificationSubscriptionDmiInCloudEvent) {
@@ -62,10 +62,10 @@ public class CmNotificationSubscriptionDmiInEventConsumer {
final String correlationId = String.valueOf(cmNotificationSubscriptionDmiInCloudEvent.value()
.getExtension("correlationid"));
- if ("subscriptionCreated".equals(subscriptionType)) {
+ if ("subscriptionCreateRequest".equals(subscriptionType)) {
createAndSendCmNotificationSubscriptionDmiOutEvent(subscriptionId, "subscriptionCreateResponse",
correlationId, CmNotificationSubscriptionStatus.ACCEPTED);
- } else if ("subscriptionDeleted".equals(subscriptionType)) {
+ } else if ("subscriptionDeleteRequest".equals(subscriptionType)) {
createAndSendCmNotificationSubscriptionDmiOutEvent(subscriptionId, "subscriptionDeleteResponse",
correlationId, CmNotificationSubscriptionStatus.ACCEPTED);
}
@@ -92,12 +92,12 @@ public class CmNotificationSubscriptionDmiInEventConsumer {
cmNotificationSubscriptionDmiOutEventData.setStatusCode("1");
cmNotificationSubscriptionDmiOutEventData.setStatusMessage("ACCEPTED");
} else {
- cmNotificationSubscriptionDmiOutEventData.setStatusCode("2");
+ cmNotificationSubscriptionDmiOutEventData.setStatusCode("104");
cmNotificationSubscriptionDmiOutEventData.setStatusMessage("REJECTED");
}
cmNotificationSubscriptionDmiOutEvent.setData(cmNotificationSubscriptionDmiOutEventData);
- cloudEventKafkaTemplate.send(cmNotificationSubscriptionResponseTopic, eventKey,
+ cloudEventKafkaTemplate.send(cmNotificationSubscriptionDmiOutTopic, eventKey,
CmNotificationSubscriptionDmiOutEventToCloudEventMapper.toCloudEvent(cmNotificationSubscriptionDmiOutEvent,
subscriptionType, dmiName, correlationId));
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 732f46db..003aa191 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2021-2023 Nordix Foundation
+# Copyright (C) 2021-2024 Nordix Foundation
# Modifications Copyright (C) 2021 Bell Canada.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -72,8 +72,8 @@ app:
topic: ${NCMP_ASYNC_M2M_TOPIC:ncmp-async-m2m}
dmi:
avc:
- subscription-topic: ${DMI_CM_AVC_SUBSCRIPTION:ncmp-dmi-cm-avc-subscription-${dmi.service.name}}
- subscription-response-topic: ${DMI_CM_AVC_SUBSCRIPTION_RESPONSE:dmi-ncmp-cm-avc-subscription}
+ cm-subscription-dmi-in: ${CM_SUBSCRIPTION_DMI_IN_TOPIC:ncmp-dmi-cm-avc-subscription}
+ cm-subscription-dmi-out: ${CM_SUBSCRIPTION_DMI_OUT_TOPIC:dmi-ncmp-cm-avc-subscription}
notification:
async:
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy
index aa331c4b..f1f476f6 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/notifications/cmsubscription/CmNotificationSubscriptionDmiInEventConsumerSpec.groovy
@@ -47,12 +47,12 @@ import java.time.OffsetDateTime
import java.time.ZoneId
-@SpringBootTest(classes = [CmNotificationSubscriptionDmiInEventConsumer])
@Testcontainers
@DirtiesContext
class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec {
def objectMapper = new ObjectMapper()
def testTopic = 'dmi-ncmp-cm-avc-subscription'
+ def testDmiName = 'test-ncmp-dmi'
@SpringBean
CmNotificationSubscriptionDmiInEventConsumer objectUnderTest = new CmNotificationSubscriptionDmiInEventConsumer(cloudEventKafkaTemplate)
@@ -70,8 +70,8 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
def 'Sends subscription cloud event response successfully.'() {
given: 'an subscription event response'
- objectUnderTest.dmiName = 'test-ncmp-dmi'
- objectUnderTest.cmNotificationSubscriptionResponseTopic = testTopic
+ objectUnderTest.dmiName = testDmiName
+ objectUnderTest.cmNotificationSubscriptionDmiOutTopic = testTopic
def correlationId = 'test-subscriptionId#test-ncmp-dmi'
def cmSubscriptionDmiOutEventData = new Data(statusCode: subscriptionStatusCode, statusMessage: subscriptionStatusMessage)
def subscriptionEventResponse =
@@ -94,17 +94,17 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
where: 'given #scenario'
scenario | subscriptionAcceptanceType | subscriptionStatusCode | subscriptionStatusMessage
'Subscription is Accepted' | CmNotificationSubscriptionStatus.ACCEPTED | '1' | 'ACCEPTED'
- 'Subscription is Rejected' | CmNotificationSubscriptionStatus.REJECTED | '2' | 'REJECTED'
+ 'Subscription is Rejected' | CmNotificationSubscriptionStatus.REJECTED | '104' | 'REJECTED'
}
def 'Consume valid message.'() {
given: 'an event'
- objectUnderTest.dmiName = 'test-ncmp-dmi'
+ objectUnderTest.dmiName = testDmiName
def eventKey = UUID.randomUUID().toString()
def timestamp = new Timestamp(1679521929511)
def jsonData = TestUtils.getResourceFileContent('cmNotificationSubscriptionCreationEvent.json')
def subscriptionEvent = objectMapper.readValue(jsonData, CmNotificationSubscriptionDmiInEvent.class)
- objectUnderTest.cmNotificationSubscriptionResponseTopic = testTopic
+ objectUnderTest.cmNotificationSubscriptionDmiOutTopic = 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"))
@@ -124,11 +124,11 @@ class CmNotificationSubscriptionDmiInEventConsumerSpec extends MessagingBaseSpec
def 'Consume invalid message.'() {
given: 'an invalid event body'
- objectUnderTest.dmiName = 'test-ncmp-dmi'
+ objectUnderTest.dmiName = testDmiName
def eventKey = UUID.randomUUID().toString()
def timestamp = new Timestamp(1679521929511)
def invalidJsonBody = "/////"
- objectUnderTest.cmNotificationSubscriptionResponseTopic = testTopic
+ objectUnderTest.cmNotificationSubscriptionDmiOutTopic = 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"))