Injection model

Hi dear community my code looks like this, it is served for accepting all information from cmd
The issue is that I would like to understand how to combine these two methods into one

object InjectionProfileParser {
  def parse(profile: String): OpenInjectionStep = {
    val pattern: Regex = "\\w+".r

    pattern.findFirstIn(profile) match {
      case Some("atOnceUsers") => atOnceUsers(config.users)
      case Some("rampUsers") => rampUsers(config.users).during(config.duration.seconds)
      case Some("constantUsersPerSec") => constantUsersPerSec(config.users) during (config.duration.seconds)
      case Some("rampUsersPerSec") => rampUsersPerSec(config.users).to(config.maxUsers).during(config.duration.seconds)
      case Some("stressPeakUsers") => stressPeakUsers(config.users).during(config.duration.seconds)
      //case Some("rampConcurrentUsers")
      case _ => throw new IllegalArgumentException(s"Invalid injection profile: $profile")
    }
  }

  def parseClosed(profile: String): ClosedInjectionStep = {
    val pattern: Regex = "\\w+".r

    pattern.findFirstIn(profile) match {
      case Some("constantConcurrentUsers") => constantConcurrentUsers(config.users).during(config.duration.seconds)
      case _ => throw new IllegalArgumentException(s"Invalid injection profile: $profile")
    }
  }
}

below is example how I call it.

class Api_test_surfing_no_auth extends Simulation {

private val load_surfing_no_auth = Scenario_surfing_no_auth.scenario_surfing_no_auth
  .inject(InjectionProfileParser.parse(injectionProfile))
  setUp(
    load_surfing_no_auth
    )

}

Any ideas?

Hello,

What your issue about merging the two functions?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.