Swa*_*wal 5 scala hashmap hamcrest jsonpath gatling
我想比较<key,values>作为HashMap<String,String>()数据传递的jsonPath中的一些.我们怎样才能在加特检查中实现它?
val hashMap = new HashMap[String,String]()
hashMap.put("foo", "bar")
Run Code Online (Sandbox Code Playgroud)
或者我可以简单地检查这样的东西吗?
for (String key <- keyValue){
.check(jsonPath("$." + key.(is(hashMap.get(key)))))
}
Run Code Online (Sandbox Code Playgroud)
要么
.check(jsonPath.containsAll(hashMap.keySet), jsonPath.containsAll(hashMap.valueSet))
Run Code Online (Sandbox Code Playgroud)
或者我可以使用hamcrest或其他一些来比较这个HashMap和JsonPath.
.exec(http("my testl").post("/some_url").headers(common_header).body(bodyPayLoad).
asJSON.check(status.is(200)).check(jsonPath("$",Matchers.hasItems(hashMap)).saveAs("response"))).exec(session => {
val responseValue = session.get("response").asOption[String]
println(testCase + " REST API Response :" + responseValue)
session
}).pause(10)
Run Code Online (Sandbox Code Playgroud)
我怎么能得到它?