Skip to content

Commit

Permalink
fix serialization of ignoreOrderOfSameNode for equalToXml (wiremock#2896
Browse files Browse the repository at this point in the history
)
  • Loading branch information
viktormelnychuk authored Nov 7, 2024
1 parent 53dfb6e commit 5565987
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class EqualToXmlPattern extends StringValuePattern {
private final Document expectedXmlDoc;

public EqualToXmlPattern(@JsonProperty("equalToXml") String expectedValue) {
this(expectedValue, null, null, null, null, false);
this(expectedValue, null, null, null, null, null);
}

public EqualToXmlPattern(
Expand Down Expand Up @@ -112,6 +112,10 @@ public Boolean isEnablePlaceholders() {
return enablePlaceholders;
}

public Boolean isIgnoreOrderOfSameNode() {
return ignoreOrderOfSameNode;
}

public String getPlaceholderOpeningDelimiterRegex() {
return placeholderOpeningDelimiterRegex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ public void deserializesEqualToXmlWithMinimalParameters() {
@Test
public void deserializesEqualToXmlWithAllParameters() {
Boolean enablePlaceholders = Boolean.TRUE;
Boolean ignoreOrderOfSameNode = Boolean.TRUE;
String placeholderOpeningDelimiterRegex = "theOpeningDelimiterRegex";
String placeholderClosingDelimiterRegex = "theClosingDelimiterRegex";
String patternJson =
Expand All @@ -377,6 +378,9 @@ public void deserializesEqualToXmlWithAllParameters() {
+ "\"enablePlaceholders\" : "
+ enablePlaceholders
+ ", "
+ "\"ignoreOrderOfSameNode\" : "
+ ignoreOrderOfSameNode
+ ", "
+ "\"placeholderOpeningDelimiterRegex\" : \""
+ placeholderOpeningDelimiterRegex
+ "\", "
Expand All @@ -389,6 +393,7 @@ public void deserializesEqualToXmlWithAllParameters() {
assertTrue(stringValuePattern instanceof EqualToXmlPattern);
EqualToXmlPattern equalToXmlPattern = (EqualToXmlPattern) stringValuePattern;
assertEquals(enablePlaceholders, equalToXmlPattern.isEnablePlaceholders());
assertEquals(ignoreOrderOfSameNode, equalToXmlPattern.isIgnoreOrderOfSameNode());
assertEquals(
placeholderOpeningDelimiterRegex, equalToXmlPattern.getPlaceholderOpeningDelimiterRegex());
assertEquals(
Expand All @@ -402,6 +407,7 @@ public void deserializesEqualToXmlWithAllParameters() {
public void serializesEqualToXmlWithAllParameters() {
String xml = "<stuff />";
Boolean enablePlaceholders = Boolean.TRUE;
Boolean ignoreOrderOfSameNode = Boolean.TRUE;
String placeholderOpeningDelimiterRegex = "[";
String placeholderClosingDelimiterRegex = "]";

Expand All @@ -412,7 +418,7 @@ public void serializesEqualToXmlWithAllParameters() {
placeholderOpeningDelimiterRegex,
placeholderClosingDelimiterRegex,
Set.of(SCHEMA_LOCATION, NAMESPACE_URI, ATTR_VALUE),
false);
ignoreOrderOfSameNode);

String json = Json.write(pattern);

Expand All @@ -422,6 +428,7 @@ public void serializesEqualToXmlWithAllParameters() {
"{\n"
+ " \"equalToXml\": \"<stuff />\",\n"
+ " \"enablePlaceholders\": true,\n"
+ " \"ignoreOrderOfSameNode\": true,\n"
+ " \"placeholderOpeningDelimiterRegex\": \"[\",\n"
+ " \"placeholderClosingDelimiterRegex\": \"]\",\n"
+ " \"exemptedComparisons\": [\"SCHEMA_LOCATION\", \"ATTR_VALUE\", \"NAMESPACE_URI\"]\n"
Expand Down

0 comments on commit 5565987

Please sign in to comment.