Last active
June 20, 2023 12:35
-
-
Save aartajew/3958dc76856d42e982f797b3930247f8 to your computer and use it in GitHub Desktop.
Gatling > Parse Expression Language string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import io.gatling.core.session._ | |
object ElParser { | |
def apply[T](expression: Expression[T], session: Session): T = toOption(expression, session).get | |
def toOption[T](expression: Expression[T], session: Session): Option[T] = expression(session).toOption | |
} | |
// usage | |
val expression: Expression[String] = "#{sessionId}" | |
val sessionId = ElParser(expression, session) | |
// type hinting | |
val userId = ElParser[String]("#{userId}", session) | |
val userData = ElParser[Map[String, Any]]("#{userData}", session) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment