We have a custom zio.test.Assertion
that wrap json-path-assert:
def isJson(matching: org.hamcrest.Matcher[_ >: ReadContext]): Assertion[HttpEntity] = {
def test(entity: => HttpEntity): Boolean = {
// Removed for brevity
}
Assertion.assertion[HttpEntity]("isJson")(param(matching))(test)
}
We are quite happy with it but the failure message is far to be obvious:
response.body
= Strict(ByteString(121, 32, 95, 111, 10, 108, 113, 35, 50, 90, 124, 23, 112, 111, 112, 31, 48, 24, 46, 31, 111, 22, 111, 25, 93, 52, 41, 54, 59, 90, 100, 43, 42, 51, 75, 14, 41, 54, 40, 65, 34, 42, 99, 88, 100, 54, 34, 25, 33, 89, 41, 40, 54, 52, 44, 40, 31, 101, 112, 105, 91, 10, 35, 125, 79, 106, 95, 11, 11, 32, 85, 13, 43, 104, 111)... and [661] more,Some(application/json)) did not satisfy isJson(with json path "$['store']['name']")
I would like to print the Json string decoded from those bytes but I do not see how to do that.
How can we customize the messages of a custom zio.test.Assertion
?
Thanks