Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
feature(): Add output and validation fields to every actions (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
DelaunayAlex authored Feb 8, 2024
1 parent 1d6b0bf commit b327e84
Showing 1 changed file with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,61 @@ package com.chutneytesting.kotlin.dsl
/**
* Always success
*/
fun ChutneyStepBuilder.SuccessAction() {
Implementation {
type = "success"
}
fun ChutneyStepBuilder.SuccessAction(outputs: Map<String, Any> = mapOf(), validations: Map<String, Any> = emptyMap()) {
implementation = ChutneyStepImpl(
type = "success",
outputs = outputs,
validations = validations
)
}

/**
* Always fail
*/
fun ChutneyStepBuilder.FailAction() {
Implementation {
type = "fail"
}
fun ChutneyStepBuilder.FailAction(outputs: Map<String, Any> = mapOf(), validations: Map<String, Any> = emptyMap()) {
implementation = ChutneyStepImpl(
type = "fail",
outputs = outputs,
validations = validations
)
}

/**
* Log values in the execution context
*/
fun ChutneyStepBuilder.DebugAction(filters: List<String> = listOf()) {
Implementation {
type = "debug"
fun ChutneyStepBuilder.DebugAction(filters: List<String> = listOf(), outputs: Map<String, Any> = mapOf(), validations: Map<String, Any> = 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<String, Any> = mapOf(), validations: Map<String, Any> = emptyMap()) {
implementation = ChutneyStepImpl(
type = "sleep",
inputs = mapOf("duration" to duration),
outputs = outputs,
validations = validations
)
}

/**
* Add variable to execution context
*/
fun ChutneyStepBuilder.ContextPutAction(entries: Map<String, Any>, outs: Map<String, Any> = mapOf()) {
Implementation {
type = "context-put"
inputs = mapOf("entries" to entries)
outputs = outs
}
fun ChutneyStepBuilder.ContextPutAction(entries: Map<String, Any>, outputs: Map<String, Any> = mapOf(), validations: Map<String, Any> = emptyMap()) {
implementation = ChutneyStepImpl(
type = "context-put",
inputs = mapOf("entries" to entries),
outputs = outputs,
validations = validations
)
}

/**
Expand All @@ -77,8 +86,7 @@ fun ChutneyStepBuilder.FinalAction(
"strategy-properties" to strategyProperties,
"validations" to validations
).notEmptyToMap(),
outputs = outputs
)
outputs = outputs)
}

/**
Expand Down Expand Up @@ -761,7 +769,9 @@ fun ChutneyStepBuilder.ScpUploadAction(
source: String,
destination: String,
timeout: String? = "",
strategy: Strategy? = null
strategy: Strategy? = null,
outputs: Map<String, Any> = mapOf(),
validations: Map<String, Any> = emptyMap()
) {
implementation = ChutneyStepImpl(
type = "scp-upload",
Expand All @@ -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
}
Expand All @@ -785,7 +795,9 @@ fun ChutneyStepBuilder.ScpDownloadAction(
source: String,
destination: String,
timeout: String? = "",
strategy: Strategy? = null
strategy: Strategy? = null,
outputs: Map<String, Any> = mapOf(),
validations: Map<String, Any> = emptyMap()
) {
implementation = ChutneyStepImpl(
type = "scp-download",
Expand All @@ -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
}
Expand All @@ -809,7 +821,9 @@ fun ChutneyStepBuilder.SftpUploadAction(
source: String,
destination: String,
timeout: String? = "",
strategy: Strategy? = null
strategy: Strategy? = null,
outputs: Map<String, Any> = mapOf(),
validations: Map<String, Any> = emptyMap()
) {
implementation = ChutneyStepImpl(
type = "sftp-upload",
Expand All @@ -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
}
Expand All @@ -833,7 +847,9 @@ fun ChutneyStepBuilder.SftpDownloadAction(
source: String,
destination: String,
timeout: String? = "",
strategy: Strategy? = null
strategy: Strategy? = null,
outputs: Map<String, Any> = mapOf(),
validations: Map<String, Any> = emptyMap()
) {
implementation = ChutneyStepImpl(
type = "sftp-download",
Expand All @@ -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
}
Expand Down

0 comments on commit b327e84

Please sign in to comment.