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

Commit

Permalink
fix() : ignore empty parameters of strategies in generated json files
Browse files Browse the repository at this point in the history
  • Loading branch information
Redouane-E committed Feb 15, 2021
1 parent 0b5c7fa commit a0540b0
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class ChutneyScenarioBuilder(val id: Int? = null, val title: String = "") {
}

fun build(): ChutneyScenario = ChutneyScenario(id, title, description, givens, `when`, thens)

}

@JsonInclude(NON_EMPTY)
open class Strategy(val type: String, val parameters: Map<String, String> = emptyMap())
open class RetryTimeOutStrategy(timeout: String, retryDelay: String) :
Strategy(type = "retry-with-timeout", parameters = mapOf("timeOut" to timeout, "retryDelay" to retryDelay))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.junit.Test
class ChutneyScenarioDslTest {

@Test
fun `abe to create chutney scenario using kotlin dsl`() {
fun `able to create chutney scenario using kotlin dsl`() {

val `swapi GET people record` = Scenario(title = "swapi GET people record") {
Given("I set get people service api endpoint") {
Expand Down Expand Up @@ -111,4 +111,27 @@ class ChutneyScenarioDslTest {

}

@Test
fun `abe to create chutney scenario using kotlin dsl with softAssertions`() {

fun declareUri(): ChutneyStepBuilder.() -> Unit = { ContextPutTask(entries = mapOf("uri" to "api/people/1")) }

val `swapi GET people record` = Scenario(title = "swapi GET people record") {
Given("I set get people service api endpoint", declareUri())
When("I send GET HTTP request") {
HttpGetTask(target = "swapi.dev", uri = "uri".spEL())
}
Then("I receive valid HTTP response", strategy = SoftAssertStrategy()) {
JsonAssertTask(
document = "body".spEL(),
expected = mapOf("$.name" to "Luke Skywalker", "$.species" to emptyArray<String>())
)
}
}

// create this file get-people-multiple-assertions-soft-strategy.chutney.json
"$`swapi GET people record`" `should equal json` "/get-people-multiple-assertions-soft-strategy.chutney.json".asResource()

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"title": "swapi GET people record",
"description": "swapi GET people record",
"givens": [
{
"description": "I set get people service api endpoint",
"implementation": {
"type": "context-put",
"inputs": {
"entries": {
"uri": "api/people/1"
}
}
}
}
],
"when": {
"description": "I send GET HTTP request",
"implementation": {
"type": "http-get",
"target": "swapi.dev",
"inputs": {
"uri": "${#uri}",
"timeout" : "2 sec"
}
}
},
"thens": [
{
"strategy": {
"type": "soft-assert"
},
"description": "I receive valid HTTP response",
"implementation": {
"type": "json-assert",
"inputs": {
"document": "${#body}",
"expected": {
"$.name": "Luke Skywalker",
"$.species": []
}
}
}
}
]
}

0 comments on commit a0540b0

Please sign in to comment.