File tree Expand file tree Collapse file tree
loggerazzi/src/main/java/com/telefonica/loggerazzi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,4 +21,30 @@ class DefaultLogComparator<LogType> : LogComparator<LogType> {
2121
2222 return compareResult.toString().takeIf { it.isNotEmpty() }
2323 }
24- }
24+ }
25+
26+ @Suppress(" unused" )
27+ class AnyOrderLogComparator <LogType > : LogComparator <LogType > {
28+ override fun compare (recorded : List <LogType >, golden : List <LogType >): String? {
29+ val missing = findDifference(golden, recorded)
30+ val extra = findDifference(recorded, golden)
31+
32+ if (missing.isEmpty() && extra.isEmpty()) {
33+ return null
34+ }
35+
36+ val result = StringBuilder ()
37+ if (missing.isNotEmpty()) {
38+ result.appendLine(" Missing entries (in golden but not in recorded): $missing " )
39+ }
40+ if (extra.isNotEmpty()) {
41+ result.appendLine(" Extra entries (in recorded but not in golden): $extra " )
42+ }
43+
44+ return result.toString().trimEnd()
45+ }
46+
47+ private fun findDifference (first : List <LogType >, second : List <LogType >): List <LogType > {
48+ return first.toMutableList().apply { removeAll(second) }
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments