diff options
author | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-07-31 17:19:19 +0100 |
---|---|---|
committer | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-08-02 10:20:00 +0100 |
commit | b0c7b0e43956ef48011c95b2689578acbfd9282f (patch) | |
tree | 583dd9eaf86bb2217fe38f2e261b2ef7d73db4b8 /cps-ncmp-service | |
parent | 81bf6fb1badc3c41d41c501330bc2a462f20c786 (diff) |
Updating CM Data Notification Event Schema
- Updated "avc-event-schema" value attribute to accept type object.
- Modified cm avc event consumer to not wrap received event into another cloud event using "CloudEventBuilder.from"
Issue-ID: CPS-2299
Change-Id: I3b2acd53a3939d992b337e98debb7f62f3a528dd
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ncmp-service')
3 files changed, 7 insertions, 16 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumer.java index 0207fb90e3..9e90eabbc4 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumer.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumer.java @@ -21,8 +21,6 @@ package org.onap.cps.ncmp.impl.cmnotificationsubscription.cmavc; import io.cloudevents.CloudEvent; -import io.cloudevents.core.builder.CloudEventBuilder; -import java.util.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.kafka.clients.consumer.ConsumerRecord; @@ -56,11 +54,8 @@ public class CmAvcEventConsumer { containerFactory = "cloudEventConcurrentKafkaListenerContainerFactory") public void consumeAndForward( final ConsumerRecord<String, CloudEvent> cmAvcEventAsConsumerRecord) { - log.debug("Consuming AVC event {} ...", cmAvcEventAsConsumerRecord.value()); - final String newEventId = UUID.randomUUID().toString(); - final CloudEvent outgoingAvcEvent = - CloudEventBuilder.from(cmAvcEventAsConsumerRecord.value()).withId(newEventId) - .build(); - eventsPublisher.publishCloudEvent(cmEventsTopicName, newEventId, outgoingAvcEvent); + final CloudEvent outgoingAvcEvent = cmAvcEventAsConsumerRecord.value(); + log.debug("Consuming AVC event {} ...", outgoingAvcEvent); + eventsPublisher.publishCloudEvent(cmEventsTopicName, outgoingAvcEvent.getId(), outgoingAvcEvent); } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumerSpec.groovy index a8b5250edf..06651be913 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumerSpec.groovy @@ -37,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.annotation.DirtiesContext import org.testcontainers.spock.Testcontainers - import java.time.Duration import static org.onap.cps.ncmp.utils.events.CloudEventMapper.toTargetEvent @@ -86,8 +85,8 @@ class CmAvcEventConsumerSpec extends MessagingBaseSpec { def convertedAvcEvent = toTargetEvent(cloudEvent, AvcEvent.class) and: 'we have correct headers forwarded where correlation id matches' assert KafkaHeaders.getParsedKafkaHeader(record.headers(), 'ce_correlationid') == 'test-cmhandle1' - and: 'event id differs(as per requirement) between consumed and forwarded' - assert KafkaHeaders.getParsedKafkaHeader(record.headers(), 'ce_id') != 'sample-eventid' + and: 'event id is same between consumed and forwarded' + assert KafkaHeaders.getParsedKafkaHeader(record.headers(), 'ce_id') == 'sample-eventid' and: 'the event payload still matches' assert testEventSent == convertedAvcEvent } diff --git a/cps-ncmp-service/src/test/resources/sampleAvcInputEvent.json b/cps-ncmp-service/src/test/resources/sampleAvcInputEvent.json index 5b297c86c2..1dc14bd65e 100644 --- a/cps-ncmp-service/src/test/resources/sampleAvcInputEvent.json +++ b/cps-ncmp-service/src/test/resources/sampleAvcInputEvent.json @@ -10,11 +10,8 @@ "operation":"replace", "target":"ran-network:ran-network/NearRTRIC[@id='22']/GNBCUCPFunction[@id='cucpserver2']/NRCellCU[@id='15549']/NRCellRelation[@id='14427']", "value":{ - "attributes":[ - { - "isHoAllowed":true - } - ] + "color": "yellow", + "name": "Apple" } }, { |