https://linen.dev logo
#help
Title
# help
a

Anthony Tang

06/27/2023, 1:21 PM
Hi Wiremock! Hoping to get some thoughts on something I’m trying to implement. I have a WireMock service that receives 2 different API requests: swapIDs and getDetails. I want to make the response template for the getDetails request dependent on the number of swapID requests with a certain deviceID. The count response that I get from the verify API with a matching condition does what I want information wise, but is there a good way to make this call and return a response body dependent on the count? Response logic would be something like if count>=2 return “active”:true and “inactive” when <2. Appreciate any thoughts or ideas. Thank you in advance!
o

Oleg Nenashev

06/27/2023, 3:25 PM
It can be done by unwrapping the response sequence to stateful behavior, but a more graceful implementation would require an extension that stores the context
a

Anthony Tang

06/27/2023, 4:00 PM
I see, thank you very much! Is it possible to filter for a match on a field from a previous request in the scenario? I was able to implement stateful scenarios like the documentation, but no notion of the deviceID is controlled for. If deviceIDs are 000 and 111 Can the state associated with 000 be "Started State 1" while 111's is in "Continue State 2"? Seems like that would then be a non-finite state machine but I may not be thinking creatively enough with matching.