Support alternate Id interface for ncmp inventory /ch/cmhandles endpoint

Issue-ID: CPS-2481
Change-Id: I8a200495be1afb9a4f256127f886bed78c77f653
Signed-off-by: seanbeirne <sean.beirne@est.tech>
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index a8da693..e564c6b 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -366,7 +366,7 @@
           type: array
           items:
             type: string
-            description: targeted cm handle references, maximum of 200 supported. If this limit is exceeded the request wil be refused.
+            description: targeted cm handle references, maximum of 200 supported. If this limit is exceeded the request will be refused.
             example: [ "da310eecdb8d44c2acc0ddaae01174b1","c748c58f8e0b438f9fd1f28370b17d47" ]
 
   examples:
@@ -516,7 +516,7 @@
     outputAlternateIdOptionInQuery:
       name: outputAlternateId
       in: query
-      description: Boolean parameter to determine if returned value(s) will be cm handle references for a given query
+      description: Boolean parameter to determine if returned value(s) will be cm handle Ids or alternate Ids for a given query
       required: false
       schema:
         type: boolean
diff --git a/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml b/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
index 24b83cf..7b1c8d4 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml
@@ -96,15 +96,16 @@
                 }
               ]
 
-getAllCmHandleIdsForRegisteredDmi:
+getAllCmHandleReferencesForRegisteredDmi:
   get:
-    description: Get all cm handle IDs for a registered DMI plugin
+    description: Get all cm handle references for a registered DMI plugin
     tags:
       - network-cm-proxy-inventory
-    summary: Get all cm handle IDs for a registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin)
-    operationId: getAllCmHandleIdsForRegisteredDmi
+    summary: Get all cm handle references for a registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin)
+    operationId: getAllCmHandleReferencesForRegisteredDmi
     parameters:
       - $ref: 'components.yaml#/components/parameters/dmiPluginIdentifierInQuery'
+      - $ref: 'components.yaml#/components/parameters/outputAlternateIdOptionInQuery'
     responses:
       200:
         description: OK
@@ -121,7 +122,7 @@
 
 searchCmHandleIds:
   post:
-    description: Query and get CMHandle references for additional properties, public properties and registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin).
+    description: Query and get cm handle references for additional properties, public properties and registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin).
     tags:
       - network-cm-proxy-inventory
     summary: Query for CM Handle IDs
diff --git a/cps-ncmp-rest/docs/openapi/openapi-inventory.yml b/cps-ncmp-rest/docs/openapi/openapi-inventory.yml
index d374dcc..6c207ee 100755
--- a/cps-ncmp-rest/docs/openapi/openapi-inventory.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi-inventory.yml
@@ -34,7 +34,7 @@
     $ref: 'ncmp-inventory.yml#/updateDmiRegistration'
 
   /v1/ch/cmHandles:
-    $ref: 'ncmp-inventory.yml#/getAllCmHandleIdsForRegisteredDmi'
+    $ref: 'ncmp-inventory.yml#/getAllCmHandleReferencesForRegisteredDmi'
 
   /v1/ch/searches:
     $ref: 'ncmp-inventory.yml#/searchCmHandleIds'
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
index f763769..0e27ba9 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
@@ -74,12 +74,17 @@
      * Get all cm-handle IDs under a registered DMI plugin.
      *
      * @param dmiPluginIdentifier DMI plugin identifier
+     * @param outputAlternateId   Boolean for cm handle reference type either
+     *                            cm handle id (False) or alternate id (True)
      * @return list of cm handle IDs
      */
     @Override
-    public ResponseEntity<List<String>> getAllCmHandleIdsForRegisteredDmi(final String dmiPluginIdentifier) {
+    public ResponseEntity<List<String>> getAllCmHandleReferencesForRegisteredDmi(final String dmiPluginIdentifier,
+                                                                                 final Boolean outputAlternateId) {
+
         final Collection<String> cmHandleIds =
-            networkCmProxyInventoryFacade.getAllCmHandleIdsByDmiPluginIdentifier(dmiPluginIdentifier);
+            networkCmProxyInventoryFacade.getAllCmHandleReferencesByDmiPluginIdentifier(dmiPluginIdentifier,
+                outputAlternateId);
         return ResponseEntity.ok(List.copyOf(cmHandleIds));
     }
 
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
index 74e6759..5930764 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
@@ -234,12 +234,14 @@
             'delete upgrade failed' | expectedSuccessResponse('cm-handle-1') | expectedSuccessResponse('cm-handle-2') | expectedFailedResponse('cm-handle-3')  | expectedFailedResponse('cm-handle-4')  || []                                            | []                                            | [expectedUnknownErrorResponse('cm-handle-3')] | [expectedUnknownErrorResponse('cm-handle-4')]
     }
 
-    def 'Get all cm handle IDs by DMI plugin identifier.'() {
-        given: 'an endpoint for returning cm handle IDs for a registered dmi plugin'
-            def getUrl = "$ncmpBasePathV1/ch/cmHandles?dmi-plugin-identifier=some-dmi-plugin-identifier"
-        and: 'a collection of cm handle IDs are returned'
-            1 * mockNetworkCmProxyInventoryFacade.getAllCmHandleIdsByDmiPluginIdentifier('some-dmi-plugin-identifier')
+    def 'Get all cm handle references by DMI plugin identifier when #scenario.'() {
+        given: 'an endpoint for returning cm handle references for a registered dmi plugin'
+            def getUrl = "$ncmpBasePathV1/ch/cmHandles?dmi-plugin-identifier=some-dmi-plugin-identifier"+outputAlternateId
+        and: 'a collection of cm handle references are returned'
+            mockNetworkCmProxyInventoryFacade.getAllCmHandleReferencesByDmiPluginIdentifier('some-dmi-plugin-identifier', false)
                     >> ['cm-handle-id-1','cm-handle-id-2']
+            mockNetworkCmProxyInventoryFacade.getAllCmHandleReferencesByDmiPluginIdentifier('some-dmi-plugin-identifier', true)
+                    >> ['alternate-id-1','alternate-id-2']
         when: 'the endpoint is invoked'
             def response = mvc.perform(
                     get(getUrl)
@@ -247,8 +249,12 @@
                             .accept(MediaType.APPLICATION_JSON_VALUE)
             ).andReturn().response
         then: 'the response matches the result returned by the service layer'
-            assert response.contentAsString.contains('cm-handle-id-1')
-            assert response.contentAsString.contains('cm-handle-id-2')
+            assert response.contentAsString.contains(firstReference)
+            assert response.contentAsString.contains(secondReference)
+        where:
+            scenario                | outputAlternateId         || firstReference    | secondReference
+            'output returns cm handle ids'  | ''                        ||  'cm-handle-id-1' | 'cm-handle-id-2'
+            'output returns alternate ids'  | '&outputAlternateId=true' ||  'alternate-id-1' | 'alternate-id-2'
     }
 
     def expectedUnknownErrorResponse(cmHandle) {