Kotlin DSL library for WireMock
<dependency>
<groupId>io.github.siosio</groupId>
<artifactId>wiremockk</artifactId>
<version>1.1.0</version>
</dependency>import io.github.siosio.wiremockk.register
wireMock.register {
request {
method = RequestMethod.GET
url = "/test"
}
response {
status = 200
headers {
contentType("application/json")
header("x-test", "true")
}
body {
path("data/test.json")
}
}
}import io.github.siosio.wiremockk.register
wireMock.register {
request {
method = RequestMethod.POST
url = "/users"
body {
json(
"""
{
"user": {
"name": "siosio"
}
}
""".trimIndent(), false, true)
}
}
response {
status = 201
headers {
header("location", "users/1")
}
}
}import io.github.siosio.wiremockk.verify
wireMock.verify {
url = "/test"
method = RequestMethod.POST
headers {
header("Content-Type", "application/json")
}
body {
json("""{"test":"value"}""")
}
}