fix data from object to string 49/124149/2
authortragait <rahul.tyagi@est.tech>
Tue, 14 Sep 2021 12:55:05 +0000 (13:55 +0100)
committertragait <rahul.tyagi@est.tech>
Fri, 17 Sep 2021 15:58:37 +0000 (16:58 +0100)
Issue-ID: CPS-634
Signed-off-by: tragait <rahul.tyagi@est.tech>
Change-Id: I13b20bc81a6109da32986088ddcf3d1814902a02

cps-ncmp-rest/docs/openapi/ncmproxy.yml
cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java

index 5e2957f..2e5eba7 100755 (executable)
@@ -266,10 +266,10 @@ resourceDataForPassthroughRunning:
       content:
         application/json:
           schema:
-            type: object
+            type: string
         application/yang-data+json:
           schema:
-            type: object
+            type: string
     responses:
       201:
         $ref: 'components.yaml#/components/responses/Created'
index b782416..a4d94ce 100755 (executable)
@@ -214,7 +214,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
     @Override
     public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String cmHandle,
                                                                      final String resourceIdentifier,
-                                                                     final Object requestBody,
+                                                                     final String requestBody,
                                                                      final String contentType) {
         networkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle(cmHandle,
                 resourceIdentifier, requestBody, contentType);
index 613243e..9f2b4e1 100644 (file)
@@ -232,7 +232,7 @@ class NetworkCmProxyControllerSpec extends Specification {
             response.getContentAsString() == '{valid-json}'
     }
 
-    def 'Create Resource Data from pass-through running using POST.' () {
+    def 'Create Resource Data from pass-through running with #scenario.' () {
         given: 'resource data url'
             def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
                     "/testResourceIdentifier"
@@ -240,13 +240,17 @@ class NetworkCmProxyControllerSpec extends Specification {
             def response = mvc.perform(
                     post(getUrl)
                             .contentType(MediaType.APPLICATION_JSON_VALUE)
-                            .accept(MediaType.APPLICATION_JSON_VALUE).content('{"some-json":"value"}')
+                            .accept(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
             ).andReturn().response
         then: 'ncmp service method to create resource called'
             1 * mockNetworkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle('testCmHandle',
-                    'testResourceIdentifier', ['some-json':'value'], 'application/json;charset=UTF-8')
+                    'testResourceIdentifier', requestBody, 'application/json;charset=UTF-8')
         and: 'resource is created'
             response.status == HttpStatus.CREATED.value()
+        where: 'given request body'
+            scenario                        |  requestBody
+            'body contains " and new line'  |  'body with " quote and \n new line'
+            'body contains normal string'   |  'normal request body'
     }
 
     def 'Get module references for the given dataspace and cm handle.' () {
index 60669b9..2f91ed3 100644 (file)
@@ -153,7 +153,7 @@ public interface NetworkCmProxyDataService {
      */
     void createResourceDataPassThroughRunningForCmHandle(@NotNull String cmHandle,
                                                          @NotNull String resourceIdentifier,
-                                                         @NotNull Object requestBody,
+                                                         @NotNull String requestBody,
                                                          String contentType);
 
     /**
index a28b73c..ff9502d 100755 (executable)
@@ -202,7 +202,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
     @Override
     public void createResourceDataPassThroughRunningForCmHandle(final @NotNull String cmHandle,
                                                                 final @NotNull String resourceIdentifier,
-                                                                final @NotNull Object requestBody,
+                                                                final @NotNull String requestBody,
                                                                 final String contentType) {
         final var cmHandleDataNode = fetchDataNodeFromDmiRegistryForCmHandle(cmHandle);
         final var dmiServiceName = String.valueOf(cmHandleDataNode.getLeaves().get(NCMP_DMI_SERVICE_NAME));
index 9ed78de..4f6f0ef 100644 (file)
@@ -49,6 +49,6 @@ public class GenericRequestBody   {
 
     private OperationEnum operation;
     private String dataType;
-    private Object data;
+    private String data;
     private Map<String, String> cmHandleProperties;
 }