Service Virtualization

  • 1.  String Pattern to choose from given options?

    Posted Jan 09, 2017 05:15 AM

    Hi Everybody,

     

    In one of the virtual service that I currently implement, I need to have response that is partially genereated. The point is, that I need to have value in response to be chosen from several values, e.g A, AB, CD.

     

    I try to use string pattern in response in vsi. I'm able to generate proper response, when it is single letter or number, for example: {{=[::[A,B]]}} generates A or B. How to modify this pattern to have in response A,B, or CD?

     

    thanks in advance

     

    Wojtek



  • 2.  Re: String Pattern to choose from given options?
    Best Answer

    Posted Jan 10, 2017 09:31 AM

    Hello Wojtek,

     

    Try to use 

    {{=[::\AB]}} for "AB", 

    {{=[::[A,B]]}} for "A" or "B" 

    and {{=[::C\D]}} for "CD".

     

    Hope it helps.

     

    Thank you,

    Heloisa



  • 3.  Re: String Pattern to choose from given options?

    Posted Mar 21, 2018 10:03 AM

    Heloisa -

    I have a use case which is similar but slightly different from the solution you suggested.  In your example you provided 3 different patterns to generate the 3 different solutions. I don't think this was what the original poster was looking for - definitely not what I need.

     

    I need one pattern which can select from the SET options.

    In the pattern definitions CA provides an option to choose from a SET such as:

    9[a,b,c]

    Each time this pattern was called it would return either 9a, 9b, or 9c

     

    In my use case, I need either 9dog, 9cat, or 9yeti.

    Logically, this would be a pattern that looked like the following:

    9[dog,cat,yeti].

     

    This doesn't work.  The pattern tells me: The pick list item has more than one character. near index 1
    9[dog,cat,yeti]  ^

    Question 1 - is this a defect or unsupported usage of the pattern set option?  If so, this would be a big improvement.

    Question 2 - short of coding, how would you do this.  I know I can code but the patterns work for 40 other cases I have so I prefer to not make an exception for this situation.



  • 4.  Re: String Pattern to choose from given options?

    Broadcom Employee
    Posted Mar 21, 2018 10:24 AM

    Hi Tom,

     

    Q1: I believe it is working as designed.

     

    Q2: Would it solve your problem if you use a local, random dataset?

     

    --Mike



  • 5.  Re: String Pattern to choose from given options?

    Posted Mar 21, 2018 11:41 AM

    Bummer that it is working as designed. I think the ability to pick a multi-character value from the set would be very useful. vs being restricted to single character . I am creating shipping carrier tracking numbers and there are frequent situations where there are pattern groups that are used to signify mail classes as an example.

    Regarding your Q2 – Possibly. It’s just not as elegant. 39 of my 40 pieces of data can be derived from the patterns, and for this one case I need to implement a random data set then pass it around as a property.

     

    I was trying to keep the code intuitive.

    Hopefully if you see the value you can propose it as a feature.



  • 6.  Re: String Pattern to choose from given options?

    Broadcom Employee
    Posted Mar 21, 2018 01:13 PM

    Hi Tom,

     

    I wanted to make sure you didn't misunderstand what I meant by "random dataset".  I didn't mean a custom dataset to generate random values.  I meant a traditional CSV dataset with the "random" selector checked.

     

    --Mike



  • 7.  Re: String Pattern to choose from given options?

    Posted Jan 17, 2017 02:27 PM

    Wojtek,

     

    Did Heloisa's recommendations resolve this issue?

     

    Regards,

    Reid