aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Gleeson <luke.gleeson@est.tech>2023-03-22 10:27:39 +0000
committerGerrit Code Review <gerrit@onap.org>2023-03-22 10:27:39 +0000
commit3b72dbb767aae4d0c53ada2d82d9dfa0a0d76597 (patch)
tree9c913d0e7c8b9d81059e45a02b25e48ea770f889
parent3371266a2cc5e23e8189f0dbc3f64bac31d4d441 (diff)
parentbdf609572b2a62df00e044f4bae38e4c6c8ce4e7 (diff)
Merge "Add event to mapper as well"
-rw-r--r--cps-application/src/main/resources/application.yml1
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventMapper.java1
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducer.java8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducerIntegrationSpec.groovy6
-rw-r--r--cps-ncmp-service/src/test/resources/application.yml1
5 files changed, 13 insertions, 4 deletions
diff --git a/cps-application/src/main/resources/application.yml b/cps-application/src/main/resources/application.yml
index 02902de68..0007bc824 100644
--- a/cps-application/src/main/resources/application.yml
+++ b/cps-application/src/main/resources/application.yml
@@ -99,6 +99,7 @@ app:
topic: ${NCMP_ASYNC_M2M_TOPIC:ncmp-async-m2m}
avc:
subscription-topic: ${NCMP_CM_AVC_SUBSCRIPTION:cm-avc-subscription}
+ cm-events-topic: ${NCMP_CM_EVENTS_TOPIC:cm-events}
lcm:
events:
topic: ${LCM_EVENTS_TOPIC:ncmp-events}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventMapper.java
index b6dc46777..aaa06c665 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventMapper.java
@@ -40,6 +40,7 @@ public interface AvcEventMapper {
@Mapping(source = "eventSchemaVersion", target = "eventSchemaVersion")
@Mapping(source = "eventSource", target = "eventSource")
@Mapping(source = "eventType", target = "eventType")
+ @Mapping(source = "event", target = "event")
AvcEvent toOutgoingAvcEvent(AvcEvent incomingAvcEvent);
@Named("avcEventId")
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducer.java
index 049f66100..b8fe730a1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducer.java
@@ -23,6 +23,7 @@ package org.onap.cps.ncmp.api.impl.notifications.avc;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.event.model.AvcEvent;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
@@ -38,6 +39,9 @@ public class AvcEventProducer {
private final AvcEventMapper avcEventMapper;
+ @Value("${app.ncmp.avc.cm-events-topic}")
+ private String cmEventsTopic;
+
/**
* Sends message to the configured topic with a message key.
*
@@ -46,7 +50,7 @@ public class AvcEventProducer {
public void sendMessage(final AvcEvent incomingAvcEvent) {
// generate new event id while keeping other data
final AvcEvent outgoingAvcEvent = avcEventMapper.toOutgoingAvcEvent(incomingAvcEvent);
- log.debug("Forwarding AVC event {} to topic {} ", outgoingAvcEvent.getEventId(), "cm-events");
- kafkaTemplate.send("cm-events", outgoingAvcEvent.getEventId(), outgoingAvcEvent);
+ log.debug("Forwarding AVC event {} to topic {} ", outgoingAvcEvent.getEventId(), cmEventsTopic);
+ kafkaTemplate.send(cmEventsTopic, outgoingAvcEvent.getEventId(), outgoingAvcEvent);
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducerIntegrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducerIntegrationSpec.groovy
index 744737080..a251ecbf0 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducerIntegrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/notifications/avc/AvcEventProducerIntegrationSpec.groovy
@@ -56,8 +56,10 @@ class AvcEventProducerIntegrationSpec extends MessagingBaseSpec {
def kafkaConsumer = new KafkaConsumer<>(consumerConfigProperties('ncmp-group'))
def 'Consume and forward valid message'() {
- given: 'consumer has a subscription'
- kafkaConsumer.subscribe(['cm-events'] as List<String>)
+ given: 'consumer has a subscription on a topic'
+ def cmEventsTopic = 'cm-events'
+ avcEventProducer.cmEventsTopic = cmEventsTopic
+ kafkaConsumer.subscribe([cmEventsTopic] as List<String>)
and: 'an event is sent'
def jsonData = TestUtils.getResourceFileContent('sampleAvcInputEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, AvcEvent.class)
diff --git a/cps-ncmp-service/src/test/resources/application.yml b/cps-ncmp-service/src/test/resources/application.yml
index b7dfe86c1..e66f23d23 100644
--- a/cps-ncmp-service/src/test/resources/application.yml
+++ b/cps-ncmp-service/src/test/resources/application.yml
@@ -20,6 +20,7 @@ app:
ncmp:
avc:
subscription-topic: cm-avc-subscription
+ cm-events-topic: cm-events
ncmp:
dmi: