Last Updated: February 25, 2016
·
582
· prayagupd

Groovy foreach

def generateUrl(SearchRequest searchRequest){
        String url = TEST_URL
        boolean first = true

        searchRequest.requestParameters.each {key, value ->
            if (first)
                url += Constants.WHAT + key+Constants.EQUALS + value
            else
                url += Constants.AND + key + Constants.EQUALS + value
            first = false
        }

        println "SEARCH REQUEST => ${url}"

        url
    }