Incorrect Internal Error Code for duplicated registration 09/140009/2
authorseanbeirne <sean.beirne@est.tech>
Thu, 23 Jan 2025 10:59:00 +0000 (10:59 +0000)
committerseanbeirne <sean.beirne@est.tech>
Thu, 23 Jan 2025 14:13:02 +0000 (14:13 +0000)
-Deprectated 111 Alternate-Id already exists error code
-All dupication scenarios now return 109

Issue-ID: CPS-2563
Change-Id: Ic9b9df936eaf3795441f4dd1ec1cc73e39c9eae1
Signed-off-by: seanbeirne <sean.beirne@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServicePropertyHandler.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/models/CmHandleRegistrationResponseSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy

index e7fd247..75c52f3 100644 (file)
@@ -23,7 +23,6 @@
 
 package org.onap.cps.ncmp.impl.inventory;
 
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED;
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND;
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_READY;
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST;
@@ -347,7 +346,7 @@ public class CmHandleRegistrationService {
         final Collection<String> rejectedCmHandleIds = alternateIdChecker
             .getIdsOfCmHandlesWithRejectedAlternateId(cmHandlesToBeCreated, AlternateIdChecker.Operation.CREATE);
         cmHandleRegistrationResponses.addAll(CmHandleRegistrationResponse.createFailureResponses(
-            rejectedCmHandleIds, ALTERNATE_ID_ALREADY_ASSOCIATED));
+            rejectedCmHandleIds, CM_HANDLE_ALREADY_EXIST));
         return rejectedCmHandleIds;
     }
 
index b7a13d9..97fd8e5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2024 Nordix Foundation
+ *  Copyright (C) 2022-2025 Nordix Foundation
  *  Modifications Copyright (C) 2022 Bell Canada
  *  Modifications Copyright (C) 2024 TechMahindra Ltd.
  *  ================================================================================
@@ -22,8 +22,8 @@
 
 package org.onap.cps.ncmp.impl.inventory;
 
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED;
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST;
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_INVALID_ID;
 import static org.onap.cps.ncmp.impl.inventory.CmHandleRegistrationServicePropertyHandler.PropertyType.DMI_PROPERTY;
 import static org.onap.cps.ncmp.impl.inventory.CmHandleRegistrationServicePropertyHandler.PropertyType.PUBLIC_PROPERTY;
@@ -81,7 +81,7 @@ public class CmHandleRegistrationServicePropertyHandler {
         final Collection<String> rejectedCmHandleIds = alternateIdChecker
             .getIdsOfCmHandlesWithRejectedAlternateId(updatedNcmpServiceCmHandles, AlternateIdChecker.Operation.UPDATE);
         final List<CmHandleRegistrationResponse> failureResponses =
-            CmHandleRegistrationResponse.createFailureResponses(rejectedCmHandleIds, ALTERNATE_ID_ALREADY_ASSOCIATED);
+            CmHandleRegistrationResponse.createFailureResponses(rejectedCmHandleIds, CM_HANDLE_ALREADY_EXIST);
         final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>(failureResponses);
         for (final NcmpServiceCmHandle updatedNcmpServiceCmHandle : updatedNcmpServiceCmHandles) {
             final String cmHandleId = updatedNcmpServiceCmHandle.getCmHandleId();
index 055a6e7..c49af0f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada
- *  Modifications Copyright (C) 2023-2024 Nordix Foundation
+ *  Modifications Copyright (C) 2023-2025 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import spock.lang.Specification
 
 import java.util.stream.Collectors
 
-import static org.onap.cps.ncmp.api.NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST
 import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR
 
@@ -89,14 +88,14 @@ class CmHandleRegistrationResponseSpec extends Specification {
     }
 
     def 'Failed cm-handle registration based on cm handle id and registration error'() {
-        when: 'the failure response is created with "alternate id already associated" error code for 1 cm handle'
+        when: 'the failure response is created with "cm-handle already exists" error code for 1 cm handle'
             def cmHandleRegistrationResponses =
-                    CmHandleRegistrationResponse.createFailureResponses(['ch 1'], ALTERNATE_ID_ALREADY_ASSOCIATED)
+                    CmHandleRegistrationResponse.createFailureResponses(['ch 1'], CM_HANDLE_ALREADY_EXIST)
         then: 'the response with expected values'
             assert cmHandleRegistrationResponses[0].cmHandle == 'ch 1'
             assert cmHandleRegistrationResponses[0].status == Status.FAILURE
-            assert cmHandleRegistrationResponses[0].ncmpResponseStatus == ALTERNATE_ID_ALREADY_ASSOCIATED
-            assert cmHandleRegistrationResponses[0].errorText == 'alternate id already associated'
+            assert cmHandleRegistrationResponses[0].ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
+            assert cmHandleRegistrationResponses[0].errorText == 'cm-handle already exists'
     }
 
 }
index 6f063fb..c4946b4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the 'License');
  *  you may not use this file except in compliance with the License.
@@ -178,9 +178,9 @@ class CmHandleCreateSpec extends CpsIntegrationSpecBase {
             assert dmiPluginRegistrationResponse.createdCmHandles.sort { it.cmHandle } == [
                 CmHandleRegistrationResponse.createSuccessResponse('ch-3'),
                 CmHandleRegistrationResponse.createSuccessResponse('ch-4'),
-                CmHandleRegistrationResponse.createFailureResponse('ch-5', NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED),
+                CmHandleRegistrationResponse.createFailureResponse('ch-5', NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST),
                 CmHandleRegistrationResponse.createSuccessResponse('ch-6'),
-                CmHandleRegistrationResponse.createFailureResponse('ch-7', NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED),
+                CmHandleRegistrationResponse.createFailureResponse('ch-7', NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST),
             ]
 
         cleanup: 'deregister CM handles'
index f2593ce..22bbaa8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2024 Nordix Foundation
+ *  Copyright (C) 2024-2025 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the 'License');
  *  you may not use this file except in compliance with the License.
@@ -76,8 +76,8 @@ class CmHandleUpdateSpec extends CpsIntegrationSpecBase {
             def dmiPluginRegistrationResponse =
                     objectUnderTest.updateDmiRegistration(new DmiPluginRegistration(dmiPlugin: DMI1_URL, updatedCmHandles: [cmHandleToUpdate]))
 
-        then: 'registration gives failure response, due to alternate ID being already associated'
-            assert dmiPluginRegistrationResponse.updatedCmHandles == [CmHandleRegistrationResponse.createFailureResponse('ch-1', NcmpResponseStatus.ALTERNATE_ID_ALREADY_ASSOCIATED)]
+        then: 'registration gives failure response, due to cm-handle already existing'
+            assert dmiPluginRegistrationResponse.updatedCmHandles == [CmHandleRegistrationResponse.createFailureResponse('ch-1', NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST)]
 
         and: 'the CM-handle still has the old alternate ID'
             assert objectUnderTest.getNcmpServiceCmHandle('ch-1').alternateId == 'original'