简体   繁体   中英

How to pass HashMap values as a queryParam to Gatling simulation

I need help for passing HashMap to queryParam as shown below, as I have so many request with same queryParams and just last queryParam changes with each request.

val asset_sort_by_displays = exec(http("Sort by Displays")
 .get("/data/analytics/reports/")
 .queryParamMap(GatlingConfig.asset_query_string_map)
 .queryParam("""sort""", """displays""")

Where in my config file I have a object GatlingConfig{} where I've defined asset_query_string_map as.

val asset_query_string_map = Map("""report_type""" -> """performance""",
 """start_date""" -> "2014-07-07",
 """end_date""" -> "2014-07-10",
 """metrics""" ->  """plays""",
 """metrics""" -> """displays""",
 """metrics""" -> """video_starts""")

But, it throws " value asset_query_string_map is not a member of io.gatling.http.request.builder.HttpRequestBuilder " error.

Please guide me , how can I pass Map value to queryParams?

Where in my config file I have created

I don't get it. This is to be defined in some Scala code and imported/placed in scope.

Then, queryParam is for unique values. You'd have to use queryParamMap instead.

With current snapshot, you'd have:

val asset_query_string_map = Map("""report_type""" -> """performance""",
   """start_date""" -> "2014-07-07",
   """end_date""" -> "2014-07-10",
   """metrics""" ->  """plays""",
   """metrics""" -> """displays""",
   """metrics""" -> """video_starts""")

val asset_sort_by_displays = exec(http("Sort by Displays")
  .get("/data/analytics/reports/")
  .queryParamMap(asset_query_string_map)
  .queryParam("""sort""", """displays"""))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM