خرید بک لینک

Vote count: 0

I have the following two methods:

def randomStartMethod() : Long = {
  var range = 1000L
  var r = ThreadLocalRandom.current().nextLong(10L*range)
  var randomStart = 1396024675000L + r
  retu randomStart
}

def randomStopMethod() : Long = {
  var range = 1000L
  val r = ThreadLocalRandom.current().nextLong(10L*range)
  val randomStop =  1396024675000L + r*2L
  retu randomStop
}

Then I add it to the request body like this:

val activity = repeat(10, "i") {
      exec(http("POST activity post")
        .post("/activity/")
        .header("Content-Type", "application/json; charset=ISO-8859-1")
        .header("USERID", "14986456963")
        .header("appId", "com.nike.sport.coect2")
        .header("accept", "*/*")
        .header("Authorization", "Bearer eyJhbGciOiJIUzI1NiJ9.eyJzY3AiOiJ2My1zeW5jLXBheWxvYWQiLCJleHAiOjc0MDk4NDc1OTUsInN1YiI6InYzLWxzcyIsImF1ZCI6WyJ2My1zeW5jLXNlcnZpY2UiXSwiaXNzIjoidjMtbHNzIn0.U2JZr3Y1MKKgZlc_p74byIWGeGewyoEvKkC5G4SoNTc")
        .body(StringBody(
          s"""
             |{
             |    "id": "activityId",
             |    "type": "run",
             |    "start_epoch_ms": "${randomStartMethod()}",
             |    "end_epoch_ms": "${randomStop()}",
             |    "metrics": [
             |        {
             |            "type": "distance",
             |            "unit": "KM",
             |            "source": "nike.ruing.ios",
             |            "values": [
             |                {
             |                    "start_epoch_ms": "${randomStartMethod()}",
             |                    "end_epoch_ms": "${randomStopMethod()}",
             |                    "value": 2.0
             |                }
             |
            |            ]
             |        }
             |    ]
             |}
          """.stripMargin)).
        asJSON
        .check(status.is(202))
        .check(
          jsonPath(
            "$.activityId").saveAs("message")
        )
        .check(bodyString.
          transform(_.split("""
          )(3)).saveAs(
          "changeToken"))

      ).exec(
        session => {
          val maybeId =
            session.get(
              "message").asOption[String]
          println(maybeId)
          session
        }
      )
    }
  }

But here the values are not generated dynamically when I use with feed. Can someone suggest how to generate the random numbers every time throughout the run?

asked 58 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 19 مرداد 1395 ساعت: 0:24

صفحه بندی