Assertions
_testScript.run(context)
println("\r\n--- Test Output ----------")
int docCount = context.outputDocuments.size()
println(docCount + " Document(s) after script execution")
assert context.inputDocuments.size() == docCount
for (Document doc in context.outputDocuments) {
String textDoc = doc.toString()
assert textDoc != "", "Document is null"
println("Doc[${docNo++}] ----" )
println(textDoc)
}Validate an XML output document
/** The testfile for document 1 contains one _uniquekeys_ which is converted to:
* <RecordQueryRequest limit="" offsetToken="">
* <filter op="OR">
* <fieldValue>
* <fieldId>
* VATNO
* </fieldId>
* <operator>
* EQUALS
* </operator>
* <value>
* V_5001
* </value>
* </fieldValue>
* ....
* */
static void _checkDoc1(Document document) {
def ddpUniqueKeyCount = document.getProperty("DDP_UniqueKeyCount")
assert (ddpUniqueKeyCount as Integer == 1)
final xs = new XmlSlurper()
String xml = document.toString()
println( xml)
def xDoc = xs.parseText(xml)
// Get first [filter] element
def field0 = xDoc.filter.fieldValue[0]
// Print a validate its children
println( "OPERATION[0]:")
println( "Field : '${field0.fieldId}' ")
println( "Operation : '${field0.operator}' ")
println( "Value : '${field0.value}' ")
// @TypeChecked must be off!!!
assert ((xDoc.filter.fieldValue[0].fieldId) as String).equals("VATNO")
assert !((xDoc.filter.fieldValue[0].fieldId) as String).equals("vatno")
}Check for Dynamic Document Properties
Last updated