From 184b681a516c08abe9ef151090c5f208f5544e0e Mon Sep 17 00:00:00 2001 From: "david.mcweeney" Date: Thu, 2 May 2024 15:14:52 +0100 Subject: CPS-2187 - #5 Add module Set Tag to dmi (single cm handle) data request Change-Id: Iae7e3bac67bb8e5bbb50e4157fdf7daf9fc2220f Signed-off-by: david.mcweeney Issue-ID: CPS-2187 --- docs/api/swagger/openapi.yaml | 19 +++++++++++++++++ openapi/components.yml | 11 ++++++++++ openapi/openapi.yml | 1 + .../dmi/rest/controller/DmiRestController.java | 8 ++++---- .../rest/controller/DmiRestControllerSpec.groovy | 24 ++++++++++++++++------ 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/docs/api/swagger/openapi.yaml b/docs/api/swagger/openapi.yaml index f3516b5d..5782a9c8 100644 --- a/docs/api/swagger/openapi.yaml +++ b/docs/api/swagger/openapi.yaml @@ -209,6 +209,15 @@ paths: required: false schema: type: string + - name: moduleSetTag + description: Module set tag of the given cm handle. + in: query + examples: + sample1: + value: module-set-tag1 + required: false + schema: + type: string requestBody: content: application/json: @@ -379,6 +388,16 @@ components: required: false schema: type: string + moduleSetTagParamInQuery: + name: moduleSetTag + in: query + description: Module set tag of the given cm handle. + required: false + schema: + type: string + examples: + sample1: + value: module-set-tag1 requiredTopicParamInQuery: allowReserved: true description: mandatory topic name passed from client(NCMP). diff --git a/openapi/components.yml b/openapi/components.yml index b7f6058b..e011b16d 100644 --- a/openapi/components.yml +++ b/openapi/components.yml @@ -297,6 +297,17 @@ components: value: topic: my-topic-name + moduleSetTagParamInQuery: + name: moduleSetTag + in: query + description: Module set tag of the given cm handle. + required: false + schema: + type: string + examples: + sample1: + value: tag1 + requiredRequestIdParamInQuery: name: requestId in: query diff --git a/openapi/openapi.yml b/openapi/openapi.yml index 6dbc19f3..38f21c15 100644 --- a/openapi/openapi.yml +++ b/openapi/openapi.yml @@ -128,6 +128,7 @@ paths: - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery' - $ref: 'components.yml#/components/parameters/optionsParamInQuery' - $ref: 'components.yml#/components/parameters/topicParamInQuery' + - $ref: 'components.yml#/components/parameters/moduleSetTagParamInQuery' requestBody: description: Contains collection of cm handles with it's private properties and requestId content: diff --git a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java index 1dcc6373..47b9fc3e 100644 --- a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java +++ b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java @@ -80,16 +80,13 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { return ResponseEntity.ok(moduleSet); } - @Override public ResponseEntity retrieveModuleResources( final String cmHandle, final ModuleResourcesReadRequest moduleResourcesReadRequest) { final List moduleReferences = convertRestObjectToJavaApiObject(moduleResourcesReadRequest); final YangResources yangResources = dmiService.getModuleResources(cmHandle, moduleReferences); - if (moduleResourcesReadRequest.getModuleSetTag() != null) { - log.info("Module set tag received: {}", moduleResourcesReadRequest.getModuleSetTag()); - } + log.info("Module set tag received: {}", moduleResourcesReadRequest.getModuleSetTag()); return new ResponseEntity<>(yangResources, HttpStatus.OK); } @@ -141,7 +138,10 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { final String resourceIdentifier, final String optionsParamInQuery, final String topicParamInQuery, + final String moduleSetTagParamInQuery, final DataAccessRequest dataAccessRequest) { + + log.info("Module set tag received: {}", moduleSetTagParamInQuery); if (DatastoreType.PASSTHROUGH_OPERATIONAL == DatastoreType.fromDatastoreName(datastoreName)) { return dataAccessPassthroughOperational(resourceIdentifier, cmHandle, dataAccessRequest, optionsParamInQuery, topicParamInQuery); diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy index a23902fa..520e76af 100644 --- a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy +++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy @@ -21,7 +21,7 @@ package org.onap.cps.ncmp.dmi.rest.controller -import ch.qos.logback.classic.Level + import ch.qos.logback.classic.Logger import ch.qos.logback.classic.spi.ILoggingEvent import ch.qos.logback.core.read.ListAppender @@ -221,9 +221,8 @@ class DmiRestControllerSpec extends Specification { .contentType(MediaType.APPLICATION_JSON) .content(jsonData)) then: 'the module set tag is logged' - def loggingEvent = getLoggingEvent() - assert loggingEvent.level == Level.INFO - assert loggingEvent.formattedMessage.contains('Module set tag received: module-set-tag1') + def loggingMessage = getLoggingMessage(0) + assert loggingMessage.contains('module-set-tag1') } def 'Get resource data for pass-through operational.'() { @@ -339,6 +338,19 @@ class DmiRestControllerSpec extends Specification { resourceIdentifier << ['passthrough-operational', 'passthrough-running'] } + def 'PassThrough logs module set tag'(){ + given: 'Passthrough read URL and request data with a module set tag (parameter)' + def readPassThroughUrl ="${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:" + + 'passthrough-running?resourceIdentifier=some-resourceIdentifier&moduleSetTag=module-set-tag1' + def jsonData = TestUtils.getResourceFileContent('readData.json') + when: 'the request is posted' + mvc.perform( + post(readPassThroughUrl).contentType(MediaType.APPLICATION_JSON).content(jsonData)) + then: 'response status is OK' + def loggingMessage = getLoggingMessage(0) + assert loggingMessage.contains('module-set-tag1') + } + def 'Get resource data for pass-through running with #scenario value in resource identifier param.'() { given: 'Get resource data url' def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" + @@ -381,7 +393,7 @@ class DmiRestControllerSpec extends Specification { assert response.status == 501 } - def getLoggingEvent() { - return logger.list[0] + def getLoggingMessage(int index) { + return logger.list[index].formattedMessage } } \ No newline at end of file -- cgit 1.2.3-korg