@@ -15,6 +15,8 @@ import com.salesforce.revoman.internal.postman.template.Url
1515import com.salesforce.revoman.output.Rundown
1616import com.salesforce.revoman.output.postman.PostmanEnvironment
1717import com.salesforce.revoman.output.report.StepReport
18+ import io.exoquery.pprint
19+ import io.github.oshai.kotlinlogging.KotlinLogging
1820import org.graalvm.polyglot.Context
1921import org.graalvm.polyglot.HostAccess
2022import org.graalvm.polyglot.Source
@@ -36,6 +38,7 @@ class PostmanSDK(
3638 lateinit var request: Request
3739 lateinit var response: Response
3840 lateinit var currentStepReport: StepReport
41+ @Suppress(" unused" )
3942 @JvmField val variables: Variables = Variables ()
4043 lateinit var rundown: Rundown
4144 @JvmField val xml2Json = Xml2Json { xml -> moshiReVoman.asA(U .xmlToJson(xml)) }
@@ -112,14 +115,21 @@ class PostmanSDK(
112115 evaluateJS(" jsonStr => JSON.parse(jsonStr)" ).execute(jsonStr)
113116
114117 inner class Variables {
115- fun has (variableKey : String ) = environment.containsKey(variableKey)
118+ fun has (key : String ) = environment.containsKey(key)
119+
120+ fun get (key : String ) = environment[key]
116121
117- fun get (variableKey : String ) = environment[variableKey]
122+ fun set (key : String , value : String ) {
123+ logger.info { " pm environment variable set through JS in Step: ${currentStepReport.step} - key: $key , value: ${pprint(value)} " }
124+ environment.set(key, value)
125+ }
118126
119- fun set (variableKey : String , value : String ) {
120- environment.set(variableKey, value)
127+ fun unset (key : String ) {
128+ logger.info { " pm environment variable unset through JS in Step: ${currentStepReport.step} - key: $key " }
129+ environment.unset(key)
121130 }
122131
132+ @Suppress(" unused" )
123133 fun replaceIn (stringToReplace : String ): String =
124134 regexReplacer.replaceVariablesRecursively(stringToReplace, this @PostmanSDK) ? : " "
125135 }
@@ -161,3 +171,5 @@ class PostmanSDK(
161171}
162172
163173data class Info (@JvmField val requestName : String )
174+
175+ private val logger = KotlinLogging .logger {}
0 commit comments