Forum Discussion
nmrao
8 years agoChampion Level 3
Script Assertion can be used to achieve the same and below is script:
assert context.rawRequest, 'Request is empty or null' assert context.response, 'Response is empty or null' //Closure to get the required data from json def getDataMap = { data, list -> def json = new groovy.json.JsonSlurper().parseText(data) json.inject([:]) {m, key, value -> if(key in list) m[key] = value;m } } def desiredKeys = ['storeId', 'registerNumber'] def reqestMap = getDataMap(context.rawRequest, desiredKeys) def responseMap = getDataMap(context.response, desiredKeys) println "Request data : $reqestMap" println "Response data : $responseMap" assert reqestMap == responseMap, 'Response data is not matching with request data'
The above one uses dynamic request and response.
Here is the script that you can try online quickly for your fixed data and see it working.
Related Content
- 8 years ago
Recent Discussions
- 6 days ago
- 10 days ago