/wiremock-kotlin

Kotlin DSL support for WireMock

Primary LanguageKotlin

wiremock-kotlin CI build status

Create WireMock stubs via Kotlin DSL

Example

data class Song(val title: String)

stubFor {
    get {
        url equalTo "/my-api"
        willReturn {

            headers = mapOf("Content-Type" to "application/json")

            body jsonFromObject Song("The revenge of Vera Gemini")
        }
    }

    post {
        url matching "/your/([a-z]*)\\?and=query"
        
        willReturn { 
            status = 201
            body.file("my/path/example.json")
            fixedDelay { 
                milliseconds = 3000
            }
        }
    }
}