summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-09-02 12:32:35 +0100
committertragait <rahul.tyagi@est.tech>2021-09-03 16:04:36 +0100
commitb53a57901dd73270a4389109b0df8ca5c02a9e22 (patch)
tree81b97e1a62c718bb0a8dc1337beba430344be43c /src
parentf5de1ae2fe4b092d76c39a995d187cc509722c12 (diff)
fix data type as string for dmi request body
Issue-ID: CPS-634 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: Ib3d9d7cab12c77332d799b89e73e5a9b934a4473
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java13
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy2
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy2
-rw-r--r--src/test/resources/WriteDataForCmHandle.json4
5 files changed, 6 insertions, 17 deletions
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
index f1446084..7f79a04c 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
@@ -106,5 +106,5 @@ public interface DmiService {
* @return response from sdnc
*/
String writeResourceDataPassthroughForCmHandle(String cmHandle, String resourceIdentifier, String dataType,
- Object data);
+ String data);
} \ No newline at end of file
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
index 216190e3..87936bb7 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
@@ -207,18 +207,9 @@ public class DmiServiceImpl implements DmiService {
@Override
public String writeResourceDataPassthroughForCmHandle(final String cmHandle, final String resourceIdentifier,
- final String dataType, final Object data) {
- final String jsonData;
- try {
- jsonData = objectMapper.writeValueAsString(data);
- } catch (final JsonProcessingException e) {
- log.error("JSON exception occurred when processing pass through request data for the given cmHandle {}",
- cmHandle);
- throw new DmiException("Unable to process incoming JSON from the request body.",
- "JSON exception occurred when writing data for the given cmHandle " + cmHandle, e);
- }
+ final String dataType, final String data) {
final ResponseEntity<String> responseEntity =
- sdncOperations.writeResourceDataPassthroughRunning(cmHandle, resourceIdentifier, dataType, jsonData);
+ sdncOperations.writeResourceDataPassthroughRunning(cmHandle, resourceIdentifier, dataType, data);
if (responseEntity.getStatusCode() == HttpStatus.CREATED) {
return responseEntity.getBody();
} else {
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 e08870fd..c32608c0 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
@@ -212,7 +212,7 @@ class DmiRestControllerSpec extends Specification {
def writeDataforCmHandlePassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running/some-resourceIdentifier"
def jsonData = TestUtils.getResourceFileContent('WriteDataForCmHandle.json')
and: 'dmi service is called'
- mockDmiService.writeResourceDataPassthroughForCmHandle('some-cmHandle', 'some-resourceIdentifier', 'application/json', ['some-data': 'some-value']) >> '{some-json}'
+ mockDmiService.writeResourceDataPassthroughForCmHandle('some-cmHandle', 'some-resourceIdentifier', 'application/json', '{ some data }') >> '{some-json}'
when: 'write cmHandle passthrough running post api is invoked with json data'
def response = mvc.perform(
post(writeDataforCmHandlePassthroughRunning).contentType(MediaType.APPLICATION_JSON)
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
index 1d2cf7f3..7891450d 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
@@ -266,7 +266,7 @@ class DmiServiceImplSpec extends Specification {
mockObjectMapper.writeValueAsString(_) >> jsonString
when: 'write resource data for pass through method is invoked'
objectUnderTest.writeResourceDataPassthroughForCmHandle('some-cmHandle',
- 'some-resourceIdentifier', 'some-dataType', new Object())
+ 'some-resourceIdentifier', 'some-dataType', 'some-json-data')
then: 'a dmi exception is thrown'
thrown(DmiException.class)
where: 'the following combinations are tested'
diff --git a/src/test/resources/WriteDataForCmHandle.json b/src/test/resources/WriteDataForCmHandle.json
index 8eb19599..178421fc 100644
--- a/src/test/resources/WriteDataForCmHandle.json
+++ b/src/test/resources/WriteDataForCmHandle.json
@@ -1,9 +1,7 @@
{
"operation": "create",
"dataType": "application/json",
- "data": {
- "some-data": "some-value"
- },
+ "data": "{ some data }",
"cmHandleProperties": {
"some-property": "some-property-value"
}