Implement ACK in DMI Plugin 99/138099/4
authoregernug <gerard.nugent@est.tech>
Wed, 29 May 2024 09:22:59 +0000 (10:22 +0100)
committeregernug <gerard.nugent@est.tech>
Thu, 30 May 2024 14:28:58 +0000 (15:28 +0100)
Implementing a response in DMI Plugin to indicate that the datajobs API is not implemented

Issue-ID: CPS-2243

Change-Id: I5215d634006a2031638110e3dc159c66ad4e7d86
Signed-off-by: egernug <gerard.nugent@est.tech>
docs/api/swagger/openapi-datajob.yaml
openapi/openapi-datajob.yml
pom.xml
src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java [new file with mode: 0644]
src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy [new file with mode: 0644]

index b3baa16..e58591e 100644 (file)
@@ -10,7 +10,7 @@ tags:
 - description: DMI plugin rest apis
   name: dmi-datajob
 paths:
-  /dmi/v1/readJob/{requestId}:
+  /v1/readJob/{requestId}:
     post:
       description: Create a read request
       operationId: readDataJob
@@ -31,15 +31,19 @@ paths:
               $ref: '#/components/schemas/SubjobReadRequest'
         description: Operation body
       responses:
-        "200":
+        "501":
           content:
             application/json:
+              example:
+                status: 501
+                message: Not Implemented
+                details: Method Not Implemented
               schema:
-                $ref: '#/components/schemas/readDataJob_200_response'
-          description: Response for subjob
+                $ref: '#/components/schemas/ErrorMessage'
+          description: Not Implemented
       tags:
       - dmi-datajob
-  /dmi/v1/writeJob/{requestId}:
+  /v1/writeJob/{requestId}:
     post:
       description: Create a write request
       operationId: writeDataJob
@@ -60,12 +64,16 @@ paths:
               $ref: '#/components/schemas/SubjobWriteRequest'
         description: Operation body
       responses:
-        "200":
+        "501":
           content:
             application/json:
+              example:
+                status: 501
+                message: Not Implemented
+                details: Method Not Implemented
               schema:
-                $ref: '#/components/schemas/readDataJob_200_response'
-          description: Response for subjob
+                $ref: '#/components/schemas/ErrorMessage'
+          description: Not Implemented
       tags:
       - dmi-datajob
 components:
@@ -80,7 +88,28 @@ components:
         example: some-identifier
         type: string
       style: simple
+  responses:
+    NotImplemented:
+      content:
+        application/json:
+          example:
+            status: 501
+            message: Not Implemented
+            details: Method Not Implemented
+          schema:
+            $ref: '#/components/schemas/ErrorMessage'
+      description: Not Implemented
   schemas:
+    ErrorMessage:
+      properties:
+        status:
+          type: string
+        message:
+          type: string
+        details:
+          type: string
+      title: Error
+      type: object
     SubjobReadRequest:
       properties:
         dataAcceptType:
@@ -165,14 +194,6 @@ components:
       type: object
     Object:
       type: object
-    readDataJob_200_response:
-      example:
-        dataProducerJobId: dataProducerJobId
-      properties:
-        dataProducerJobId:
-          description: The data job ID.
-          type: string
-      type: object
     SubjobReadRequest_data_inner:
       properties:
         path:
index 8a0f315..989218d 100644 (file)
@@ -27,7 +27,7 @@ tags:
   - description: DMI plugin rest apis
     name: dmi-datajob
 paths:
-  /dmi/v1/readJob/{requestId}:
+  /v1/readJob/{requestId}:
     post:
       description: Create a read request
       operationId: readDataJob
@@ -42,17 +42,9 @@ paths:
       tags:
         - dmi-datajob
       responses:
-        "200":
-          description: Response for subjob
-          content:
-            application/json:
-              schema:
-                type: object
-                properties:
-                  dataProducerJobId:
-                    type: string
-                    description: The data job ID.
-  /dmi/v1/writeJob/{requestId}:
+        "501":
+          $ref: '#/components/responses/NotImplemented'
+  /v1/writeJob/{requestId}:
     post:
       description: Create a write request
       operationId: writeDataJob
@@ -67,16 +59,9 @@ paths:
       tags:
         - dmi-datajob
       responses:
-        "200":
-          description: Response for subjob
-          content:
-            application/json:
-              schema:
-                type: object
-                properties:
-                  dataProducerJobId:
-                    type: string
-                    description: The data job ID.
+        "501":
+          $ref: '#/components/responses/NotImplemented'
+
 components:
   parameters:
     requestIdInPath:
@@ -88,6 +73,16 @@ components:
         example: some-identifier
         type: string
   schemas:
+    ErrorMessage:
+      type: object
+      title: Error
+      properties:
+        status:
+          type: string
+        message:
+          type: string
+        details:
+          type: string
     SubjobReadRequest:
       type: object
       required:
@@ -245,5 +240,15 @@ components:
         type: string
     Object:
       type: object
-
+  responses:
+    NotImplemented:
+      description: Not Implemented
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/ErrorMessage'
+          example:
+            status: 501
+            message: Not Implemented
+            details: Method Not Implemented
 
diff --git a/pom.xml b/pom.xml
index df55eb1..58c330f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                             <inputSpec>${project.basedir}/openapi/openapi-datajob.yml</inputSpec>
                             <generatorName>spring</generatorName>
                             <generateSupportingFiles>false</generateSupportingFiles>
-                            <invokerPackage>org.onap.cps.ncmp.dmi.rest.controller</invokerPackage>
-                            <apiPackage>org.onap.cps.ncmp.dmi.rest.api</apiPackage>
-                            <modelPackage>org.onap.cps.ncmp.dmi.model</modelPackage>
+                            <invokerPackage>org.onap.cps.ncmp.dmi.datajobs.rest.controller</invokerPackage>
+                            <apiPackage>org.onap.cps.ncmp.dmi.datajobs.rest.api</apiPackage>
+                            <modelPackage>org.onap.cps.ncmp.dmi.datajobs.model</modelPackage>
                             <generateAliasAsModel>true</generateAliasAsModel>
                             <configOptions>
                                 <sourceFolder>src/gen/java</sourceFolder>
                 <configuration>
                     <excludes>
                         <exclude>org/onap/cps/ncmp/dmi/model/*</exclude>
+                        <exclude>org/onap/cps/ncmp/dmi/datajobs/model/*</exclude>
                     </excludes>
                 </configuration>
                 <executions>
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestController.java
new file mode 100644 (file)
index 0000000..bbc1c20
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 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.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.datajobs.rest.controller;
+
+import org.onap.cps.ncmp.dmi.datajobs.model.SubjobReadRequest;
+import org.onap.cps.ncmp.dmi.datajobs.model.SubjobWriteRequest;
+import org.onap.cps.ncmp.dmi.datajobs.rest.api.DmiDatajobApi;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping("${rest.api.dmi-base-path}")
+@RestController
+public class DmiDatajobsRestController implements DmiDatajobApi {
+    /**
+     * * This method is not implemented for ONAP DMI plugin.
+     *
+     * @param requestId Identifier for the overall Datajob (required)
+     * @param subjobReadRequest Operation body (optional)
+     * @return (@ code ResponseEntity) response entity
+     */
+    @Override
+    public ResponseEntity<Void> readDataJob(final String requestId,
+                                              final SubjobReadRequest subjobReadRequest) {
+
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+    /**
+     * * This method is not implemented for ONAP DMI plugin.
+     *
+     * @param requestId Identifier for the overall Datajob (required)
+     * @param subjobWriteRequest Operation body (optional)
+     * @return (@ code ResponseEntity) response entity
+     */
+    @Override
+    public ResponseEntity<Void> writeDataJob(final String requestId,
+                                                               final SubjobWriteRequest subjobWriteRequest) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/datajobs/rest/controller/DmiDatajobsRestControllerSpec.groovy
new file mode 100644 (file)
index 0000000..c55f53c
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 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.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.datajobs.rest.controller
+
+import org.onap.cps.ncmp.dmi.config.WebSecurityConfig
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
+import org.springframework.context.annotation.Import
+import org.springframework.http.HttpStatus
+import org.springframework.security.test.context.support.WithMockUser
+import org.springframework.test.web.servlet.MockMvc
+import spock.lang.Specification
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
+
+@Import(WebSecurityConfig)
+@WebMvcTest(DmiDatajobsRestController.class)
+@WithMockUser
+class DmiDatajobsRestControllerSpec extends Specification{
+
+    @Autowired
+    private MockMvc mvc
+
+    @Value('${rest.api.dmi-base-path}/v1')
+    def basePathV1
+
+    def 'write request should return 501 HTTP Status' () {
+        given: 'URL to write a data job'
+            def getModuleUrl = "${basePathV1}/writeJob/001"
+        when: 'the request is posted'
+            def response = mvc.perform(
+                post(getModuleUrl)
+                        .contentType('application/3gpp-json-patch+json')
+        ).andReturn().response
+        then: 'response value is Not Implemented'
+            response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
+
+    def 'read request should return 501 HTTP Status' () {
+        given: 'URL to write a data job'
+            def getModuleUrl = "${basePathV1}/readJob/001"
+        when: 'the request is posted'
+            def response = mvc.perform(
+                post(getModuleUrl)
+                        .contentType('application/3gpp-json-patch+json')
+        ).andReturn().response
+        then: 'response value is Not Implemented'
+        response.status == HttpStatus.NOT_IMPLEMENTED.value()
+    }
+}