summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-09-14 13:55:05 +0100
committertragait <rahul.tyagi@est.tech>2021-09-17 16:58:37 +0100
commit868eca153be21b9faaae9ace99254a538ab270c6 (patch)
treeec2a42fae969612c89b4eb49501b7de49676a503
parentbd8ab2fc4737aebada59962baed8b35d4f86dd1c (diff)
fix data from object to string
Issue-ID: CPS-634 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: I13b20bc81a6109da32986088ddcf3d1814902a02
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java2
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java2
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java2
6 files changed, 13 insertions, 9 deletions
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index 5e2957f340..2e5eba754d 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -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'
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index b78241662e..a4d94cebfd 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -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);
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index 613243e28b..9f2b4e19a3 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -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.' () {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index 60669b9169..2f91ed30e1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -153,7 +153,7 @@ public interface NetworkCmProxyDataService {
*/
void createResourceDataPassThroughRunningForCmHandle(@NotNull String cmHandle,
@NotNull String resourceIdentifier,
- @NotNull Object requestBody,
+ @NotNull String requestBody,
String contentType);
/**
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index a28b73c427..ff9502d501 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -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));
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java
index 9ed78de6e7..4f6f0ef491 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java
@@ -49,6 +49,6 @@ public class GenericRequestBody {
private OperationEnum operation;
private String dataType;
- private Object data;
+ private String data;
private Map<String, String> cmHandleProperties;
}