fork(5) download
  1. def validValues = ['Tag': ['A', 'B', 'C']]
  2. def tagToFind = 'Tag'
  3. def xml = """<Response>
  4. <Tag>D</Tag>
  5. <Tag>A</Tag>
  6. <Tag>C</Tag>
  7. <Tag>B</Tag>
  8. <Tag>E</Tag>
  9. </Response>"""
  10. def pxml = new XmlSlurper().parseText(xml)
  11. //Find all the tag values and filter those are not in valid values
  12. def result = pxml.'**'.findAll{it.name() == tagToFind && !(it.text() in validValues[tagToFind])}
  13. assert !result, "Elements ${tagToFind} have different values other than valid- ${result}"
Runtime error #stdin #stdout #stderr 0.98s 4456448KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Caught: java.lang.AssertionError: Elements Tag have different values other than valid- [D, E]. Expression: result. Values: result = [D, E]
java.lang.AssertionError: Elements Tag have different values other than valid- [D, E]. Expression: result. Values: result = [D, E]
	at prog.run(prog.groovy:13)