Forum Discussion
richie, here is what you can do to overcome this Uppercase' issue. it is bit ugly but may work.
import net.sf.* import net.sf.json.* import net.sf.json.groovy.* import groovy.json.JsonSlurper def response = new File(context.expand( '${#TestSuite#ResponsePath}') + 'Untitled1.json').text def slurper = new JsonSlurper() def json = slurper.parseText response def actual = [] json.data.DataSourceId_Name.each{ actual = actual+it //Get all DataSourceId_Name } //Get unique value from the 'actual' array and loop through actual.unique().each{ log.info it it.toUpperCase() == it //Convert each array element to uppercase and compare it to itself }
Hey lads!
New2API - thank you - I appreciate your efforts on my behalf - but I don't think I explained it clearly enough.
The attached file was an example - but I won't be using it for comparison - that is one of the responses I need to verify the fields display only upper case., so I'm grateful for your help fella - but that's not what I need.
Lucian - another reason I'm using scripts for a lot of my assertions it that I've a mix of OTB functionality REST requests and requests build by a script nmrao put together cos I can't use the OTB functionality to build and submit some of my requests - it doesn't do what I need - hence the reason for the scripting - @Rao's script builds the URI and query string from parameters set in a Properties step.
I do have REST requests that use the OTB functionality - so using the OTB assertion functionality for those requests is fine, but for the requests built and submitted by @Rao's script I can't use the OTB assertions for those.
I have attached an example file
There is a field - JSONPATH = x.data[x].DataSourceId_Name OR $[data][x][DataSourceId_Name] that should ONLY ever have upper case chars.
I am hoping to create an assertion that does this verification - however the response can have many, many records in there - so I can't just add in loads of values to an array as a possible way to assert these values against.
I hope I've been clear in my request!
nice one,
richie
Related Content
- 5 years ago
Recent Discussions
- 18 days ago