'Wiremock Standalone: dynamic response based on current day
I would like to mock API that returns the state of third party service. And there are a lot of them. So, to cover our logic related to those statuses, I would like my mock to return different statuses based on the day of the week when it is called. It will allow to test all statuses within 1 week. But it should be predefined as in tests I should know what status was returned to our back end to calculate expected results. So, bare. randomizer won't work.
The JSON example is the following
...
"state": {
"state_message": ,
"life_cycle_state": TERMINATED,
"result_state": "SUCCESS",
"user_cancelled_or_timedout": false
},
...
So, that life_cycle_state should be changing I was trying with response-template and contains functions. Like this:
"life_cycle_state": {{#contains "Sat Sun Mon" '{{now timezone="UTC" format="EEE"}}'}}"RUNNING"{{/contains}},
But it looks like wire mock does not understand that now is a function and treats it as string How could I achieve expected behavior?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
