@@ -9,6 +9,7 @@ package com.salesforce.revoman.output.report
99
1010import arrow.core.Either.Left
1111import arrow.core.Either.Right
12+ import com.salesforce.revoman.internal.postman.template.Environment.Companion.fromMap
1213import com.salesforce.revoman.output.ExeType
1314import com.salesforce.revoman.output.postman.PostmanEnvironment
1415import com.salesforce.revoman.output.report.TxnInfo.Companion.uriPathContains
@@ -23,6 +24,7 @@ import io.vavr.control.Either.left
2324import io.vavr.control.Either.right
2425import org.http4k.core.Request
2526import org.http4k.core.Response
27+ import org.http4k.format.ConfigurableMoshi
2628
2729data class StepReport
2830internal constructor (
@@ -31,20 +33,23 @@ internal constructor(
3133 @JvmField val preHookFailure: PreHookFailure ? = null ,
3234 @JvmField val responseInfo: Either <out ResponseFailure , TxnInfo <Response >>? = null ,
3335 @JvmField val postHookFailure: PostHookFailure ? = null ,
34- @JvmField val envSnapshot: PostmanEnvironment <Any ?> = PostmanEnvironment ()
36+ private val moshiReVoman: ConfigurableMoshi ,
37+ @JvmField val envSnapshot: PostmanEnvironment <Any ?> = PostmanEnvironment (),
3538) {
3639 internal constructor (
3740 step: Step ,
3841 requestInfo: arrow.core.Either <RequestFailure , TxnInfo <Request >>? = null ,
3942 preHookFailure: PreHookFailure ? = null ,
4043 responseInfo: arrow.core.Either <ResponseFailure , TxnInfo <Response >>? = null ,
41- postHookFailure: PostHookFailure ? = null
44+ postHookFailure: PostHookFailure ? = null ,
45+ moshiReVoman: ConfigurableMoshi ,
4246 ) : this (
4347 step,
4448 requestInfo?.toVavr(),
4549 preHookFailure,
4650 responseInfo?.toVavr(),
4751 postHookFailure,
52+ moshiReVoman,
4853 )
4954
5055 @JvmField
@@ -60,6 +65,11 @@ internal constructor(
6065 @JvmField
6166 val isHttpStatusSuccessful: Boolean = failure?.fold({ it !is PostHookFailure }, { true }) != true
6267
68+ @get:JvmName(" envSnapShotInPostmanEnvJSONFormat" )
69+ val envSnapShotInPostmanEnvJSONFormat: String by lazy {
70+ moshiReVoman.prettify(moshiReVoman.asFormatString(fromMap(envSnapshot, moshiReVoman)))
71+ }
72+
6373 companion object {
6474 private fun failure (
6575 requestInfo : Either <out ExeFailure , TxnInfo <Request >>? = null,
@@ -110,7 +120,7 @@ internal constructor(
110120 @JvmStatic
111121 fun Either <out RequestFailure , TxnInfo <Request >>?.containsHeader (
112122 key : String ,
113- value : String
123+ value : String ,
114124 ): Boolean = this ?.fold({ false }, { it.containsHeader(key, value) }) ? : false
115125 }
116126
0 commit comments