Forum Discussion
I believe that, actual date does not matter. What matters is that are all the values same?
Below does that
//Assumes json object is defined allread
assert 1 == json.data.findAll{it.'GeographicalIndicationStatusId_Name' == 'Registered'}.collect {it.'RegistrationFromDate'}.unique().size()
Here is the explanation
Find all StatusId_Name value is Registered, collect the Registration From Dates which is a list of dates, apply uniqueness on that list and that size should be always equals to one.
Hey rao
Ok -I don't know if my rubbish explanations have confused you - I need to think about your code a bit cos just when I think I can read your code, you introduce new stuff that I can't!
Anyway - (in the meantime whilst I work out exactly how your code snippet works to see if it does what I need) I've tried to clarify the requirement I'm trying to test is to actually copy in the requirement statement below - I've copied this straight from the JIRA user story:
Registration From Date = If Geographical Indication Status is 'Registered' then '29 Mar 2019' else Null;
Aah! - hold it - my brain's catching up - so using your example I can use two assertion as follows to cover the 29 Mar 2019 and null scenario like as follows:
def json = new groovy.json.JsonSlurper().parseText(context.response)
assert 1 == json.data.findAll{it.'GeographicalIndicationStatusId_Name' == 'Registered'}.collect {it.'RegistrationFromDate'}.unique().size()
assert 1 == json.data.findAll{it.'GeographicalIndicationStatusId_Name' != 'Registered'}.collect {it.'RegistrationFromDate'}.unique().size()
Just trying this to see if the second assertion works for nulls......
I hope I've been clear!
thanks!
richie