My question is regarding data - driven virtual service.
I have a swagger file which i need to virtualize. I am running the swagger file in the browser : 'http://<server>:<port>/v2/pet/1'. Running this getting the response..
I have two rows in the excel sheet with two "id" columns and 2 responses
Now the requirement is: i) if i pass any odd number to the request_id it should pick one response and (ii) if even it should pick another response.
An Example: 'http://<server>:<port>/v2/pet/**odd_number**' it should give first row response
and if 'http://<server>:<port>/v2/pet/**even_number**' it should give second row response
Please provide an answer with screenshot if possible.
I am assuming you have applied the REST DPH with an appropriate rule you now have the number as an argument of your transaction signature inside your .vsi file.
You will have 2 specific transactions, one specific transaction containing the response for the even number, one for the odd number.
By default the comparison operator for the "number" argument will be equal (=), change that to regex and put the following:
Apologies, I do not have the bandwidth to provide screenshots.
This was helpful. Thank you so much..
It will be helpful if you share how to do it from writing JSR-223 script in the .vsm file by getting the arguments from the .vsi and apply some logical coding?