How to verify if the value in response is sort by descending
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011
12:35 AM
11-16-2011
12:35 AM
How to verify if the value in response is sort by descending
Hello,
Here is the case we want to see if a node value in response is order by descending. I was trying to figure that out but failed.
Anyone here can help me out? Thanks.
The sample output like below and we want to add an assertion to verify if "create_date" is order by descending
<ads>
<ad>
<create_date>value1</create_date>
</ad>
...
<ad>
<create_date>value1</create_date>
</ad>
...
</ads>
Thanks in advance!
Sophie
Here is the case we want to see if a node value in response is order by descending. I was trying to figure that out but failed.
Anyone here can help me out? Thanks.
The sample output like below and we want to add an assertion to verify if "create_date" is order by descending
<ads>
<ad>
<create_date>value1</create_date>
</ad>
...
<ad>
<create_date>value1</create_date>
</ad>
...
</ads>
Thanks in advance!

Sophie
6 REPLIES 6
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011
01:04 AM
11-16-2011
01:04 AM
you can add value in the list:
def date = []
int datecount = Integer.parseInt (holderResponse.getNodeValue( "count(//*[local-name()='create_date' and namespace-uri()='yournamespace])") )
for(int i = 1; i <= datecount; i++){
date.add( holderResponse.getNodeValue( "//*[local-name()='create_date' and namespace-uri()='yournamespace']") )
}
and then compare in this list if i > i+1 or you can clone this list sort it and compare if these lists are equals
def date = []
int datecount = Integer.parseInt (holderResponse.getNodeValue( "count(//*[local-name()='create_date' and namespace-uri()='yournamespace])") )
for(int i = 1; i <= datecount; i++){
date.add( holderResponse.getNodeValue( "//*[local-name()='create_date' and namespace-uri()='yournamespace']") )
}
and then compare in this list if i > i+1 or you can clone this list sort it and compare if these lists are equals
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2011
01:45 AM
11-16-2011
01:45 AM
Hi Sophie,
can you give us a complete example response message to work on for providing a solution?
regards!
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
can you give us a complete example response message to work on for providing a solution?
regards!
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2011
12:59 AM
11-17-2011
12:59 AM
Hi,
Thanks much for those replies. For now we have search ad cases via some criterias and have to verify if the search result matches to those criterias.
e.g
1, sort by price/date/distance descending/ascending.
2, filter out the ads which create date is < the input criteria
3, filter out the ads which the price is in a range(minPrice, maxPrice)
Attach is a output sample. I hope you there could provide a solution on how I can add an assertion for the output to verify those cases.
PS:I am just a very beginner in soapUI field and still learning, so please explain more detailed on how to. Thanks much.
Best,
Sophie
Thanks much for those replies. For now we have search ad cases via some criterias and have to verify if the search result matches to those criterias.
e.g
1, sort by price/date/distance descending/ascending.
2, filter out the ads which create date is < the input criteria
3, filter out the ads which the price is in a range(minPrice, maxPrice)
Attach is a output sample. I hope you there could provide a solution on how I can add an assertion for the output to verify those cases.
PS:I am just a very beginner in soapUI field and still learning, so please explain more detailed on how to. Thanks much.
Best,
Sophie
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2011
02:13 AM
11-17-2011
02:13 AM
Hi Sophie,
I don't think this can be done without groovy unfortunately - I think the suggestion given by RJanecek above is a good start
regards!
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
I don't think this can be done without groovy unfortunately - I think the suggestion given by RJanecek above is a good start
regards!
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2011
01:18 AM
11-18-2011
01:18 AM
Hi RJanecek,
I tried to add the script below in Script Assertion, but seems like i cant get each date value via the loop. And can get the could of date-time.
I have 3 ads so with 3 different creation-date-time.
-
import com.eviware.soapui.support.XmlHolder
def date = []
def holder = new XmlHolder( messageExchange.responseContentAsXml )
holder.namespaces["ad"] = myNameSpace
int datecount = Integer.parseInt (holder.getNodeValue( "count(//ad:ads/ad:ad/ad:creation-date-time)") )
for(int i = 0; i < datecount; i++){
date.add( holder.getNodeValue( "//ad:ads/ad:ad/ad:creation-date-time") )
}
-
And below is the assertion I added for date-time content
//ad:ads[1]/ad:ad[3]/ad:creation-date-time[1]/text()
So am wondering if I need to add an index in that loop, like this date.add( holder.getNodeValue( "//ad:ads[1]/ad:ad/ad:creation-date-time[1]/text()") )
??
Thanks,
Sophie
I tried to add the script below in Script Assertion, but seems like i cant get each date value via the loop. And can get the could of date-time.
I have 3 ads so with 3 different creation-date-time.
-
import com.eviware.soapui.support.XmlHolder
def date = []
def holder = new XmlHolder( messageExchange.responseContentAsXml )
holder.namespaces["ad"] = myNameSpace
int datecount = Integer.parseInt (holder.getNodeValue( "count(//ad:ads/ad:ad/ad:creation-date-time)") )
for(int i = 0; i < datecount; i++){
date.add( holder.getNodeValue( "//ad:ads/ad:ad/ad:creation-date-time") )
}
-
And below is the assertion I added for date-time content
//ad:ads[1]/ad:ad[3]/ad:creation-date-time[1]/text()
So am wondering if I need to add an index in that loop, like this date.add( holder.getNodeValue( "//ad:ads[1]/ad:ad/ad:creation-date-time[1]/text()") )
??
Thanks,
Sophie
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2011
05:55 AM
11-21-2011
05:55 AM
firstly you should have some root element secondly you should define namespace prefixes
