ContributionsMost RecentMost LikesSolutionsRe: Autocomplete API :-Check a string parameter in the request matches the string value in the response? THIS WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :smileyhappy: :smileyhappy::smileyhappy: I cannot thank-you enough. I literally jumped for joy when it worked. All thanks to you. Thanks for your time and effort in helping me. Please look for my future questions ;-) Re: Autocomplete API :-Check a string parameter in the request matches the string value in the response? The API is returning the correct response. { "results": [ { "documentNumber": "123456789", "fileId": 0 }], "total": 1, "page": 1 The initial problem is a null response def response = context.expand( '${Retrieve a list of Document Numbers for autocomplete example 1#Response}' ).toString(); Re: Autocomplete API :-Check a string parameter in the request matches the string value in the response? Here is my solution again:- package json import com.eviware.soapui.support.XmlHolder import groovy.json.* // get the response of the JSON test step / request. def response = context.expand( '${Retrieve a list of Document Numbers for autocomplete example 1#Response}' ).toString(); log.info response; // set up a json slurper to parse the response string def autocompletenodesreturned = new JsonSlurper().parseText(response) log.info autocompletenodesreturned; // set N to the number of elements in the parsed response def n = autocompletenodesreturned.size() for (int i=0; i < n; i++) { log.info(autocompletenodesreturned[i].documentNumber); assert(autocompletenodesreturned[i].documentNumber.contains("123")); } Re: Autocomplete API :-Check a string parameter in the request matches the string value in the response? def response = context.expand( '${Retrieve a list of Document Numbers for autocomplete example 1#Response}' ).toString(); log.info response Returning a null response Re: Autocomplete API :-Check a string parameter in the request matches the string value in the response? Here is my solution as provided by you:- package json import com.eviware.soapui.support.XmlHolder import groovy.json.* // get the response of the JSON test step / request. def response = context.expand( '${#[AutoComplete#API: Retrieve a list of document numbers for autocomplete_valid (24554)#Retrieve a list of Document Numbers for autocomplete example 1]#Response}' ).toString(); // set up a json slurper to parse the response string def r = new JsonSlurper().parseText(response) // set N to the number of elements in the parsed response def n = r.size() for (int i=0; i < n; i++) { log.info(r[i].documentNumber); assert(r[i].documentNumber.contains("123")); } I am receiving the following error:- java.lang.String cannot be cast to java.lang.Integer Can you help? Thanks Re: Autocomplete API :-Check a string parameter in the request matches the string value in the response? Hi I will try the script this evening and get back to you with an update. Your time and effort in helping me is much appreciated. Autocomplete API :-Check a string parameter in the request matches the string value in the response? I am using a REST API to check for autocomplete Example Test Case:- Request I retrieve a list of Document Numbers I retrieve a list of Document Numbers for AutoComplete (parameter value I pass in is '123') Response Document Numbers containing 123 are returned. { "results": [ {"documentNumber": "112369353213670593"}, {"documentNumber": "120212364882313025"}, {"documentNumber": "123055742821186593"}, {"documentNumber": "123134986738657857"}, {"documentNumber": "123207962820539585"}, {"documentNumber": "1234567"}, {"documentNumber": "123456789"}, {"documentNumber": "123597020827608033"}, {"documentNumber": "123639294264534913"} Question, How do I assert the response FOR EACH NODE RETURNED AS ABOVE contains '123' OR better still if I pass in dynamic autocomplete search in the request each time and returning a dynamic number of document numbers/nodes in the RESPONSE? Can I please ask to add comments with your proposed solution as this will aid my own learning. Thanks for your time. SolvedRe: How to create a Groovy Script in order to perform assertions for sorting (ascending/descending) Hi. Thanks. I will try this and let you know if I can get it to work. Thanks so much for your time :-) :-) How to create a Groovy Script in order to perform assertions for sorting (ascending/descending) My API response returns customer file details and can sort a chosen field in ascending or descending order. Example, the JSON REST RESPONSE as detailed further below returns the 'UploadedBy' field as expected in ascending order. I now need to verify this. Can someone help me with a groovy script for this and PLEASE INCLUDE COMMENTS so that I can completely understand the code, for my own learning purposes. Thank-you, much appreciated. JSON RESPONSE "results": [ { "trackingEntryId": 24, "documentId": 24, "fileId": 24, "fileName": "Sample.xlsx", "status": "Success", "uploadedBy": "Gibson, Mike", "uploadedDate": "2017-06-21T08:31:23.2021627", "transactions": 1 }, { "trackingEntryId": 25, "documentId": 25, "fileId": 25, "fileName": Sample1.xlsx", "status": "Success", "uploadedBy": "Hill, Lucy", "uploadedDate": "2017-06-21T08:32:05.4842927", "transactions": 1 }, { "trackingEntryId": 26, "documentId": 26, "fileId": 26, "fileName": "TrackIT_Test4.xlsx", "status": "Success", "uploadedBy": "Sinatra, Frank", "uploadedDate": "2017-06-21T08:33:24.0482512", "transactions": 0 } SolvedRe: Assertions to verify items are being returned in alphabetical order/ascending/descending order etc In particular, what is the following statement doing? def getPropertyValues = { prop -> json.results."$prop"