Multiple Responses

SenthilSenthil Posts: 17
edited March 21 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 SzmigielIreneusz Szmigiel Posts: 204 ✭✭

    @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

  • SenthilSenthil Posts: 17

    Thanks for your Reply.

  • SenthilSenthil Posts: 17

    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_chankeegan_chan Posts: 57

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

  • SenthilSenthil Posts: 17
    edited April 1

    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_chankeegan_chan Posts: 57

    Would this suffice?

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

  • SenthilSenthil Posts: 17

    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_chankeegan_chan Posts: 57

    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.

  • SenthilSenthil Posts: 17

    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

  • SenthilSenthil Posts: 17

    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_chankeegan_chan Posts: 57

    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')

  • SenthilSenthil Posts: 17
    edited April 5

    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

  • SenthilSenthil Posts: 17

    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_chankeegan_chan Posts: 57

    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".

  • SenthilSenthil Posts: 17
    edited April 5

    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_chankeegan_chan Posts: 57

    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())

  • SenthilSenthil Posts: 17

    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_chankeegan_chan Posts: 57

    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.

  • SenthilSenthil Posts: 17

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

Sign In or Register to comment.