Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Multiple Responses

Senthil
Senthil Posts: 27
edited March 2019 in Virtualize

Hi All,

I am New to Parasoft, and trying to stub and virtulize few Operations. I have created 3 response and based on my Incoming request it has to pick the right response. for Eg.
1. If my incoming request is of Reffer it has to pick the Reffer Response.
2.If my incoming request is of Approve it has to pick the Approve Response.
3.If my incoming request is of Declineit has to pick the Decline Response.
Under the Conditional tab by enabling the correlations is it posible. If yes could you please help me in getting this sorted.

Thanks
Senthil kumar. M

Comments

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭

    @Senthil
    you have enabled message correlation however, according to screenshot, you don't have required condition.
    Did you check manual?
    Here is explanation on how correlation process works: User manual

    You have to add proper Xpath for each incoming message which should evaluate to true, to get proper, selected by you, response.

    --
    Ireneusz Szmigiel
    http://www.catb.org/esr/faqs/smart-questions.html

  • Senthil
    Senthil Posts: 27

    Thanks for your Reply.

  • Senthil
    Senthil Posts: 27

    Just wanted to know if we can use "or" condition in Multiple Responses. My consern is if I give the partial data in the application it should fetch the details from this responder, as if now it is not working. How to add condition and what condition can be give, to fetch partial data.
    I have 5 different address set in the responder, apart from the given address if an user type it should not display an error.
    Could you help me with this, as this is blocking my Testing.

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    You can use any valid XPath expression, including the "or" condition.

  • Senthil
    Senthil Posts: 27
    edited April 2019

    Thanks Chan.
    I have tried with XPath expression, including the "or" condition but it did not work. Please see my conditions below for your reference.

    /:Envelope/:Body/:QASearch/:Search/text()="1 lonsdale close, lake haven nsw 2263" or
    /:Envelope/:Body/:QASearch/:Search/text()="1 lonsdale court, port noarlunga south sa 5167" or
    /:Envelope/:Body/:QASearch/:Search/text()="1 lonsdale crescent, cranbourne north vic 3977" or
    /:Envelope/:Body/:QASearch/:Search/text()="1 lonsdale crescent, waikiki wa 6169" or
    /:Envelope/:Body/:QASearch/:Search/text()="broadclose, 1 lonsdale promenade, westbury tas 7303"

    for eg: When I type "lonsdale" in my application, which is a partial value it should display all the address matching to it, else it should not return any address.
    My search of address can be case insensitive. Could you please help me in getting this sorted.

    Thanks
    Senthil kumar. M

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    Would this suffice?

    contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()), "lonsdale")

  • Senthil
    Senthil Posts: 27

    Thanks Chan.

    I tried the same syntax, but the "OK" button is disabled.
    Could you please help me in getting this sorted.

    Thanks
    Senthil kumar. M

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    What you have is not a valid xpath expression. The "contains" function takes two arguments and returns a boolean. If you need general help on XPath, please consult the XPath tutorials on the internet.

  • Senthil
    Senthil Posts: 27

    Thanks Chan,

    My bad I made a mistake. I have added the syntax "contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()), "lonsdale")",
    let me test and update you on the same.

    Many Thanks
    Thanks
    Senthil kumar. M

  • Senthil
    Senthil Posts: 27

    Hi Chan,

    I did not get, What i wanted. for eg: I have the below address stubbed.

    1 Lonsdale Close, LAKE HAVEN NSW 2263
    1 Lonsdale Court, PORT NOARLUNGA SOUTH SA 5167
    1 Lonsdale Crescent, CRANBOURNE NORTH VIC 3977
    1 Lonsdale Crescent, WAIKIKI WA 6169
    Broadclose, 1 Lonsdale Promenade, WESTBURY TAS 7303

    Now my query is in my application if I type partially address like (Lonsdale or HAVEN ) it should display the relevant complete address, but not all, currently it says no address found if I give partial address, I have used the given syntax.

    contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()),"1 Lonsdale Close, LAKE HAVEN NSW 2263")
    and
    contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()="1 lonsdale close, lake haven nsw 2263")

    Please help me on this..

    Thanks
    Senthil kumar. M

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    Do you mean an xpath like this?
    contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()), 'lonsdale') or contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()), 'haven')

  • Senthil
    Senthil Posts: 27
    edited April 2019

    Hi Chan,

    No not that way. Please find the attachment for your reference. So now when I type Lonsdale or Haven or Westbury etc in any format it should display the respective address only not all. So how should I add the condition in Xpath.

    1 Lonsdale Close, LAKE HAVEN NSW 2263
    1 Lonsdale Court, PORT NOARLUNGA SOUTH SA 5167
    1 Lonsdale Crescent, CRANBOURNE NORTH VIC 3977
    1 Lonsdale Crescent, WAIKIKI WA 6169
    Broadclose, 1 Lonsdale Promenade, WESTBURY TAS 7303

    Thanks
    Senthil kumar. M

  • Senthil
    Senthil Posts: 27

    I know when we use lower case in the condition, we do not require the 2nd condition, but still I wanted to give a go and find out.
    Please help me with this , I am stuck with this for the couple of days.

    Thanks
    Senthil kumar. M

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    The second argument of the "contains" function is the substring you are testing whether the first argument contains or not. The first argument in this case is the string passed from your search box. Therefore, if the xpath is

    contains(lower-case(/:Envelope/:Body/:QASearch/:Search/text()), 'lonsdale')

    Then the responder will be invoked if your search term contains "lonsdale".

  • Senthil
    Senthil Posts: 27
    edited April 2019

    Hi Chan,

    Yes, I agree but Testers will not always go with lonsdale. They may type any random words from the given address. So my condition should invoke if any word matches from the given address, that's why i mentioned Lonsdale or Close or LAKE or HAVEN.
    I assumed that if I provide the complete address using contains, it would fetch the address with random matching words. But it's not working as that .

    Thanks
    Senthil kumar. M

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    if you want the condition to match if the search term is contained in your preset string, that the arguments are used in the opposite way:

    contains("1 lonsdale close, lake haven nsw 2263", lower-case(/:Envelope/:Body/:QASearch/:Search/text())

  • Senthil
    Senthil Posts: 27

    Hi Chan,

    Is there a document for me to play with condition using contains, or , and , lowercase, upper case ?

    1. contains("1 lonsdale close, lake haven nsw 2263", lower-case(/:Envelope/:Body/:QASearch/:Search/text())
      This again works only for lonsdale. When I typed "haven" it did not display any address, attached file for reference.

    2. When I continuously give 6 space from my keyboard, It still displays all the address, Need to add a condition for this also, attached file for reference.

    3. How should I add condition for the remaining 4 address, Should I have 5 different Xpath condition or should I use "or" condition in 1 Xpath ?

      contains("1 Lonsdale Court, PORT NOARLUNGA SOUTH SA 5167",lower-case(/:Envelope/:Body/:QASearch/:Search/text()))
      contains("1 Lonsdale Crescent, CRANBOURNE NORTH VIC 3977",lower-case(/:Envelope/:Body/:QASearch/:Search/text()))
      contains("1 Lonsdale Crescent, WAIKIKI WA 6169",lower-case(/:Envelope/:Body/:QASearch/:Search/text()))
      contains("Broadclose, 1 Lonsdale Promenade, WESTBURY TAS 7303",lower-case(/:Envelope/:Body/:QASearch/:Search/text()))

    Thanks
    Senthil kumar. M

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    XPath is an industry standard on how to query an XML document. If you need general help on XPath, please consult the XPath tutorials on the internet.

  • Senthil
    Senthil Posts: 27

    Thanks Chan, for your support and help. Will check XPath tutorials on the internet.

  • Senthil
    Senthil Posts: 27

    Hi Chan,

    Below is the tag which comes in the incoming request, now I need to compare the string partially and send an response.

    AUE|d1f40fb0-0084-4333-a162-9a617cf24e96|730SOAUEHgXjBwAAAAAIAgEAAAAAdSq2kAAhAA4AAAAAAAAAAAD..2IAAAAA.....wAAAAAAAAAAAAAAAAAAADEgTG9uc2RhbGUgQ2xvc2UsIExBS0UgSEFWRU4gTlNXIDIyNjMAAAAAAA--$37

    I followed the below two approach but its failing., here I am send the partially value to compare.

    None of the multiple responses XPath functions, URL parameters, or URL paths matched the request
    ** Method 1:**
    contains(/:Envelope/:Body/:QAGetAddress/:Moniker/text(), "730SOAUEHgXjBwAAAAAIAgEAAAAAdSq2kAAhAA4AAAAAAAAAAAD")

    ** Method 2:**
    contains("730SOAUEHgXjBwAAAAAIAgEAAAAAdSq2kAAhAA4AAAAAAAAAAAD",(/:Envelope/:Body/:QAGetAddress/:Moniker/text()))

    Thanks
    Senthil. M

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,

    In what part of the request is that string coming in? Is it part of the parameters, path or body? You mentioned you tried all three correlation types but where do you expect the string?

    Is that string the entire payload or is it part of a large xml payload? The xpath you have will only work if the request is xml and is a soap envelope. If that string is the entire request then you will need to use a custom correlation and script the contains check.

  • Senthil
    Senthil Posts: 27

    Hi William,
    please find the complete xml request, Here I need to check for the Moniker node and write a contains condition under multiple response. If the value matches partially also it should send the response based on the value matched.





    ws_1751_int
    M3b@nkDev







    ME Bank
    AUE|d1f40fb0-0084-4333-a162-9a617cf24e96|7.7303OAUEGgLkBwAAAAAIAgEAAAAAdnba0AAhAA4AAAAAAAAAAAD..2IAAAAA.....wAAAAAAAAAAAAAAAAAAADEgTG9uc2RhbGUgQ2xvc2UsIExBS0UgSEFWRU4gTlNXIDIyNjMAAAAAAA--$37


    Thanks
    Senthil.M

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,

    I don't see the xml in the comment you posted. What you can do in the tool to help test different xpaths is to use an XML Data Bank tool. That tool has a "evaluate" button that will show you the results of your xpath. It also has a graphic based selection tree that can help build the xpath to select the desired element.