Merge "Correct use of Spock setup and cleanup methods (no need for @Before @After)"
authorToine Siebelink <toine.siebelink@est.tech>
Thu, 8 Feb 2024 16:38:37 +0000 (16:38 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 8 Feb 2024 16:38:37 +0000 (16:38 +0000)
cps-ncmp-events/src/main/resources/schemas/lcm/lcm-event-schema-v1.json
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmHandleIdMapperSpec.groovy

index 7006b78..e687303 100644 (file)
           "description": "cmHandle id",
           "type": "string"
         },
+        "alternateId": {
+          "description": "alternative id for cmHandle (e.g. 3GPP FDN)",
+          "type": "string"
+        },
         "oldValues": {
           "$ref": "#/definitions/Values"
         },
index 450bc8c..23d508b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation
+ * Copyright (C) 2022-2024 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -95,6 +95,7 @@ public class LcmEventsCreator {
             final NcmpServiceCmHandle existingNcmpServiceCmHandle, final LcmEventType lcmEventType) {
         final Event event = new Event();
         event.setCmHandleId(eventCorrelationId);
+        event.setAlternateId(targetNcmpServiceCmHandle.getAlternateId());
         final CmHandleValuesHolder cmHandleValuesHolder =
                 LcmEventsCreatorHelper.determineEventValues(targetNcmpServiceCmHandle, existingNcmpServiceCmHandle,
                         lcmEventType);
index b54c154..3be97e8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2023 Nordix Foundation
+ *  Copyright (C) 2022-2024 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@ public class YangDataConverter {
         final List<YangModelCmHandle.Property> publicProperties = yangModelCmHandle.getPublicProperties();
         ncmpServiceCmHandle.setCmHandleId(yangModelCmHandle.getId());
         ncmpServiceCmHandle.setCompositeState(yangModelCmHandle.getCompositeState());
+        ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId());
         setDmiProperties(dmiProperties, ncmpServiceCmHandle);
         setPublicProperties(publicProperties, ncmpServiceCmHandle);
         return ncmpServiceCmHandle;
index ba36b1a..03e53fc 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2023 Nordix Foundation
+ *  Copyright (C) 2021-2024 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -119,7 +119,7 @@ public class YangModelCmHandle {
         yangModelCmHandle.setDmiDataServiceName(dmiDataServiceName);
         yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName);
         yangModelCmHandle.setModuleSetTag(moduleSetTag == null ? StringUtils.EMPTY : moduleSetTag);
-        yangModelCmHandle.setAlternateId(alternateId);
+        yangModelCmHandle.setAlternateId(alternateId == null ? StringUtils.EMPTY : alternateId);
         yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties()));
         yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(
                 ncmpServiceCmHandle.getPublicProperties()));
index 0917953..b7c3b87 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation
+ * Copyright (C) 2022-2024 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -173,4 +173,19 @@ class LcmEventsCreatorSpec extends Specification {
             assert result.eventCorrelationId == cmHandleId
             assert result.eventId != null
     }
+
+    def 'Map the LcmEvent for alternate IDs when #scenario'() {
+        given: 'NCMP cm handle details with current and old alternate IDs'
+            def existingNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: existingAlternateId, compositeState: new CompositeState(dataSyncEnabled: false))
+            def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, compositeState: new CompositeState(dataSyncEnabled: false))
+        when: 'the event is populated'
+            def result = objectUnderTest.populateLcmEvent(cmHandleId, targetNcmpServiceCmHandle, existingNcmpServiceCmHandle)
+        then: 'the alternate ID is present or is an empty string in the payload'
+            assert result.event.alternateId == expectedEventAlternateId
+        where: 'the following alternate IDs are provided'
+            scenario                                      | existingAlternateId | targetAlternateId || expectedEventAlternateId
+            'same new and old alternate ID'               | 'someAlternateId'   | 'someAlternateId' || 'someAlternateId'
+            'blank new and old alternate ID'              | ''                  | ''                || ''
+            'new alternate id and blank old alternate ID' | ''                  | 'someAlternateId' || 'someAlternateId'
+    }
 }
\ No newline at end of file
index 0a2962e..55ccdf3 100644 (file)
@@ -78,6 +78,15 @@ class CmHandleIdMapperSpec extends Specification {
             assert objectUnderTest.cmHandleIdToAlternateId('my cmhandle id') == null
     }
 
+    def 'Attempt to remove a non-existing entry from the cache.'() {
+        when: 'removing an entry that is not cached'
+            objectUnderTest.removeMapping('non-cached cmhandle id')
+        then: 'deleting from the cmhandle cache returns null'
+            assert alternateIdPerCmHandle.remove('non-cached cmhandle id') == null
+        and: 'removal from the alternate id cache is skipped'
+            0 * cmHandlePerAlternateId.remove(_)
+    }
+
     def 'Cannot update existing alternate id.'() {
         given: 'attempt to update an existing alternate id'
             objectUnderTest.addMapping('my cmhandle id', 'other id')