Forum Discussion

searay60's avatar
searay60
Occasional Contributor
13 years ago

index Soap input line with assertion

I have multi-line input (several product numbers to price) and serveral assertions (qty, uom, price, etc) for each. Sometimes Soap returns the output in a different order than I have them in the input; for example the first input line may come back as the third result line, or the second input line will come back as the first result line. The problem is my assertions are set up based on the position of the product number in the input. In other words, I'm expecting $34 in the first assertion (for the first line of the input) but $34 is returning as the third result (assertion) and some other price is returning in the first assertion. How do I index or associate the assertions with the input so this does not happen? It causes the tests to fail. Thank you.

6 Replies

  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Can you use XPath assertions instead?

    Kind regards,
    Tim
  • searay60's avatar
    searay60
    Occasional Contributor
    I am using XPath assertions. There are 3 pricing request in one call (or test). I can specify in the assertions that the correct price for the first is $34, the second is $50 and the third is $68. But Soap sometimes returns the amounts I'm expecting in another order (for some reason) and so the soap test fails. I don't know how to "tie" or index them so that this doesn't occur. Thank you again.
  • Hi searay60,

    Always order is not guarantee in the xml, so better way is get the price based on the product.
    You can use xpath or groovy script assertion.
    Can u send your request snippet so that I can help more.

    Thanks & Regards
    Saravanan Ramamoorthy
  • searay60's avatar
    searay60
    Occasional Contributor
    Thanks again. Below is (part of) a pricing call for three products. My assertion's "suggested price" results are set up in this order; 03-001-00001 first, 03-001-00002 second and 03-012-00033 third. But the results come back mixed up so the assertions sometimes fail when they shouldn't because the three expected results are returned correctly - just not in the correct order in the results.

    <I_XX_GET_PRICE_IN_TBL>
    <I_XX_GET_PRICE_IN_TBL_ITEM>
    <I_REFERRAL_LINE_ID>2180188</I_REFERRAL_LINE_ID>
    <I_PATIENT_STATE>AK</I_PATIENT_STATE>
    <I_PATIENT_ZIP>99501</I_PATIENT_ZIP>
    <I_PRODUCT>03-001-00001</I_PRODUCT>
    <I_REQUESTED_QTY>1</I_REQUESTED_QTY>
    <I_REQUESTED_UOM>Each</I_REQUESTED_UOM>
    <I_CARRIER_ACCOUNT_NUMBER>26586</I_CARRIER_ACCOUNT_NUMBER>
    <I_ORDER_TYPE>P</I_ORDER_TYPE>
    <I_COST></I_COST>
    <I_DATE_OF_SERVICE>10/13/2012</I_DATE_OF_SERVICE>
    <I_SUGGSTD_PRICE_REQUIRED>Y</I_SUGGSTD_PRICE_REQUIRED>
    </I_XX_GET_PRICE_IN_TBL_ITEM>
    <I_XX_GET_PRICE_IN_TBL_ITEM>
    <I_REFERRAL_LINE_ID>2180189</I_REFERRAL_LINE_ID>
    <I_PATIENT_STATE>AK</I_PATIENT_STATE>
    <I_PATIENT_ZIP>99501</I_PATIENT_ZIP>
    <I_PRODUCT>03-001-00002</I_PRODUCT>
    <I_REQUESTED_QTY>1</I_REQUESTED_QTY>
    <I_REQUESTED_UOM>Each</I_REQUESTED_UOM>
    <I_CARRIER_ACCOUNT_NUMBER>26586</I_CARRIER_ACCOUNT_NUMBER>
    <I_ORDER_TYPE>P</I_ORDER_TYPE>
    <I_DATE_OF_SERVICE>10/13/2012</I_DATE_OF_SERVICE>
    <I_SUGGSTD_PRICE_REQUIRED>Y</I_SUGGSTD_PRICE_REQUIRED>
    </I_XX_GET_PRICE_IN_TBL_ITEM>
    <I_XX_GET_PRICE_IN_TBL_ITEM>
    <I_REFERRAL_LINE_ID>2180190</I_REFERRAL_LINE_ID>
    <I_PATIENT_STATE>AK</I_PATIENT_STATE>
    <I_PATIENT_ZIP>99501</I_PATIENT_ZIP>
    <I_PRODUCT>03-012-00033</I_PRODUCT>
    <I_REQUESTED_QTY>1</I_REQUESTED_QTY>
    <I_REQUESTED_UOM>Each</I_REQUESTED_UOM>
    <I_CARRIER_ACCOUNT_NUMBER>26586</I_CARRIER_ACCOUNT_NUMBER>
    <I_ORDER_TYPE>P</I_ORDER_TYPE>
    <I_DATE_OF_SERVICE>10/13/2012</I_DATE_OF_SERVICE>
    <I_SUGGSTD_PRICE_REQUIRED>Y</I_SUGGSTD_PRICE_REQUIRED>
    </I_XX_GET_PRICE_IN_TBL_ITEM>
  • Hi

    Sorry for the late response.

    Steps:
    1. Find the primary element of the complex type I_XX_GET_PRICE_IN_TBL_ITEM.
    2. using the element get the the corresponding I_XX_GET_PRICE_IN_TBL_ITEM complex type
    3. fetch the PRODUCT element.


    //initialization.
    def reqxml = new XmlParser().parseText(messageExchange.requestContent)
    def typ= new groovy.xml.Namespace("ur namespace")

    // get the list
    def productitems = reqxml[typ.I_XX_GET_PRICE_IN_TBL_ITEM]

    // fetch the unique I_XX_GET_PRICE_IN_TBL_ITEM complextype using I_REFERRAL_LINE_ID
    def first = productitems.find{it[typ.I_REFERRAL_LINE_ID].text()=="2180188"}

    //do it for second and third

    //then do assertions based on first,second and third.


    Let me know if u need more details