Service Virtualization

  • 1.  Generate random number dynamically in response

    Posted Jun 05, 2018 09:18 AM

    Hi,

    I am creating a virtual service, wherein the requirement is to generate a random number in the response. Say for example, i need the value of "Document number" to generate random 13 digit number which begins with 005 in the response.

    Also the "Document number" element is not present in the incoming request.

    I tried using regular expression in the response as  DocumentNumber = "^([0][0][5]\d{10})$"

    Not sure whether am following the right approach.

     

    Greatly appreciate any help.

     

    Thanks,

    Ganga



  • 2.  Re: Generate random number dynamically in response
    Best Answer

    Broadcom Employee
    Posted Jun 05, 2018 09:37 AM

    For generating a random 13 digit number starting with 005, you can use the following pattern expression in your response

     

    {{=[::005DDDDDDDDDD]}}

     

    To learn more about String patterns refer to the link below

     

    https://docops.ca.com/devtest-solutions/10-3/en/using/using-ca-application-test/using-devtest-workstation-with-ca-application-test/building-test-cases/properties/string-patterns



  • 3.  Re: Generate random number dynamically in response

    Posted Jun 06, 2018 01:11 AM

    Thank you Prem. It works.