Last active
December 22, 2015 19:40
-
-
Save raidzero/0c88b0285bcdb76745fa to your computer and use it in GitHub Desktop.
groovy extract date range in days from xml (for soapui)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.time.TimeCategory | |
// create XmlHolder for request content | |
def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent ) | |
// get arguments | |
def startDateStr = holder["//b:StartDate"] | |
def endDateStr = holder["//b:EndDate"] | |
log.info "start: " + startDateStr + " end:" + endDateStr | |
try | |
{ | |
def startDate = Date.parse("yyyy-MM-dd", startDateStr) | |
def endDate = Date.parse("yyyy-MM-dd", endDateStr) | |
log.info "RANGE: " + startDate + " - " + endDate | |
def range = TimeCategory.minus(endDate, startDate).days + "d" | |
log.info "range string: " + range | |
// range is known. return it (response name) | |
return range | |
} catch(e) { | |
log.info "Error: " + e | |
return "Invalid Input Response" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment