Handle duplicate targets NcmpOut event 09/138609/1
authormpriyank <priyank.maheshwari@est.tech>
Wed, 31 Jul 2024 15:29:01 +0000 (16:29 +0100)
committermpriyank <priyank.maheshwari@est.tech>
Wed, 31 Jul 2024 15:29:05 +0000 (16:29 +0100)
- Accpted , Rejected and Pending targets in the NcmpOut response to have
  unique values hence changing the datastructre to Set.

Issue-ID: CPS-2338
Change-Id: I24a109fad4c854eff1b052df38947cc121445bb9
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
cps-ncmp-events/src/main/resources/schemas/cmnotificationsubscription/ncmp-out-event-schema-1.0.0.json
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventMapper.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/cmnotificationsubscription/ncmp/NcmpOutEventMapperSpec.groovy

index 0c8d02a..0e6e290 100644 (file)
           "description": "The unique subscription id"
         },
         "acceptedTargets": {
-          "type": "array",
-          "description": "List of accepted targets",
-          "items": {
-            "type": "string"
-          }
+          "type": "object",
+          "existingJavaType": "java.util.Collection<String>",
+          "description": "Unique Collection of accepted targets"
         },
         "rejectedTargets": {
-          "type": "array",
-          "description": "List of rejected targets",
-          "items": {
-            "type": "string"
-          }
+          "type": "object",
+          "existingJavaType": "java.util.Collection<String>",
+          "description": "Unique Collection of rejected targets"
         },
         "pendingTargets": {
-          "type": "array",
-          "description": "List of pending targets",
-          "items": {
-            "type": "string"
-          }
+          "type": "object",
+          "existingJavaType": "java.util.Collection<String>",
+          "description": "Unique Collection of pending targets"
         }
       },
       "required": [
index ffd4b01..afff9d1 100644 (file)
@@ -21,6 +21,8 @@
 package org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import lombok.RequiredArgsConstructor;
@@ -76,9 +78,9 @@ public class NcmpOutEventMapper {
             final Map<String, DmiCmSubscriptionDetails> dmiSubscriptionsPerDmi,
             final Data cmSubscriptionData) {
 
-        final List<String> acceptedCmHandleIds = new ArrayList<>();
-        final List<String> pendingCmHandleIds = new ArrayList<>();
-        final List<String> rejectedCmHandleIds = new ArrayList<>();
+        final Collection<String> acceptedCmHandleIds = new HashSet<>();
+        final Collection<String> pendingCmHandleIds = new HashSet<>();
+        final Collection<String> rejectedCmHandleIds = new HashSet<>();
 
         dmiSubscriptionsPerDmi.forEach((dmiPluginName, dmiSubscriptionDetails) -> {
             final CmSubscriptionStatus cmSubscriptionStatus =
index 2251a33..d3c4026 100644 (file)
@@ -53,9 +53,9 @@ class NcmpOutEventMapperSpec extends Specification {
         then: 'event is mapped correctly for the subscription'
             result.data.subscriptionId == 'test-subscription'
         and: 'the cm handle ids are part of correct list'
-            result.data.pendingTargets == ['ch-A']
-            result.data.acceptedTargets == ['ch-B']
-            result.data.rejectedTargets == ['ch-C']
+            result.data.pendingTargets == ['ch-A'] as Set
+            result.data.acceptedTargets == ['ch-B'] as Set
+            result.data.rejectedTargets == ['ch-C'] as Set
     }
 
     def 'Check for Cm Notification Rejected Subscription Outgoing event mapping'() {