I'm making an automated test suite for an API with an odd schema. In my API response, I have a list of types of items people can order and some information about them like price. Each item has an ID:
<xml>
<ItemType ID="Type1">
<Price>5.00</Price>
</ItemType>
<ItemType ID="Type2">
<Price>10.00</Price>
</ItemType>
</xml>
Later in the API there is a list of actual products. Each one has an ItemID so that you can find out how much it costs, like this:
<Product>
<Name>Product1</Name>
<Description>some stuff</Description>
<ItemRefs>Type1</ItemRefs>
</Product>
I select a product and save its ItemRefs as a property to use in the next API. However, I also need to work out the price of the product I chose. I currently always select the first product in the list but this doesn't always correlate to the first type of item. I also want to be able to make tests selecting multiple products and types of items in the future, but I would need to find the price of all of them.
I need a way to find my ItemRefs property within the earlier list and set the associated price as another property. I'm assuming I need to do this with a groovy script but I don't know how. Can anyone help?