Service Virtualization

 View Only
Expand all | Collapse all

Handling split dates while creating virtual service using recording method

  • 1.  Handling split dates while creating virtual service using recording method

    Posted Mar 17, 2020 08:40 AM

    Hi,

    While creating virtual service using recording method,

    We have a requirement to handle a Date field split into 3 different fields (field_year , field_month & field_date) as magic strings or magic dates unlike the standard Date handling.

    Here is the scenario explained:

    Request_1 has an argument travel_from_date with value  170321 which DevTest parameterizes to {{=doDateDeltaFromRequest("ddMMyy","70D");/*170321*/}}

    Request_2 splits this value 170321 into 3 different fields (travel_day , travel_month , travel_year ) with values as (17 , 03 , 2021) respectively which we want to use as Magic Dates/Strings since these values are repeated in many such requests.

    Since doDateDeltaFromRequest is for the date of format ddMMyy ,  we want to understand how to handle the split dates spread across different fields.

    The highlighted part we would like to parameterize.

    Note: Magic string won't work here, because request arguments name and response arguments name will not be same



    ------------------------------
    Aravind
    ------------------------------


  • 2.  RE: Handling split dates while creating virtual service using recording method
    Best Answer

    Posted Mar 17, 2020 10:13 AM

    Hi,

     

    The doDateDeltaFromRequest function works on the first date argument that it finds in the lisa_vse_request object (that internal object created from the incoming request).

    One way to solve this so that you can continue to use magic dates with the doDateDeltaFromRequest() function would be to add the required date-argument as first argument of the lisa_vse_request arguments list.

    Here's a high-level approach:

    • Add a Request Data Copier DPH to the Listen step, copy all the arguments to properties
    • Add a scriptable DPH to the Listen step
    • In the scriptable DPH, add a new argument to the arguments list consisting of the concatenation of the day-property + month-property + year-property
    • In your VSI, add this argument to your transaction signature
    • In the responses use doDateDeltaFromRequest() as needed

     

    This approach uses as much as possible the existing features from the VSI and from the workflow in the VSM. I can imagine that you can also completely solve the problem by writing everything in java or script inside a script-step which would create and calculate and store a date property outside of the lisa_vse_request object, but you would also have to implement the date delta functionality in here (not rocket science but the number of code lines starts to grow)

     

    Cheers,

    Danny

     

    ::DISCLAIMER::

    The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects.






  • 3.  RE: Handling split dates while creating virtual service using recording method

    Posted Mar 24, 2020 07:49 AM
    Thanks for your response Danny.
    I will try to adopt the approach in my existing VSM and VSI and will get back to you.

    Regards,
    Aravind