Comparing values

reactancexlreactancexl Posts: 147

I have a set of values from one rest call. I need to verify if they exist in another rest call. First call may have 5 values and second call may have 15. What is the best way to validate if the first value(s) is contained in second? Sample Data: below data returned as a JSON array.
First Call Second Call

100 345
200 77
300 200
400 500
500 300
123
222
777
543

Tagged:

Comments

  • benken_parasoftbenken_parasoft Posts: 1,009 ✭✭✭
    edited August 25

    I believe you would chain a Data Bank to the first REST Client to extract the values. When extracting multiple values, you can use an XPath that uses the "string-join" function so you can delimit each value with a comma, for example. So, your data bank would contain a comma-separated list of the values. Then you can chain an Assertor to the second REST Client to do the comparison. In the Assertor, you would configure a Value Assertion that extracts the values from the second client in a similar way, maybe using "string-join" to delimit the values, and then you specify the data bank column from the first test as the Expected Value.

    It looks like someone posted a variant of this high level approach which you may also want to review: Validating Variable Length Lists In API Responses

  • reactancexlreactancexl Posts: 147

    Thanks for the info. The string-join worked by concatenating all my array values from source and target. then the script below is doing the validation (Jython)

Sign In or Register to comment.