summaryrefslogtreecommitdiffstats
path: root/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-09-14 13:47:52 +0100
committertragait <rahul.tyagi@est.tech>2021-09-21 14:38:30 +0100
commitfa11e9cb799b9738d2295abd4690c142639b9250 (patch)
tree165fa9c085f2d87d53053af0e861e4bc12680583 /src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
parentaccefb1c6f1fbb2ab904acbf7d5f4eb33ef51cee (diff)
fix data from object to string
Also, make dmi service url configurable, change name of dmi creds env var Issue-ID: CPS-675 Issue-ID: CPS-634 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: I6fe794b3e65b6a3aae2a1698ea64a925238a18d3
Diffstat (limited to 'src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy')
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy16
1 files changed, 9 insertions, 7 deletions
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 a937c4e6..ac4fde3d 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
@@ -26,12 +26,8 @@ import org.onap.cps.ncmp.dmi.TestUtils
import org.onap.cps.ncmp.dmi.exception.DmiException
import org.onap.cps.ncmp.dmi.exception.ModuleResourceNotFoundException
import org.onap.cps.ncmp.dmi.exception.ModulesNotFoundException
-import org.onap.cps.ncmp.dmi.model.DataAccessReadRequest
-import org.onap.cps.ncmp.dmi.model.DataAccessWriteRequest
import org.onap.cps.ncmp.dmi.model.ModuleReference
import org.onap.cps.ncmp.dmi.model.ModuleSchemaList
-import org.onap.cps.ncmp.dmi.model.ModuleSchemaProperties
-import org.onap.cps.ncmp.dmi.model.ModuleSchemas
import org.onap.cps.ncmp.dmi.model.ModuleSet
import org.onap.cps.ncmp.dmi.model.ModuleSetSchemas
import org.onap.cps.ncmp.dmi.service.DmiService
@@ -207,12 +203,14 @@ class DmiRestControllerSpec extends Specification {
['prop1': 'value1', 'prop2': 'value2'])
}
- def 'Write data using passthrough running for a cm handle.'() {
+ def 'Write data using passthrough running for a cm handle using #scenario.'() {
given: 'write data for cmHandle url and jsonData'
def writeDataforCmHandlePassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running/some-resourceIdentifier"
- def jsonData = TestUtils.getResourceFileContent('WriteDataForCmHandle.json')
+ def jsonData = TestUtils.getResourceFileContent(requestBodyFile)
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',
+ expectedRequestData) >> '{some-json}'
when: 'write cmHandle passthrough running post api is invoked with json data'
def response = mvc.perform(
post(writeDataforCmHandlePassthroughRunning).contentType(MediaType.APPLICATION_JSON)
@@ -222,6 +220,10 @@ class DmiRestControllerSpec extends Specification {
response.status == HttpStatus.CREATED.value()
and: 'the data in the request body is as expected'
response.getContentAsString() == '{some-json}'
+ where: 'given request body and data'
+ scenario | requestBodyFile || expectedRequestData
+ 'data with normal chars' | 'dataWithNormalChar.json' || 'normal request body'
+ 'data with special chars' | 'dataWithSpecialChar.json'|| 'data with quote \" and new line \n'
}
def 'Get resource data for pass-through running from cm handle.'() {