Forum Discussion

GirlGeek's avatar
GirlGeek
New Contributor
12 years ago

How to check whether a response list contains an item?

Short version: If my response is a list, how can I check that the list contains a specific item?

Long version: My test suite has two steps: first I call an addCustomer method, then getCustomerByPhoneNumber. However, since phone number is not unique, I may get back a list of several customers. I only want to check whether the customer I added in the first step is returned in the second step; I don't care if any other customers are returned as well. I understand how to do this if we could guarantee getCustomerByPhoneNumber always returned only one customer, but getting a list back is throwing me off.

Simplified example: Say I add a customer with name=customer2, and the addCustomer method returns a generated ID equaling 222. getCustomerByPhoneNumber then returns the following. How do I check that a customer with id=222 was returned? Customer2 may be in any position in the list.


<customers>
<customer>
<id>111</id>
<name>customer1</name>
<phoneNumber>555-5555</phoneNumber>
</customer>
<customer>
<id>222</id>
<name>customer2</name>
<phoneNumber>555-5555</phoneNumber>
</customer>
<customer>
<id>333</id>
<name>customer3</name>
<phoneNumber>555-5555</phoneNumber>
</customer>


Note: I am using SoapUI Pro, but since my company has a floating license I wasn't sure how to get access to the Pro forums.

Thanks!