Hello,
Im using Websocket protocol during my simulation, and for one message I can got several responses. Only two of them are necessary for me to gather some data and the question is how can I handle such scenario when those two important responses can arrive in different order? For exmaple
WS - Send some message
Server respond - non-important response
Server respond - important response 1
Server respond - important response 2
WS - Send some message
Server respond - non-important response
Server respond - important response 2
Server respond - important response 1
Example of current implementation (hardcoded for specific order of responses)
.doWhile(checkForProperMessage).on(
pause(Duration.ofMillis(50))
.exec(sendMessage
.await(6).on(Checks.firstResponse)
.await(6).on(Checks.secondResponse)
))
Implementation of checks:
ws.checkTextMessage("First Response")
.matching(regex("\\d.+\"SOME_REGEX\".+"))
.check(regex("SOME_REGEX").captureGroups(2).saveAs("some_session_id));
If response will match my regex I have to store some part of the message cuz there is provided information about the delay which I have to use before sending next message to give user some time to do some action during WebSocket connection
ws.checkTextMessage("Second Response")
.matching(regex("SOME_REGEX)
.check(regex("(.+\"imageQuality\":\")(IMAGE_QUALITY_\\w+)(\".+)")
.captureGroups(2).saveAs(IMAGE_QUALITY_REQUEST_GROUP_KEY));
And here if response will match my regex I have to store some part of response to validate if doWhile step is satisfied or not
Both messages can appear at different order. Is there any way to handle such case?
BR
Mateusz