Service Virtualization

 View Only
  • 1.  Run a flow in a loop

    Posted May 31, 2018 01:35 AM

    Hi,

     

    I have a requirement where I have to do pagination to call an API.

    I am calculating the number of times I have to call an API and saving this in a context variable called "count".

    I want to run through each loop where my flow should run for "count" number of times.

    I tried with run assertions for each loop and trying to set count in maximum exceeded limit, but it is not working.

    Even I didn't find any assertions which can help in running through loop which accepts Integer.

    Please help me with some idea.

     

    Gateway Version: 9.0.0

     

    Regards,

    Ravish



  • 2.  Re: Run a flow in a loop

    Posted May 31, 2018 03:01 AM

    Hi,

     

    Create a LISAProperty (say "count") at very first step of the flow, this step has to execute only once during execution.

    textExec.setStateValue("count",20)

     

    Now decrement the count by 1 , on completion of each loop as a last step , use scripted assertion to decrement the value.

    Also do check the value before updating the count and exit if it has reached to "0".

     

     

    Thanks,

    Dinesh Kumar

     



  • 3.  Re: Run a flow in a loop

    Posted May 31, 2018 06:19 AM

    Hi Dinesh,

    Can you please elaborate which assertion to use exactly and how can I use number in loop.

     

    Thanks,

    Ravish



  • 4.  Re: Run a flow in a loop
    Best Answer

    Posted May 31, 2018 06:39 AM

    Hi Ravish,

     

    Please read below for scripted assertion:

    Scripted Assertion - DevTest Solutions - 9.0 - CA Technologies Documentation 

     

    You can write Java code(other options also available) ,something as below:

    Step-1: Read the value of LISAProperty 'count' into a Integer variable(requires conversion from String type to int)

    Step-2: Check 'count'

                   If it is equal to '0' , then end the loop

                   If count not equal to '0', then 

                         decriment the value by 1 and continue in loop.

     

     

    Hope it helps.

     

    Thanks,

    Dinesh Kumar



  • 5.  Re: Run a flow in a loop

    Broadcom Employee
    Posted May 31, 2018 05:51 AM

    Is this in relation to DevTest? If so, there's an easier way - implement a numeric counting dataset.