diff options
author | seanbeirne <sean.beirne@est.tech> | 2024-11-05 10:21:30 +0000 |
---|---|---|
committer | seanbeirne <sean.beirne@est.tech> | 2024-11-13 10:52:19 +0000 |
commit | c37dee4816f51f750a9c92946dc9d4a558f3b812 (patch) | |
tree | d54dba7ce7c024c6be1a347190b14c8a2aecb092 /cps-ncmp-rest | |
parent | 38cea5882ab71f23eddd3ffc9fd56c5d6540f28e (diff) |
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>
Diffstat (limited to 'cps-ncmp-rest')
5 files changed, 29 insertions, 17 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml index a8da6937a3..e564c6b0cf 100644 --- a/cps-ncmp-rest/docs/openapi/components.yaml +++ b/cps-ncmp-rest/docs/openapi/components.yaml @@ -366,7 +366,7 @@ components: 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 @@ components: 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 24b83cf368..7b1c8d403e 100755 --- a/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml +++ b/cps-ncmp-rest/docs/openapi/ncmp-inventory.yml @@ -96,15 +96,16 @@ updateDmiRegistration: } ] -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 @@ getAllCmHandleIdsForRegisteredDmi: 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 d374dcc9db..6c207ee2af 100755 --- a/cps-ncmp-rest/docs/openapi/openapi-inventory.yml +++ b/cps-ncmp-rest/docs/openapi/openapi-inventory.yml @@ -34,7 +34,7 @@ paths: $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 f76376991a..0e27ba9355 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 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor * 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 74e6759f72..59307640ef 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 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { '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 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { .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) { |