diff --git a/config/src/test/java/org/springframework/security/config/doc/XsdDocumentedTests.java b/config/src/test/java/org/springframework/security/config/doc/XsdDocumentedTests.java index fc57a11a18..ec4c1a8eba 100644 --- a/config/src/test/java/org/springframework/security/config/doc/XsdDocumentedTests.java +++ b/config/src/test/java/org/springframework/security/config/doc/XsdDocumentedTests.java @@ -22,10 +22,10 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -185,8 +185,8 @@ public class XsdDocumentedTests { */ @Test public void countLinksWhenReviewingDocumentationThenParentsAndChildrenAreCorrectlyLinked() throws IOException { - Map> docAttrNameToChildren = new HashMap<>(); - Map> docAttrNameToParents = new HashMap<>(); + Map> docAttrNameToChildren = new TreeMap<>(); + Map> docAttrNameToParents = new TreeMap<>(); String docAttrName = null; Map> currentDocAttrNameToElmt = null; List lines = Files.readAllLines(Paths.get(this.referenceLocation)); @@ -215,8 +215,8 @@ public class XsdDocumentedTests { } } Map elementNameToElement = this.xml.elementsByElementName(this.schemaDocumentLocation); - Map> schemaAttrNameToChildren = new HashMap<>(); - Map> schemaAttrNameToParents = new HashMap<>(); + Map> schemaAttrNameToChildren = new TreeMap<>(); + Map> schemaAttrNameToParents = new TreeMap<>(); elementNameToElement.entrySet().stream().forEach((entry) -> { String key = "nsa-" + entry.getKey(); if (this.ignoredIds.contains(key)) { @@ -248,8 +248,23 @@ public class XsdDocumentedTests { schemaAttrNameToChildren.put(key, childIds); } }); - assertThat(docAttrNameToChildren).isEqualTo(schemaAttrNameToChildren); - assertThat(docAttrNameToParents).isEqualTo(schemaAttrNameToParents); + assertThat(docAttrNameToChildren) + .describedAs(toString(docAttrNameToChildren) + "\n!=\n\n" + toString(schemaAttrNameToChildren)) + .containsExactlyInAnyOrderEntriesOf(schemaAttrNameToChildren); + assertThat(docAttrNameToParents) + .describedAs(toString(docAttrNameToParents) + "\n!=\n\n" + toString(schemaAttrNameToParents)) + .containsExactlyInAnyOrderEntriesOf(schemaAttrNameToParents); + } + + private String toString(Map map) { + StringBuffer buffer = new StringBuffer(); + map.forEach((k, v) -> { + buffer.append(k); + buffer.append("="); + buffer.append(v); + buffer.append("\n"); + }); + return buffer.toString(); } /**