Integration test of registration with alternate ID 61/138761/1
authordanielhanrahan <daniel.hanrahan@est.tech>
Thu, 15 Aug 2024 12:42:54 +0000 (13:42 +0100)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Thu, 15 Aug 2024 12:44:26 +0000 (13:44 +0100)
Add functional test of registering a batch of CM-handles with
a mixture of existing, duplicate, new and blank alternate IDs.

Issue-ID: CPS-2366
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Iaed5c47ca0e14583bea91ee74924f1b5c1f01cec

integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy

index 3d526c6..d27badc 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.kafka.common.TopicPartition
 import org.apache.kafka.common.serialization.StringDeserializer
 import org.onap.cps.integration.KafkaTestContainer
 import org.onap.cps.integration.base.CpsIntegrationSpecBase
+import org.onap.cps.ncmp.api.NcmpResponseStatus
 import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade
 import org.onap.cps.ncmp.api.inventory.models.CmHandleRegistrationResponse
 import org.onap.cps.ncmp.api.inventory.models.DmiPluginRegistration
@@ -133,6 +134,38 @@ class CmHandleCreateSpec extends CpsIntegrationSpecBase {
             deregisterCmHandles(DMI1_URL, ['ch-1', 'ch-2', 'ch-3'])
     }
 
+    def 'Create CM-handles with alternate IDs.'() {
+        given: 'DMI will return modules for all CM-handles when requested'
+            dmiDispatcher1.moduleNamesPerCmHandleId = (1..7).collectEntries{ ['ch-'+it, ['M1']] }
+        and: 'an existing CM-handle with an alternate ID'
+            registerCmHandle(DMI1_URL, 'ch-1', NO_MODULE_SET_TAG, 'existing-alt-id')
+        and: 'an existing CM-handle with no alternate ID'
+            registerCmHandle(DMI1_URL, 'ch-2', NO_MODULE_SET_TAG, NO_ALTERNATE_ID)
+
+        when: 'a batch of CM-handles is registered for creation with various alternate IDs'
+            def cmHandlesToCreate = [
+                    new NcmpServiceCmHandle(cmHandleId: 'ch-3', alternateId: NO_ALTERNATE_ID),
+                    new NcmpServiceCmHandle(cmHandleId: 'ch-4', alternateId: 'unique-alt-id'),
+                    new NcmpServiceCmHandle(cmHandleId: 'ch-5', alternateId: 'existing-alt-id'),
+                    new NcmpServiceCmHandle(cmHandleId: 'ch-6', alternateId: 'duplicate-alt-id'),
+                    new NcmpServiceCmHandle(cmHandleId: 'ch-7', alternateId: 'duplicate-alt-id'),
+            ]
+            def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI1_URL, createdCmHandles: cmHandlesToCreate)
+            def dmiPluginRegistrationResponse = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
+
+        then: 'registration gives expected responses'
+            assert dmiPluginRegistrationResponse.createdCmHandles.sort { it.cmHandle } == [
+                CmHandleRegistrationResponse.createSuccessResponse('ch-3'),
+                CmHandleRegistrationResponse.createSuccessResponse('ch-4'),
+                CmHandleRegistrationResponse.createFailureResponse('ch-5', NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED),
+                CmHandleRegistrationResponse.createSuccessResponse('ch-6'),
+                CmHandleRegistrationResponse.createFailureResponse('ch-7', NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED),
+            ]
+
+        cleanup: 'deregister CM handles'
+            deregisterCmHandles(DMI1_URL, (1..7).collect{ 'ch-'+it })
+    }
+
     def 'CM Handle retry after failed module sync.'() {
         given: 'DMI is not initially available to handle requests'
             dmiDispatcher1.isAvailable = false