Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
976 B
1
Indexable
Never
class WebClientUtilsSpec extends Specification {
    static def BASE_URL = 'https://www.example.com'

    def "that proper url is built with given parameters"() {
        when:
        def url = WebClientUtils.interpolateUriVariables(uri, variables)

        then:
        url == expectedUrl

        where:
        variables                                                  | uri                                                             || expectedUrl
        ['firstParam': 'firstValue']                               | BASE_URL + '?firstParam={firstParam}'                           || BASE_URL + '?firstParam=firstValue'
        ['firstParam': 'firstValue', 'secondParam': 'secondValue'] | BASE_URL + '?firstParam={firstParam}&secondParam={secondParam}' || BASE_URL + '?firstParam=firstValue&secondParam=secondValue'
        ['invalidParam': 'invalidValue']                           | BASE_URL                                                        || BASE_URL
    }
}