diff options
author | Lee Anjella Macabuhay <lee.anjella.macabuhay@est.tech> | 2024-05-28 14:19:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-05-28 14:19:38 +0000 |
commit | 8ec8bc27176da9c85d5d205d9c40dce2c1591036 (patch) | |
tree | 0f729978f56555a5c8c0a3c65ec3c08a2b29aedd | |
parent | 190c30c687cb5506fed6e27bfa623fa2747386bb (diff) | |
parent | e3ac8892ef9707e5cb22a158592be0c715d19aa4 (diff) |
Merge "DMI CmSubscription topic params update"
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")) |