Wiremock

Dockerで構築

docker run --rm -itd mock rodolpheche/wiremock:2.23.2

mappings/hello.json

{
  "request": {
    "method": "POST",
    "url": "/hello"
  },
  "response": {
    "status": 200,
    "body": "hello."
  }
}

Ref:
http://wiremock.org/docs/stubbing/
http://wiremock.org/docs/request-matching/

特定のリクエストに対するレスポンスの例:

{
  "request": {
    "method": "POST",
    "url": "/hello",
    "bodyPatterns" : [ {
      "equalToJson" : "{ \"val\": 1 }",
      "ignoreExtraElements" : true
    } ]
  },
  "response": {
    "status": 200,
    "body": "{ \"result\": \"hello\" }"
  }
}