WireMock: Request Matching
JSONを書いて設定できる
キーはrequest
method:HTTPメソッド
以下にJSONを設定するためのキーを示す
URL matching
url:クエリパラメタまで見る + 厳密一致
urlPattern:クエリパラメタまで見る + 正規表現も使える
urlPath:パスだけの厳密一致
urlPathPattern:パスだけ + 正規表現も使える
Matching other attributes
All request attributes other than the URL can be matched using the following set of operators.
「URL以外のリクエストの属性は以下の演算子の集合を使ってマッチさせられる」
headersで例
equalTo:属性の値が期待値と完全一致
caseInsensitiveも指定可能
contains:属性の値の部分文字列(substring)が一致
doesNotContain
queryParametersで例
パラメタ名をキーにする
matches:正規表現を使ってマッチ
doesNotMatch
bodyPatternsで例
equalToJson:JSONとマッチ
JSONでも書けるし、文字列リテラルとしても書ける
ignoreArrayOrder
ignoreExtraElements
Placeholders
"${json-unit.any-string}"
任意の文字列を表せる
特定のキー、値は任意のJSONとequalToJsonするのに使う
matchesJsonPath:JSON Pathでマッチ(試したい)
"matchesJsonPath" : "$.name"
リクエストボディのJSONにnameというキーがある
期待値としてtrue/falseを返す式も書ける
正規表現も使える
サイズ
ネストしたJSONにはexpressionを使う例(TODO)
equalToXml
matchingXPath
matcher
hasExactly
include
IMO:違いはなんだろう?
"absent" : true
Deems a match if the attribute specified is absent from the request.
Multipart/form-data(TODO)
Basic Authentication
Dates and times
Logical AND and OR
パターンのANDやORが定義できる!(TOD)