Forum Discussion

smadden's avatar
smadden
New Contributor
9 years ago

Script Assertion checking dateTime

I am new to SoapUI, and have a question about a script assertion I need to put together. I have a DB DateTime in UTC value that I need to check against. So basically I have

 

def SQL_Departure = context.expand( ' ${yada_yada.Segment#ResponseAsXml#//Results[1]//resultSet[1]/row[1]//Departure[1]}; ).replace(".000000 ", "")

 

With the assert, I need to ensure that the table is not getting populated with records with a departure datetime less than 96 hours, so somewhat like:

 

assert SQL_Departure >= getUTCDate() + 4 //or 96 for hours instead of 4 for days. Would anyone know the best way of going about this? 

 

Thanks,

Steve

  • nevermind. Figured it out...

     

    import groovy.time.TimeCategory

     

    ----

    -----

    ------

    def now = new Date()
    use(TimeCategory){
    adjDate = now + 4.days
    }

    def dateFormat = adjDate.format("YYYY-MM-dd HH:mm:ss")
    log.info dateFormat

     

     

  • smadden's avatar
    smadden
    New Contributor

    nevermind. Figured it out...

     

    import groovy.time.TimeCategory

     

    ----

    -----

    ------

    def now = new Date()
    use(TimeCategory){
    adjDate = now + 4.days
    }

    def dateFormat = adjDate.format("YYYY-MM-dd HH:mm:ss")
    log.info dateFormat