My application request returns 1 to many datasets to the user in a single response. For example the user requests a loan, and the response will contain a structure for each supported loan offing in the sql db. Since I configure the DB with the supported offer(s), I will always know how many are supported and thus how many responses to expect. I could simply start writing validation expecting a known quantity of nodes in the output, and then create sets of redundant assertions 1 per expected offer in the response.
Is there a smarter way combining DB queries to to get counts and data, with assertions at the request output that would validate each child with in each set?
Yes I'm aware of the script assertion, and I recognize that I this will be a script assertion. What I'm looking for is a typical strategy used in writing such a script.
I want to assume that I don't know how many offers would be in the response. The first part of the assertion (Or some prior test step) might be to perform a DB query to discover the number of offers available, as my Expect Data. Then capture the number of offer nodes in the output , Actual Data, and compare Expected and Actual values.
I want to capture and store the output data as well.
I'm not sure how to work with the JSON response and order the data into something I can compare against.
Since writing this I have added a Datasource of type JDBC, which has queried the database and returned each offer and their related properties in the same order as the offers appear in the output. Now I need a way to iterate through each offer and perform assertions on each property Expect vs. Actual Values.