diff options
author | seanbeirne <sean.beirne@est.tech> | 2024-09-03 15:27:28 +0100 |
---|---|---|
committer | seanbeirne <sean.beirne@est.tech> | 2024-10-25 15:46:44 +0100 |
commit | ccf48efa15fa6cce9d2e245601105043f939bcce (patch) | |
tree | 77a1a6a13f8de8a1e1d4d745e3becf1898ca0a31 /cps-ncmp-rest/src | |
parent | de910dce42459035b24f3b1ff2f843152312518a (diff) |
Support Alternate-Id for CPS-E05 id-searches and searchCmHandleIds
Issue-ID: CPS-2402
Issue-ID: CPS-2383
Change-Id: I5dd3132b70b401bf2f50f77c2c131d5d34aa0c0a
Signed-off-by: seanbeirne <sean.beirne@est.tech>
Diffstat (limited to 'cps-ncmp-rest/src')
4 files changed, 24 insertions, 13 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java index 42f709dcf5..3676bb1393 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java @@ -268,18 +268,20 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { } /** - * Query and return cm handle ids that match the given query parameters. + * Query and return cm handle ids or alternate ids that match the given query parameters. * - * @param cmHandleQueryParameters the cm handle query parameters - * @return collection of cm handle ids + * @param cmHandleQueryParameters the cm handle query parameters + * @param outputAlternateId Boolean for cm handle reference type either + * cm handle id (false or null) or alternate id (true) + * @return collection of cm handle ids */ @Override - public ResponseEntity<List<String>> searchCmHandleIds( - final CmHandleQueryParameters cmHandleQueryParameters) { + public ResponseEntity<List<String>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters, + final Boolean outputAlternateId) { final CmHandleQueryApiParameters cmHandleQueryApiParameters = jsonObjectMapper.convertToValueType(cmHandleQueryParameters, CmHandleQueryApiParameters.class); final Collection<String> cmHandleIds - = networkCmProxyInventoryFacade.executeCmHandleIdSearch(cmHandleQueryApiParameters); + = networkCmProxyInventoryFacade.executeCmHandleIdSearch(cmHandleQueryApiParameters, outputAlternateId); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } 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 8aa86ade36..f47c05ca4e 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 @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Bell Canada - * Modifications Copyright (C) 2022-2023 Nordix Foundation + * Modifications 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. @@ -51,13 +51,22 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor private final NetworkCmProxyInventoryFacade networkCmProxyInventoryFacade; private final NcmpRestInputMapper ncmpRestInputMapper; + /** + * Get all cm handle references under a registered DMI plugin. + * + * @param cmHandleQueryParameters 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>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters) { + public ResponseEntity<List<String>> searchCmHandleIds(final CmHandleQueryParameters cmHandleQueryParameters, + final Boolean outputAlternateId) { final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = ncmpRestInputMapper .toCmHandleQueryServiceParameters(cmHandleQueryParameters); final Collection<String> cmHandleIds = networkCmProxyInventoryFacade - .executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters); + .executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, outputAlternateId); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy index 43403fa890..5340c6d93f 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy @@ -363,7 +363,7 @@ class NetworkCmProxyControllerSpec extends Specification { given: 'an endpoint and json data' def searchesEndpoint = "$ncmpBasePathV1/ch/id-searches" and: 'the service method is invoked with module names and returns cm handle ids' - 1 * mockNetworkCmProxyInventoryFacade.executeCmHandleIdSearch(_) >> ['ch-1', 'ch-2'] + 1 * mockNetworkCmProxyInventoryFacade.executeCmHandleIdSearch(_, _) >> ['ch-1', 'ch-2'] when: 'the searches api is invoked' def response = mvc.perform(post(searchesEndpoint).contentType(MediaType.APPLICATION_JSON).content('{}')).andReturn().response then: 'cm handle ids are returned' 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 97c68f08f3..85b2dd1a4d 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 @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Bell Canada - * Modifications Copyright (C) 2021-2023 Nordix Foundation + * Modifications 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. @@ -113,7 +113,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { and: 'the mapper service returns a converted object' ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters and: 'the service returns the desired results' - mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters) >> serviceMockResponse + mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse when: 'post request is performed & search is called with the given request parameters' def response = mvc.perform( post("$ncmpBasePathV1/ch/searches") @@ -136,7 +136,7 @@ class NetworkCmProxyInventoryControllerSpec extends Specification { and: 'the mapper service returns a converted object' ncmpRestInputMapper.toCmHandleQueryServiceParameters(_) >> cmHandleQueryServiceParameters and: 'the service returns the desired results' - mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters) >> serviceMockResponse + mockNetworkCmProxyInventoryFacade.executeParameterizedCmHandleIdSearch(cmHandleQueryServiceParameters, _) >> serviceMockResponse when: 'post request is performed & search is called with the given request parameters' def response = mvc.perform( post("$ncmpBasePathV1/ch/searches") |