diff --git a/dsl/src/main/kotlin/com/chutneytesting/kotlin/dsl/ChutneyActionExtensions.kt b/dsl/src/main/kotlin/com/chutneytesting/kotlin/dsl/ChutneyActionExtensions.kt index f8db47a..3e974b0 100644 --- a/dsl/src/main/kotlin/com/chutneytesting/kotlin/dsl/ChutneyActionExtensions.kt +++ b/dsl/src/main/kotlin/com/chutneytesting/kotlin/dsl/ChutneyActionExtensions.kt @@ -5,52 +5,61 @@ package com.chutneytesting.kotlin.dsl /** * Always success */ -fun ChutneyStepBuilder.SuccessAction() { - Implementation { - type = "success" - } +fun ChutneyStepBuilder.SuccessAction(outputs: Map = mapOf(), validations: Map = emptyMap()) { + implementation = ChutneyStepImpl( + type = "success", + outputs = outputs, + validations = validations + ) } /** * Always fail */ -fun ChutneyStepBuilder.FailAction() { - Implementation { - type = "fail" - } +fun ChutneyStepBuilder.FailAction(outputs: Map = mapOf(), validations: Map = emptyMap()) { + implementation = ChutneyStepImpl( + type = "fail", + outputs = outputs, + validations = validations + ) } /** * Log values in the execution context */ -fun ChutneyStepBuilder.DebugAction(filters: List = listOf()) { - Implementation { - type = "debug" +fun ChutneyStepBuilder.DebugAction(filters: List = listOf(), outputs: Map = mapOf(), validations: Map = emptyMap()) { + implementation = ChutneyStepImpl( + type = "debug", inputs = listOf( "filters" to filters - ).notEmptyToMap() - } + ).notEmptyToMap(), + outputs = outputs, + validations = validations + ) } /** * Wait "5 min", "300 sec", "500 ms" or "until 14:34" */ -fun ChutneyStepBuilder.SleepAction(duration: String) { - Implementation { - type = "sleep" - inputs = mapOf("duration" to duration) - } +fun ChutneyStepBuilder.SleepAction(duration: String, outputs: Map = mapOf(), validations: Map = emptyMap()) { + implementation = ChutneyStepImpl( + type = "sleep", + inputs = mapOf("duration" to duration), + outputs = outputs, + validations = validations + ) } /** * Add variable to execution context */ -fun ChutneyStepBuilder.ContextPutAction(entries: Map, outs: Map = mapOf()) { - Implementation { - type = "context-put" - inputs = mapOf("entries" to entries) - outputs = outs - } +fun ChutneyStepBuilder.ContextPutAction(entries: Map, outputs: Map = mapOf(), validations: Map = emptyMap()) { + implementation = ChutneyStepImpl( + type = "context-put", + inputs = mapOf("entries" to entries), + outputs = outputs, + validations = validations + ) } /** @@ -77,8 +86,7 @@ fun ChutneyStepBuilder.FinalAction( "strategy-properties" to strategyProperties, "validations" to validations ).notEmptyToMap(), - outputs = outputs - ) + outputs = outputs) } /** @@ -761,7 +769,9 @@ fun ChutneyStepBuilder.ScpUploadAction( source: String, destination: String, timeout: String? = "", - strategy: Strategy? = null + strategy: Strategy? = null, + outputs: Map = mapOf(), + validations: Map = emptyMap() ) { implementation = ChutneyStepImpl( type = "scp-upload", @@ -771,8 +781,8 @@ fun ChutneyStepBuilder.ScpUploadAction( "destination" to destination, "timeout" to timeout ).notEmptyToMap(), - outputs = emptyMap(), - validations = emptyMap() + outputs = outputs, + validations = validations ) if (strategy != null) this.strategy = strategy } @@ -785,7 +795,9 @@ fun ChutneyStepBuilder.ScpDownloadAction( source: String, destination: String, timeout: String? = "", - strategy: Strategy? = null + strategy: Strategy? = null, + outputs: Map = mapOf(), + validations: Map = emptyMap() ) { implementation = ChutneyStepImpl( type = "scp-download", @@ -795,8 +807,8 @@ fun ChutneyStepBuilder.ScpDownloadAction( "destination" to destination, "timeout" to timeout ).notEmptyToMap(), - outputs = emptyMap(), - validations = emptyMap() + outputs = outputs, + validations = validations ) if (strategy != null) this.strategy = strategy } @@ -809,7 +821,9 @@ fun ChutneyStepBuilder.SftpUploadAction( source: String, destination: String, timeout: String? = "", - strategy: Strategy? = null + strategy: Strategy? = null, + outputs: Map = mapOf(), + validations: Map = emptyMap() ) { implementation = ChutneyStepImpl( type = "sftp-upload", @@ -819,8 +833,8 @@ fun ChutneyStepBuilder.SftpUploadAction( "destination" to destination, "timeout" to timeout ).notEmptyToMap(), - outputs = emptyMap(), - validations = emptyMap() + outputs = outputs, + validations = validations ) if (strategy != null) this.strategy = strategy } @@ -833,7 +847,9 @@ fun ChutneyStepBuilder.SftpDownloadAction( source: String, destination: String, timeout: String? = "", - strategy: Strategy? = null + strategy: Strategy? = null, + outputs: Map = mapOf(), + validations: Map = emptyMap() ) { implementation = ChutneyStepImpl( type = "sftp-download", @@ -843,8 +859,8 @@ fun ChutneyStepBuilder.SftpDownloadAction( "destination" to destination, "timeout" to timeout ).notEmptyToMap(), - outputs = emptyMap(), - validations = emptyMap() + outputs = outputs, + validations = validations ) if (strategy != null) this.strategy = strategy }