How to read Session attributes outside of Gatling DSL


I would like to read the Session Map after a call to a feeder in a Scala function.

Assume here is my code :

class RechercheUSParCriteresIdsMonoValueEvol extends Simulation {

// some Stuff

object consultationService {

def rechercheUS (pTypeUS: String, IdFoncUS: String = “IDENTIFIANT”, nbIdFoncUS: Int = 0) : ChainBuilder = {

return exec { session =>
var pCriteres : String = “”
if (nbIdFoncUS != 0){
pCriteres = pCriteres + generateBuilder(IdFoncUS, nbIdFoncUS)
val newsession = session.set(“pCritere”, pCriteres).set(“pTypeUS”, pTypeUS)
soapPost(“RECHERCHE_ID_FONC_US”, urlService, “Request_rechercherUnitesStructurellesParCriteres.txt”)

def generateBuilder (tCritere : String, nbTCritere: Int) : String = {
val session: Session = ???

var valeursCriteres : List[String] = List()

for ( x ← 0 to nbTCritere - 1) {
feed(usiFeeder) → must inject data in the session
valeursCriteres = session(“idFonctionnelUs”).as[String] :: valeursCriteres
return (new pCriteres(true, tCritere, valeursCriteres)).toString()

// Some stuff


The compilation is OK, but at runtime I got this exception on the line where I declare ( val session: Session = ??? )

Exception in thread “main” scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
at consultationService .RechercheUS.(RecordedSimulation.scala:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at scala.Option.getOrElse(Option.scala:121)

Any Idea on what happened ?


??? is exactly that: something that throws a NotImplementedError at runtime.

It’s used as an intermediate step to write down all your logic while coding but you’re not finished implementing yet.
You shouldn’t be using it here and expect the Simulation to work.

Ok i was asking myself what was then meaning of ???.

So how could i fetch the Session and use them like : valeursCriteres = session(“idFonctionnelUs”).as[String] :: valeursCriteres without need to do exec { session => …