Service Virtualization

  • 1.  If,elseif, else condtion or switch case

    Posted Dec 28, 2017 06:55 AM

    how to put if else condition of switch case in Ca lisa test step. I have to execute step based on condition for example if user select payment option credit card execute step1 if user selected payment option wallet execute ste2 otherwise execute step3



  • 2.  Re: If,elseif, else condtion or switch case

    Broadcom Employee
    Posted Dec 28, 2017 09:29 AM

    What version of DevTest are you on?



  • 3.  Re: If,elseif, else condtion or switch case

    Posted Dec 29, 2017 01:13 AM

    Thank you for reply my DevTest version is 10.0.0



  • 4.  Re: If,elseif, else condtion or switch case
    Best Answer

    Broadcom Employee
    Posted Dec 29, 2017 09:17 AM

    The only thing that comes to mind for this is to maybe use a companion.

     

    Refer to this documentation link:

    Execute Event-driven Subprocess Companion - DevTest Solutions - 10.0 - CA Technologies Documentation 

     

    Hope this helps.



  • 5.  Re: If,elseif, else condtion or switch case

    Posted Jan 03, 2018 05:02 AM

    Hello Marcy,

     

    Thank You for your time, I am very new to Devtest. If you provide me  devtest step it will be a great help for me.

     

    my requirement is below( say Amazon shopping site)

     

    Step 1 fetch list of product ID by hitting product list API:(ex: electronics, cloth, footwear and so on)

    Step 2 loop over list of product id fetched in step 1

    Step 3 hit API based on product id inside loop.

     

    ( explanation : say In first  iteration of loop product id is electronics hit electronics API, Second iteration product id is cloth hit cloth API and so on. So here I need to use if else or switch statement ).



  • 6.  Re: If,elseif, else condtion or switch case

    Posted Jan 03, 2018 03:18 PM
      |   view attached

    I cannot really comment on the use of the Event Companion.

    An alternative approach is to loop over the result of the first API call, take each 'product' and make the second REST call as part of a looping process.

     

    Here's an example flow with a brief description:

    - The 1st REST call in the test retrieves the product list. The response (product list elements) are filtered to determine how many times the loop needs to occur.

    - Steps 2 & 3 are hacks to compensate for not knowing what your API call response looks like. 

    Step 2 parses a simple JSON payload since I have nothing I can call in Step 1

    Step 3 converts the JSON to XML and creates the filter of the # of occurs using an XPath count().

    - The Loop Over List of Products iterates the structure one element at a time. Filters on this step extract product type and product SKU.

    - Generate Endpoint URI assumes that a URI is all that is needed so it constructs one.

    I used a switch(); however, the implementation could be done in a number of ways depending on the API call to retrieve the product.

    Assertions might be used in situations where a particular product might have a unique API call / endpoint. In this case, you might implement multiple different REST call steps that branch back to the loop dataset when finished.

    - HTTP Get is a REST call that uses the constructed URI

    - Add other logic is just that...  Add other logic as necessary.

     

    The attached test demonstrates the above flow. For obvious reasons, your version will require modifications.

    Attachment(s)



  • 7.  Re: If,elseif, else condtion or switch case

    Posted Jan 09, 2018 01:44 PM

    use assertions