Service Virtualization

  • 1.  Conditional filters

    Posted Nov 30, 2017 12:01 PM

    How to use conditional filters in devtest 8.2 ? Like based on conditions in xml , json service responses , how to extract the value using filters? Pls clarify with an example . Here only when status key value is eligible i have to filter out the data and use it . 

     

    {

    "status" : "Eligible",

          "data" :  10,

    "status" : "InEligible"

       "data" : 12

    }



  • 2.  Re: Conditional filters
    Best Answer

    Broadcom Employee
    Posted Nov 30, 2017 12:21 PM


  • 3.  Re: Conditional filters

    Posted Dec 01, 2017 05:05 AM

    My requirement is not for comparison. Below is my requirement :

     

    In the below json response , only when inventoryStatus is InStock , i have to take the SKU value using the filter to the next step . The below structure will repeat in the response . I did not get how the above mentioned steps will work for this scenario. Pls clarify more in detail.

     

    {
    "replacementDeviceList": {
    "replacementDevice": [
    {
    "exchangeSKU": "XSAMT923TBLK",
    "AStockSKU": "610214642486",
    "priority": "1",
    "displayOnUI": true,
    "productName": "SAM T817T TAB S2 BLK EXCH",
    "inventoryStatus": "BackOrdered",
    "estimatedShipmentDateFrom": "2017-12-01",
    "estimatedShipmentDateTo": "2017-12-06"

     

    },
    {
    "exchangeSKU": "XAPP817TBLK",
    "AStockSKU": "610214641755",
    "priority": "1",
    "displayOnUI": true,
    "productName": "App iphone i7",
    "inventoryStatus": "InStock",
    "estimatedShipmentDateFrom": "2017-12-01",
    "estimatedShipmentDateTo": "2017-12-06"
    }
    ]
    }
    }



  • 4.  Re: Conditional filters

    Posted Dec 07, 2017 07:02 AM

    I dont remember if 8.2 has json path filter but you can follow the below approach 

     

    1. Convert json response to xml  couple of linez of code- optional

    2. Use an xml xpath filter or json path filter to retreive value. If your xpath is complex , instrad of filter you can just add few more lines of code

    ur xpath will be something like this

     

    /root/parent[/child=in stock]/child2

    3. Use the saved property however you want. 



  • 5.  Re: Conditional filters

    Posted Dec 09, 2017 08:57 AM

    @ monika meta , @Joel Nesmith ,

     

    I have to pick the value of exchangeSKU whose corresponding inventorystatus value is InStock and use in next test step. Here the order/position in json stucture of INstock varies during each execution. Pls suggest a better option to use this based on conditions

     

    {

     

    "exchangeSKU": "XSAMT923TBLK",
    "inventoryStatus": "BackOrdered",
     },
    {
    "exchangeSKU": "XAPP817TBLK",
    "inventoryStatus": "InStock",
    "exchangeSKU": "123456",
    "inventoryStatus": "Outofstock",

     

    }
    ]
    }
    }