Replace event-id with correlation-id for data read operation cloud event 83/135783/1
authorsourabh_sourabh <sourabh.sourabh@est.tech>
Mon, 21 Aug 2023 14:52:52 +0000 (15:52 +0100)
committersourabh_sourabh <sourabh.sourabh@est.tech>
Mon, 21 Aug 2023 14:52:52 +0000 (15:52 +0100)
- Modified data operation event consumer to send correlation-id instead
  if event-id while publishing cloud event to client topic.

Issue-ID: CPS-1842
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Change-Id: I30738b90d2ff0d14b5ee0bac680eff834aa968bf

cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/async/DataOperationEventConsumer.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/SerializationIntegrationSpec.groovy

index 9649b01..0bc1807 100644 (file)
@@ -56,8 +56,8 @@ public class DataOperationEventConsumer {
         log.info("Consuming event payload {} ...", dataOperationEventConsumerRecord.value());
         final String eventTarget = KafkaHeaders.getParsedKafkaHeader(
                 dataOperationEventConsumerRecord.headers(), "ce_destination");
-        final String eventId = KafkaHeaders.getParsedKafkaHeader(
-                dataOperationEventConsumerRecord.headers(), "ce_id");
-        eventsPublisher.publishCloudEvent(eventTarget, eventId, dataOperationEventConsumerRecord.value());
+        final String correlationId = KafkaHeaders.getParsedKafkaHeader(
+                dataOperationEventConsumerRecord.headers(), "ce_correlationid");
+        eventsPublisher.publishCloudEvent(eventTarget, correlationId, dataOperationEventConsumerRecord.value());
     }
 }
index 14ecd92..f24ff62 100644 (file)
@@ -68,7 +68,7 @@ class SerializationIntegrationSpec extends ConsumerBaseSpec {
         and: 'wait a little for async processing of message'
             TimeUnit.MILLISECONDS.sleep(300)
         then: 'the event has been forwarded'
-            1 * mockEventsPublisher.publishCloudEvent('some client topic', 'my-event-id', _) >> { args -> { capturedForwardedEvent = args[2] } }
+            1 * mockEventsPublisher.publishCloudEvent('some client topic', 'some-correlation-id', _) >> { args -> { capturedForwardedEvent = args[2] } }
         and: 'the forwarded event is identical to the event that was sent'
             assert capturedForwardedEvent == cloudEvent
     }
@@ -94,6 +94,7 @@ class SerializationIntegrationSpec extends ConsumerBaseSpec {
             .withType('DataOperationEvent')
             .withSource(URI.create('some-source'))
             .withExtension('destination','some client topic')
+            .withExtension('correlationid','some-correlation-id')
             .withData(objectMapper.writeValueAsBytes(dataOperationEvent))
             .build()
     }