Service Virtualization

Expand all | Collapse all

data driven request using odd even request

  • 1.  data driven request using odd even request

    Posted 05-21-2019 10:00 AM

    Hi,

     

    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.

     

    Thanks



  • 2.  Re: data driven request using odd even request

    Posted 05-22-2019 03:47 AM

    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:

    • regex: .*[02468] for the even number transaction
    • regex: .*[13579] for the uneven number transaction 

     

    Apologies, I do not have the bandwidth to provide screenshots.

     

    Cheers,

    DAnny



  • 3.  Re: data driven request using odd even request

    Posted 05-22-2019 07:08 AM

    Hi DannySaro,

     

    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?

     

    Thanks,

    Suvendu