An Assertion To Verify Repeating Attribute Contains All Upper Case Chars?
Hey!
nmrao and New2API have repeatedly helped me with some scripts to check repeating attributes in my .json response has certain attributes.
I now have tests that require me to verify a repeating attribute in the response contains only upper case characters.
The following is a script to verify that the repeating 'Name' attribute (repeated 1000s of times) in my .json response is always null
//All Rao's work
assert context.response, 'Request parameter is correct'
def json = new groovy.json.JsonSlurper().parseText(context.response)
assert json.data.Name.every{null == it}
//assert json.data.Name.every{context.expand('${REST Request#Name}').toInteger() == it}
I was wondering if the above could be altered to assert that an attribute in the attached .json response (DataSourceId_Name) is all UPPER CASE ONLY?
I tried googling for groovy methods relating to upper case - but I didn't find anything that I could tailor to what I need - I found the following link but I don't know how to alter the above assertion to get what I need
Cheers lads/ladies,
richie
- richie,
See adding this to existing script and helps!
//assumes json is defined and field name is DataSourceId_Name
json.data.DataSourceId_Name.each {
assert it == it.toUpperCase()
}