committed by
GitHub
parent
8cfff1caa3
commit
0f338ca5a0
@@ -220,7 +220,7 @@ class XmlToXPathsConverter {
|
||||
|
||||
private static List<Node> addValueNodes(Node node, List<List<Node>> valueNodes, List<Node> attributes) {
|
||||
getChildNodesAsList(node).each {
|
||||
attributes.addAll(getAttributesAsList(node))
|
||||
attributes.addAll(getAttributesAsList(it))
|
||||
if (isValueNode(it) && !isBlank(it.nodeValue)) {
|
||||
valueNodes << withParents(it)
|
||||
}
|
||||
|
||||
@@ -312,6 +312,11 @@ class WireMockXmlStubStrategySpec extends Specification implements WireMockStubV
|
||||
"expression": "/test/alpha/text()",
|
||||
"equalTo": "abc"
|
||||
}
|
||||
}, {
|
||||
"matchesXPath" : {
|
||||
"expression" : "/test/duck/@type",
|
||||
"equalTo" : "xtype"
|
||||
}
|
||||
}, {
|
||||
"matchesXPath": {
|
||||
"expression": "/test/duck/text()",
|
||||
|
||||
@@ -17,6 +17,12 @@ class XmlToXPathsConverterSpec extends Specification {
|
||||
String unnamedXml = '''<customer>
|
||||
<email>customer@test.com</email>
|
||||
</customer>
|
||||
'''
|
||||
@Shared
|
||||
String attributesInChildXml = '''<customer first_custom_attribute="first_value">
|
||||
<email second_custom_attribute="second_value" >customer@test.com</email>
|
||||
<address third_custom_attribute="third_value"/>
|
||||
</customer>
|
||||
'''
|
||||
|
||||
@Unroll
|
||||
@@ -39,6 +45,18 @@ class XmlToXPathsConverterSpec extends Specification {
|
||||
e.message.contains('Prefix must resolve to a namespace: ns1')
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "should generate matched path [#expectedValue] for xPath [#value]"() {
|
||||
expect:
|
||||
value == expectedValue
|
||||
where:
|
||||
value || expectedValue
|
||||
XmlToXPathsConverter.mapToMatchers(attributesInChildXml).get(0).path() || '''/customer/email/text()'''
|
||||
XmlToXPathsConverter.mapToMatchers(attributesInChildXml).get(1).path() || '''/customer/@first_custom_attribute'''
|
||||
XmlToXPathsConverter.mapToMatchers(attributesInChildXml).get(2).path() || '''/customer/email/@second_custom_attribute'''
|
||||
XmlToXPathsConverter.mapToMatchers(attributesInChildXml).get(3).path() || '''/customer/address/@third_custom_attribute'''
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "should remove elements to [#expectedValue] for xPath [#value]"() {
|
||||
given:
|
||||
|
||||
Reference in New Issue
Block a user