Updating CM Data Notification Event Schema 07/138607/4
authorsourabh_sourabh <sourabh.sourabh@est.tech>
Wed, 31 Jul 2024 16:19:19 +0000 (17:19 +0100)
committersourabh_sourabh <sourabh.sourabh@est.tech>
Fri, 2 Aug 2024 09:20:00 +0000 (10:20 +0100)
- 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>
cps-ncmp-events/src/main/resources/schemas/dmidataavc/avc-event-schema-1.0.0.json
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumer.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/cmavc/CmAvcEventConsumerSpec.groovy
cps-ncmp-service/src/test/resources/sampleAvcInputEvent.json

index a5bed93..474520d 100644 (file)
@@ -16,7 +16,8 @@
           "type": "string"
         },
         "value": {
-          "$ref": "#/definitions/Value"
+          "type": "object",
+          "existingJavaType": "java.lang.Object"
         }
       },
       "required": [
         "target"
       ]
     },
-    "Value": {
-      "type": "object",
-      "additionalProperties": false,
-      "properties": {
-        "attributes": {
-          "type": "array",
-          "items": {
-            "type": "object",
-            "existingJavaType": "java.util.Map<String,Object>",
-            "additionalProperties": false,
-            "properties": {
-              "isHoAllowed": {
-                "type": "boolean"
-              }
-            }
-          }
-        }
-      }
-    },
     "AvcEvent": {
       "description": "The payload for AVC event.",
       "type": "object",
index 0207fb9..9e90eab 100644 (file)
@@ -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);
     }
 }
index a8b5250..06651be 100644 (file)
@@ -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
     }
index 5b297c8..1dc14bd 100644 (file)
               "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"
               }
             },
             {