I'm refactoring some tests where previously the response was parsed into org.json4s.JValue
I want to pass the response as type org.asynchttpclient.Response as input parameter. In order to distinguish the HTTP code status.
NettyResponse and WebDavResponse are implementations of org.asynchttpclient.Response.
How to wrap org.json4s.JValue into the body of org.asynchttpclient.Response ?
The key solution when you cannot set the data of the instances. Mock them.
Here, I use Mockito. Add the dependency
In Scala
Notice I stubbed the method
getResponseBodyAsStream. Why not another ? Because the asserted functionprocesscalls this previous method.