Skip to content

Commit

Permalink
Pick up non-202 response if present else pick 202 response while resp…
Browse files Browse the repository at this point in the history
…onding from a virtual-service
  • Loading branch information
yogeshnikam671 committed Nov 21, 2024
1 parent 8f6da19 commit 3d5c542
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,19 @@ class StatefulHttpStub(
}

private fun Map<Int, ResponseDetails>.responseWithStatusCodeStartingWith(value: String): ResponseDetails? {
val responseDetailMatchingPredicate: (Int, ResponseDetails) -> Boolean = { statusCode, responseDetails ->
statusCode.toString().startsWith(value) && responseDetails.successResponse != null
}

val non202Response = this.entries.filter {
it.key != 202
}.firstOrNull {
responseDetailMatchingPredicate(it.key, it.value)
}?.value
if(non202Response != null) return non202Response

return this.entries.firstOrNull {
it.key.toString().startsWith(value) && it.value.successResponse != null
responseDetailMatchingPredicate(it.key, it.value)
}?.value
}

Expand Down

0 comments on commit 3d5c542

Please sign in to comment.