Create WireMock stubs via Kotlin DSL
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
}
}
}
}