sayome
13 years agoNew Contributor
Using count to assert a range
Hello,
I am fairly new to SOAPUI and I have been trying to perform an assertion and it is giving me some issues. I am testing a webservice that return the amount of appointments available for a date range as follows;
<a:Appointment>
<a:AppointmentType>
<a:Caption>AM</a:Caption>
<a:Description>Morning</a:Description>
<a:Duration>300</a:Duration>
<a:ID>1</a:ID>
<a:StartTime>0001-01-01T08:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-16T08:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
<a:Appointment>
<a:AppointmentType>
<a:Caption>PM</a:Caption>
<a:Description>Afternoon</a:Description>
<a:Duration>240</a:Duration>
<a:ID>2</a:ID>
<a:StartTime>0001-01-01T13:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-16T13:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
<a:Appointment>
<a:AppointmentType>
<a:Caption>AM</a:Caption>
<a:Description>Morning</a:Description>
<a:Duration>300</a:Duration>
<a:ID>1</a:ID>
<a:StartTime>0001-01-01T08:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-17T08:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
<a:Appointment>
<a:AppointmentType>
<a:Caption>PM</a:Caption>
<a:Description>Afternoon</a:Description>
<a:Duration>240</a:Duration>
<a:ID>2</a:ID>
<a:StartTime>0001-01-01T13:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-17T13:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
As you will see, two properties called ID (in bold) define the total appointment for a day. My test is to count the total number of ID returned so if the date range is 1 day then two IDs will be returned. So my test is written as thus at the moment;
count(//a:ID)<=2
This will be true for any number of occurrence between 0 and 2, however, 0 is not valid response. Please can anyone tell me how to eliminate 0 as count cannot accept range like 0>count(//a:ID)<=2?
Cheers
I am fairly new to SOAPUI and I have been trying to perform an assertion and it is giving me some issues. I am testing a webservice that return the amount of appointments available for a date range as follows;
<a:Appointment>
<a:AppointmentType>
<a:Caption>AM</a:Caption>
<a:Description>Morning</a:Description>
<a:Duration>300</a:Duration>
<a:ID>1</a:ID>
<a:StartTime>0001-01-01T08:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-16T08:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
<a:Appointment>
<a:AppointmentType>
<a:Caption>PM</a:Caption>
<a:Description>Afternoon</a:Description>
<a:Duration>240</a:Duration>
<a:ID>2</a:ID>
<a:StartTime>0001-01-01T13:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-16T13:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
<a:Appointment>
<a:AppointmentType>
<a:Caption>AM</a:Caption>
<a:Description>Morning</a:Description>
<a:Duration>300</a:Duration>
<a:ID>1</a:ID>
<a:StartTime>0001-01-01T08:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-17T08:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
<a:Appointment>
<a:AppointmentType>
<a:Caption>PM</a:Caption>
<a:Description>Afternoon</a:Description>
<a:Duration>240</a:Duration>
<a:ID>2</a:ID>
<a:StartTime>0001-01-01T13:00:00</a:StartTime>
</a:AppointmentType>
<a:Date>2012-10-17T13:00:00+01:00</a:Date>
<a:Preferred>true</a:Preferred>
</a:Appointment>
As you will see, two properties called ID (in bold) define the total appointment for a day. My test is to count the total number of ID returned so if the date range is 1 day then two IDs will be returned. So my test is written as thus at the moment;
count(//a:ID)<=2
This will be true for any number of occurrence between 0 and 2, however, 0 is not valid response. Please can anyone tell me how to eliminate 0 as count cannot accept range like 0>count(//a:ID)<=2?
Cheers