如果我的日期时间变量出现在多个日期的数组中但显示错误弹出窗口,我试图匹配。
错误:
assert responseStartDateTime.contains(requestStartDateTime) | | | | false 2018-01-16T04:30:00 [2018-01-16T04:30:00, 2018-01-16T06:00:00]
Groovy代码:
import groovy.json.JsonSlurper
import java.text.SimpleDateFormat
//request local time
def StartDateTime = context.expand('${#Project#StartDateTime}')
log.info 'Request StartTime : ' + StartDateTime
def EndDateTime = context.expand('${#Project#EndDateTime}')
log.info 'Request EndTime : ' + EndDateTime
//Remove Z from the request time
def outputDateFormat = "yyyy-MM-dd'T'HH:mm:ss"
start = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(StartDateTime)
end = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(EndDateTime)
def requestStartDateTime = "${start.format(outputDateFormat)}"
log.info 'Request StartTime : ' + requestStartDateTime
def requestEndDateTime = "${end.format(outputDateFormat)}"
log.info 'Request EndTime : ' + requestEndDateTime
def ResponseMessage = messageExchange.response.responseContent
def jsonSlurper = new JsonSlurper().parseText(ResponseMessage)
//Store response local time result to variable
def responseStartDateTime = jsonSlurper.MeetingItems.TimeFrom
log.info 'Response StartTime : ' + responseStartDateTime
def responseEndDateTime = jsonSlurper.MeetingItems.TimeTo
log.info 'Response EndTime : ' + responseEndDateTime
//Assert request local time with response local time
assert responseStartDateTime.contains(requestStartDateTime)
assert responseEndDateTime.contains(requestEndDateTime)
属性值:
StartDateTime - 2018-01-16T04:30:00.000Z
EndDateTime - 2018-01-16T04:45:00.000Z