unit testing - stubbing or mocking finagle client

1.2k Views Asked by At

Here is the few lines of code I would like to unit test for different http response codes. One of them is code 201 . Please advise

val cb = ClientBuilder()
val myClient = cb.build()
val req =
      RequestBuilder()
        .url(loginUrl)
        .setHeader("Content-Type", "application/json")
        .buildPost(copiedBuffer(body.getBytes(UTF_8)))

myClient(req).map(http.Response(_)).flatMap { response =>
      response.statusCode match {
        case 201 => //parse response
        case _ =>
          println(" some reseponse")
          Future(proxy(response))
       }
}
0

There are 0 best solutions below