From 3cadc1985c5f8cdc3f1914b95fe43d5e0987743b Mon Sep 17 00:00:00 2001 From: "david.mcweeney" Date: Wed, 8 May 2024 12:37:02 +0100 Subject: CPS-2182 -#3 Include module Set Tag in dmi batch data enpoint Change-Id: Ib45cc59c12062429aababa7aedb3a028aac0315c Signed-off-by: david.mcweeney Issue-ID: CPS-2182 --- docs/api/swagger/openapi.yaml | 2 ++ openapi/components.yml | 10 +++++++--- .../onap/cps/ncmp/dmi/rest/controller/DmiRestController.java | 11 +++++++++++ .../cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy | 9 ++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/api/swagger/openapi.yaml b/docs/api/swagger/openapi.yaml index 5782a9c8..0f690ef5 100644 --- a/docs/api/swagger/openapi.yaml +++ b/docs/api/swagger/openapi.yaml @@ -671,10 +671,12 @@ components: cmHandleProperties: myProp: some value otherProp: other value + moduleSetTag: module-set-tag1 - id: cmHandle123 cmHandleProperties: myProp: some value otherProp: other value + moduleSetTag: module-set-tag2 operation: read properties: operation: diff --git a/openapi/components.yml b/openapi/components.yml index e011b16d..ae9710b1 100644 --- a/openapi/components.yml +++ b/openapi/components.yml @@ -76,27 +76,31 @@ components: cmHandles: type: array items: - $ref: '#/components/schemas/cmHandle' + $ref: '#/components/schemas/dmiOperationCmHandle' required: - operation - operationId - datastore - cmHandles - cmHandle: + dmiOperationCmHandle: type: object - title: 'cmHandle' + title: 'CmHandle with properties for DMI' properties: id: type: string cmHandleProperties: additionalProperties: type: string + moduleSetTag: + type: string + example: module-set-tag1 example: id: cmHandle123 cmHandleProperties: myProp: some value otherProp: other value + moduleSetTag: module-set-tag1 ModuleResourcesReadRequest: type: object 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 47b9fc3e..ec56884c 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 @@ -116,6 +116,17 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi { @Override public ResponseEntity getResourceDataForCmHandleDataOperation(final String topic, final String requestId, final ResourceDataOperationRequests resourceDataOperationRequests) { + log.info("Request Details (for testing purposes)"); + log.info("Request Id: {}", requestId); + log.info("Topic: {}", topic); + + log.info("Details of the first Operation"); + log.info("Resource Identifier: {}", resourceDataOperationRequests.get(0).getResourceIdentifier()); + log.info("Module Set Tag: {}", resourceDataOperationRequests.get(0).getCmHandles().get(0).getModuleSetTag()); + log.info("Operation Id: {}", resourceDataOperationRequests.get(0).getOperationId()); + log.info("Cm Handles: {}", resourceDataOperationRequests.get(0).getCmHandles()); + log.info("Options: {}", resourceDataOperationRequests.get(0).getOptions()); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } 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 520e76af..23b039bd 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 @@ -384,13 +384,20 @@ class DmiRestControllerSpec extends Specification { def resourceDataUrl = "$basePathV1/data?topic=client-topic-name&requestId=some-requestId" and: 'list of operation details are received into request body' def dataOperationRequestBody = '[{"operation": "read", "operationId": "14", "datastore": "ncmp-datastore:passthrough-operational", "options": "some options", "resourceIdentifier": "some resourceIdentifier",' + - ' "cmhandles": [ {"id": "cmHanlde123", "cmHandleProperties": { "myProp`": "some value", "otherProp": "other value"}}]}]' + '"cmHandles": [ {"id": "cmHandle123", "moduleSetTag": "module-set-tag1", "cmHandleProperties": { "myProp`": "some value", "otherProp": "other value"}}]}]' when: 'the dmi resource data for dataOperation api is called.' def response = mvc.perform( post(resourceDataUrl).contentType(MediaType.APPLICATION_JSON).content(dataOperationRequestBody) ).andReturn().response then: 'the resource data operation endpoint returns the not implemented response' assert response.status == 501 + and: 'the job details are correctly received (logged)' + assert getLoggingMessage(1).contains('some-requestId') + assert getLoggingMessage(2).contains('client-topic-name') + assert getLoggingMessage(4).contains('some resourceIdentifier') + assert getLoggingMessage(5).contains('module-set-tag1') + and: 'the operation Id is correctly received (logged)' + assert getLoggingMessage(6).contains('14') } def getLoggingMessage(int index) { -- cgit 1.2.3-korg