Rob Elliot
05/05/2022, 4:04 PMMap<K, V>.shouldContainAll(expected: Map<K, V>)
which recurses into any maps in the top level structure?mapOf(
"1" to "1",
"2" to mapOf(
"2.1" to "2.1",
"2.2" to "2.2",
)
) shouldLooselyMatch mapOf(
"1" to "1",
"2" to mapOf(
"2.2" to "2.2",
)
)
mapOf(
"1" to "1",
"2" to listOf(
mapOf(
"2.1" to "2.1",
"2.2" to "2.2",
)
)
) shouldLooselyMatch mapOf(
"1" to "1",
"2" to listOf(
mapOf(
"2.1" to "2.1",
)
)
)
shouldEqualSpecifiedJson
would do it but I've got a List/Map based representation rather than a String one...)sam
05/05/2022, 4:09 PMEmil Kantis
05/05/2022, 8:29 PMRob Elliot
05/05/2022, 8:38 PMEmil Kantis
05/05/2022, 8:43 PMRob Elliot
05/05/2022, 9:01 PMshouldEqualSpecifiedJson
, but with Maps on either side rather than strings. I could serialise the Maps to json I suppose...
Or alternatively convert them to io.kotest.assertions.json.JsonTree
and use equalJson
with compareJsonOptions { fieldComparison = FieldComparison.Lenient }
, which would save using a string as the intermediate step.sam
05/05/2022, 9:02 PMRob Elliot
05/05/2022, 9:12 PMshouldEqualSpecifiedJson
matcher is exactly the concept I want; I just haven't got json strings, I've got Maps.sam
05/05/2022, 10:19 PM