POST /__admin/mappings/reset
mockServer
.stubFor(
get(urlPathEqualTo("/nextBusinessDay"))
.willReturn(
aResponse()
.withHeaders(new HttpHeaders(
HttpHeader.httpHeader("content-type", "application/json")
))
.withJsonBody(
JsonNodeFactory
.instance
.objectNode()
.put("nextBusinessDay",
LocalDateTime
.now()
.plusDays(1)
.format(API_DATE_FORMATTER)
)
)
)
);
java -jar wiremock-standalone-2.10.1.jar
Criando mock via API
$ curl -X POST \
--data '{ "request": { "url": "/get/this", "method": "GET" }, "response": { "status": 200, "body": "Here it is!\n" }}' \
http://localhost:8080/__admin/mappings/new
Testando
$ curl http://localhost:8080/get/this
Here it is!
Criando mock via arquivo (tem que derrubar e subir o server depois de criar/deletar o arquivo)
{
"request": {
"method": "GET",
"url": "/api/mytest"
},
"response": {
"status": 200,
"body": "More content\n"
}
}
Testando
$ curl -XGET localhost:8080/api/mytest
wiremock commands