diff options
author | 2024-05-28 12:48:38 +0100 | |
---|---|---|
committer | 2024-05-29 09:58:40 +0100 | |
commit | 45d3b6194e4feaaed14f5b57d54813d3c6c8bd62 (patch) | |
tree | c52742fc1094c2bd04520bca5464633eaff00536 | |
parent | e80121ef3cc4a0a44ba9ddea935e2270e1da775a (diff) |
CPS-2187 - Move Module Set Tag into request body for dmi data access passthrough calls
Change-Id: I9c807d2ef5b3712bf3f8ee5db7663d9628eef3bb
Signed-off-by: david.mcweeney <david.mcweeney@est.tech>
Issue-ID: CPS-2187
6 files changed, 30 insertions, 38 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java index 1e92bfe42..49894dedb 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java @@ -90,8 +90,7 @@ public class DmiDataOperations extends DmiOperations { final String jsonRequestBody = getDmiRequestBody(READ, requestId, null, null, yangModelCmHandle); final MultiValueMap<String, String> uriQueryParamsMap = getUriQueryParamsMap( - cmResourceAddress.resourceIdentifier(), optionsParamInQuery, - topicParamInQuery, yangModelCmHandle.getModuleSetTag()); + cmResourceAddress.resourceIdentifier(), optionsParamInQuery, topicParamInQuery); final Map<String, Object> uriVariableParamsMap = getUriVariableParamsMap(cmResourceAddress.datastoreName(), yangModelCmHandle.resolveDmiServiceName(RequiredDmiService.DATA), cmResourceAddress.cmHandleId()); final String dmiResourceDataUrl = getDmiRequestUrl(uriQueryParamsMap, uriVariableParamsMap); @@ -115,8 +114,7 @@ public class DmiDataOperations extends DmiOperations { final String jsonRequestBody = getDmiRequestBody(READ, requestId, null, null, yangModelCmHandle); - final MultiValueMap<String, String> uriQueryParamsMap = getUriQueryParamsMap("/", null, - null, yangModelCmHandle.getModuleSetTag()); + final MultiValueMap<String, String> uriQueryParamsMap = getUriQueryParamsMap("/", null, null); final Map<String, Object> uriVariableParamsMap = getUriVariableParamsMap(dataStoreName, yangModelCmHandle.resolveDmiServiceName(RequiredDmiService.DATA), cmHandleId); final String dmiResourceDataUrl = getDmiRequestUrl(uriQueryParamsMap, uriVariableParamsMap); @@ -176,8 +174,7 @@ public class DmiDataOperations extends DmiOperations { final String jsonRequestBody = getDmiRequestBody(operationType, null, requestData, dataType, yangModelCmHandle); - final MultiValueMap<String, String> uriQueryParamsMap = getUriQueryParamsMap(resourceId, null, - null, yangModelCmHandle.getModuleSetTag()); + final MultiValueMap<String, String> uriQueryParamsMap = getUriQueryParamsMap(resourceId, null, null); final Map<String, Object> uriVariableParamsMap = getUriVariableParamsMap(PASSTHROUGH_RUNNING.getDatastoreName(), yangModelCmHandle.resolveDmiServiceName(RequiredDmiService.DATA), cmHandleId); final String dmiUrl = getDmiRequestUrl(uriQueryParamsMap, uriVariableParamsMap); @@ -201,6 +198,7 @@ public class DmiDataOperations extends DmiOperations { .requestId(requestId) .data(requestData) .dataType(dataType) + .moduleSetTag(yangModelCmHandle.getModuleSetTag()) .build(); dmiRequestBody.asDmiProperties(yangModelCmHandle.getDmiProperties()); return jsonObjectMapper.asJsonString(dmiRequestBody); @@ -213,10 +211,9 @@ public class DmiDataOperations extends DmiOperations { private MultiValueMap<String, String> getUriQueryParamsMap(final String resourceId, final String optionsParamInQuery, - final String topicParamInQuery, - final String moduleSetTagParamInQuery) { + final String topicParamInQuery) { return dmiServiceUrlBuilder.populateQueryParams(resourceId, optionsParamInQuery, - topicParamInQuery, moduleSetTagParamInQuery); + topicParamInQuery); } private Map<String, Object> getUriVariableParamsMap(final String dataStoreName, diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java index 9234d3c2f..15f1effdd 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilder.java @@ -136,22 +136,17 @@ public class DmiServiceUrlBuilder { * @param resourceId unique id of response for valid topic * @param optionsParamInQuery options as provided by client * @param topicParamInQuery topic as provided by client - * @param moduleSetTag module set tag associated with the given cm handle * @return all valid query params as map */ public MultiValueMap<String, String> populateQueryParams(final String resourceId, final String optionsParamInQuery, - final String topicParamInQuery, - final String moduleSetTag) { + final String topicParamInQuery) { final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>(); getQueryParamConsumer().accept("resourceIdentifier", resourceId, queryParams); getQueryParamConsumer().accept("options", optionsParamInQuery, queryParams); if (Strings.isNotEmpty(topicParamInQuery)) { getQueryParamConsumer().accept("topic", topicParamInQuery, queryParams); } - if (Strings.isNotEmpty(moduleSetTag)) { - getQueryParamConsumer().accept("moduleSetTag", moduleSetTag, queryParams); - } return queryParams; } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy index d04052f79..9dafd9ed2 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy @@ -84,13 +84,13 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { then: 'the result is the response from the DMI service' assert result == responseFromDmi where: 'the following parameters are used' - scenario | dmiProperties | dataStore | options || expectedJson | expectedDatastoreInUrl | expectedOptionsInUrl - 'without properties' | [] | PASSTHROUGH_OPERATIONAL | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{}}' | 'passthrough-operational' | '&options=(a=1,b=2)' - 'with properties' | [yangModelCmHandleProperty] | PASSTHROUGH_OPERATIONAL | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{"prop1":"val1"}}' | 'passthrough-operational' | '&options=(a=1,b=2)' - 'null options' | [yangModelCmHandleProperty] | PASSTHROUGH_OPERATIONAL | null || '{"operation":"read","cmHandleProperties":{"prop1":"val1"}}' | 'passthrough-operational' | '' - 'empty options' | [yangModelCmHandleProperty] | PASSTHROUGH_OPERATIONAL | '' || '{"operation":"read","cmHandleProperties":{"prop1":"val1"}}' | 'passthrough-operational' | '' - 'datastore running without properties' | [] | PASSTHROUGH_RUNNING | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{}}' | 'passthrough-running' | '&options=(a=1,b=2)' - 'datastore running with properties' | [yangModelCmHandleProperty] | PASSTHROUGH_RUNNING | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{"prop1":"val1"}}' | 'passthrough-running' | '&options=(a=1,b=2)' + scenario | dmiProperties | dataStore | options || expectedJson | expectedDatastoreInUrl | expectedOptionsInUrl + 'without properties' | [] | PASSTHROUGH_OPERATIONAL | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{},"moduleSetTag":""}' | 'passthrough-operational' | '&options=(a=1,b=2)' + 'with properties' | [yangModelCmHandleProperty] | PASSTHROUGH_OPERATIONAL | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":""}' | 'passthrough-operational' | '&options=(a=1,b=2)' + 'null options' | [yangModelCmHandleProperty] | PASSTHROUGH_OPERATIONAL | null || '{"operation":"read","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":""}' | 'passthrough-operational' | '' + 'empty options' | [yangModelCmHandleProperty] | PASSTHROUGH_OPERATIONAL | '' || '{"operation":"read","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":""}' | 'passthrough-operational' | '' + 'datastore running without properties' | [] | PASSTHROUGH_RUNNING | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{},"moduleSetTag":""}' | 'passthrough-running' | '&options=(a=1,b=2)' + 'datastore running with properties' | [yangModelCmHandleProperty] | PASSTHROUGH_RUNNING | OPTIONS_PARAM || '{"operation":"read","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":""}' | 'passthrough-running' | '&options=(a=1,b=2)' } def 'Execute (async) data operation from DMI service.'() { @@ -130,12 +130,13 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { } def 'call get all resource data.'() { - given: 'the system returns a cm handle with a sample property' - mockYangModelCmHandleRetrieval([yangModelCmHandleProperty]) + given: 'the system returns a cm handle with a sample property and sample module set tag' + def sampleModuleSetTag = "mod-tag-1" + mockYangModelCmHandleRetrieval([yangModelCmHandleProperty], sampleModuleSetTag) and: 'a positive response from DMI service when it is called with the expected parameters' def responseFromDmi = new ResponseEntity<Object>(HttpStatus.OK) def expectedUrl = dmiServiceBaseUrl + "passthrough-operational?resourceIdentifier=/" - mockDmiRestClient.postOperationWithJsonData(expectedUrl, '{"operation":"read","cmHandleProperties":{"prop1":"val1"}}', READ, null) >> responseFromDmi + mockDmiRestClient.postOperationWithJsonData(expectedUrl, '{"operation":"read","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":"'+sampleModuleSetTag+'"}', READ, null) >> responseFromDmi dmiServiceUrlBuilder.getDmiDatastoreUrl(_, _) >> expectedUrl when: 'get resource data is invoked' def result = objectUnderTest.getResourceDataFromDmi( PASSTHROUGH_OPERATIONAL.datastoreName, cmHandleId, NO_REQUEST_ID) @@ -148,7 +149,7 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { mockYangModelCmHandleRetrieval([yangModelCmHandleProperty]) and: 'a positive response from DMI service when it is called with the expected parameters' def expectedUrl = dmiServiceBaseUrl + "passthrough-running?resourceIdentifier=${resourceIdentifier}" - def expectedJson = '{"operation":"' + expectedOperationInUrl + '","dataType":"some data type","data":"requestData","cmHandleProperties":{"prop1":"val1"}}' + def expectedJson = '{"operation":"' + expectedOperationInUrl + '","dataType":"some data type","data":"requestData","cmHandleProperties":{"prop1":"val1"},"moduleSetTag":""}' def responseFromDmi = new ResponseEntity<Object>(HttpStatus.OK) dmiServiceUrlBuilder.getDmiDatastoreUrl(_, _) >> expectedUrl mockDmiRestClient.postOperationWithJsonData(expectedUrl, expectedJson, operation, NO_AUTH_HEADER) >> responseFromDmi diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy index 2c7fa654c..827f44850 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy @@ -48,19 +48,17 @@ class DmiServiceUrlBuilderSpec extends Specification { given: 'uri variables' def uriVars = objectUnderTest.populateUriVariables(PASSTHROUGH_RUNNING.datastoreName, yangModelCmHandle.resolveDmiServiceName(RequiredDmiService.DATA), 'cmHandle') and: 'query params' - def uriQueries = objectUnderTest.populateQueryParams(resourceId, 'optionsParamInQuery', topic, moduleSetTag) + def uriQueries = objectUnderTest.populateQueryParams(resourceId, 'optionsParamInQuery', topic) when: 'a dmi datastore service url is generated' def dmiServiceUrl = objectUnderTest.getDmiDatastoreUrl(uriQueries, uriVars) then: 'service url is generated as expected' assert dmiServiceUrl == expectedDmiServiceUrl where: 'the following parameters are used' - scenario | topic | moduleSetTag | resourceId || expectedDmiServiceUrl - 'With valid resourceId' | 'topicParamInQuery' | '' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery&topic=topicParamInQuery' - 'With Empty resourceId' | 'topicParamInQuery' | '' | '' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?options=optionsParamInQuery&topic=topicParamInQuery' - 'With valid moduleSetTag' | 'topicParamInQuery' | 'module-set-tag1' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery&topic=topicParamInQuery&moduleSetTag=module-set-tag1' - 'With Empty moduleSetTag' | 'topicParamInQuery' | '' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery&topic=topicParamInQuery' - 'With Empty dmi base path' | 'topicParamInQuery' | '' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery&topic=topicParamInQuery' - 'With Empty topicParamInQuery' | '' | '' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery' + scenario | topic | resourceId || expectedDmiServiceUrl + 'With valid resourceId' | 'topicParamInQuery' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery&topic=topicParamInQuery' + 'With Empty resourceId' | 'topicParamInQuery' | '' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?options=optionsParamInQuery&topic=topicParamInQuery' + 'With Empty dmi base path' | 'topicParamInQuery' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery&topic=topicParamInQuery' + 'With Empty topicParamInQuery' | '' | 'resourceId' || 'dmiServiceName/dmi/v1/ch/cmHandle/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=resourceId&options=optionsParamInQuery' } def 'Populate dmi data store url #scenario.'() { @@ -68,7 +66,7 @@ class DmiServiceUrlBuilderSpec extends Specification { dmiProperties.dmiBasePath = dmiBasePath def uriVars = objectUnderTest.populateUriVariables(PASSTHROUGH_RUNNING.datastoreName, yangModelCmHandle.resolveDmiServiceName(RequiredDmiService.DATA), 'cmHandle') and: 'null query params' - def uriQueries = objectUnderTest.populateQueryParams(null, null, null, null) + def uriQueries = objectUnderTest.populateQueryParams(null, null, null) when: 'a dmi datastore service url is generated' def dmiServiceUrl = objectUnderTest.getDmiDatastoreUrl(uriQueries, uriVars) then: 'the created dmi service url matches the expected' diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java index a596afdce..005aa2237 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java @@ -205,11 +205,11 @@ public class DmiRestStubController { @RequestParam(value = "resourceIdentifier") final String resourceIdentifier, @RequestParam(value = "options", required = false) final String options, @RequestParam(value = "topic", required = false) final String topic, - @RequestParam(value = "moduleSetTag", required = false) final String moduleSetTag, - @RequestHeader(value = "Authorization", required = false) final String authorization) { + @RequestHeader(value = "Authorization", required = false) final String authorization, + @RequestBody final String requestBody) { log.info("DMI AUTH HEADER: {}", authorization); delay(dataForCmHandleDelayMs); - log.info("Module set tag received: {}", moduleSetTag); + log.info("Logging request body {}", requestBody); final String sampleJson = ResourceFileReaderUtil.getResourceFileContent(applicationContext.getResource( ResourceLoader.CLASSPATH_URL_PREFIX + "data/operational/ietf-network-topology-sample-rfc8345.json")); diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java index 0771e7740..ae78c0337 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/model/data/operational/DmiDataOperationRequest.java @@ -29,4 +29,5 @@ import lombok.Setter; public class DmiDataOperationRequest { private List<DataOperationRequest> operations; + } |