5

I want to compare some <key,values> in the jsonPath passed as HashMap<String,String>() data. How can we achieve it in gatling check ?

  val hashMap = new HashMap[String,String]()
  hashMap.put("foo", "bar")

OR can I simply check something like this ?

for (String key <- keyValue){
.check(jsonPath("$." + key.(is(hashMap.get(key)))))
}

OR

.check(jsonPath.containsAll(hashMap.keySet), jsonPath.containsAll(hashMap.valueSet))

Or can I use hamcrest or some other to compare this HashMap with 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)

How can I achive it?

Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92

0 Answers0