diff options
3 files changed, 12 insertions, 5 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala index 72d3490..f62959f 100644 --- a/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala +++ b/core/src/main/scala/com/softwaremill/sttp/testing/SttpBackendStub.scala @@ -41,7 +41,8 @@ class SttpBackendStub[R[_], S] private (rm: MonadError[R], override def send[T](request: Request[T, S]): R[Response[T]] = { matchers .collectFirst { - case matcher: Matcher[T] if matcher(request) => matcher.response(request).get + case matcher: Matcher[T @unchecked] if matcher(request) => + matcher.response(request).get } match { case Some(response) => wrapResponse(response) case None => @@ -111,7 +112,8 @@ object SttpBackendStub { private val DefaultResponse = Response[Nothing](Left("Not Found"), 404, Nil, Nil) - private case class Matcher[T](p: PartialFunction[Request[T, _], Response[_]]) { + private case class Matcher[T]( + p: PartialFunction[Request[T, _], Response[_]]) { def apply(request: Request[T, _]): Boolean = p.isDefinedAt(request) diff --git a/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala b/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala index d10d1b6..9e10cd7 100644 --- a/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala +++ b/core/src/test/scala/com/softwaremill/sttp/testing/SttpBackendStubTests.scala @@ -13,8 +13,14 @@ class SttpBackendStubTests extends FlatSpec with Matchers with ScalaFutures { .whenRequestMatches(_.method == Method.GET) .thenRespondServerError() .whenRequestMatchesPartial({ - case r if r.method == Method.POST && r.uri.path.endsWith(List("partial10")) => Response(Right(10), 200, Nil, Nil) - case r if r.method == Method.POST && r.uri.path.endsWith(List("partialAda")) => Response(Right("Ada"), 200, Nil, Nil) + case r + if r.method == Method.POST && r.uri.path.endsWith( + List("partial10")) => + Response(Right(10), 200, Nil, Nil) + case r + if r.method == Method.POST && r.uri.path.endsWith( + List("partialAda")) => + Response(Right("Ada"), 200, Nil, Nil) }) "backend stub" should "use the first rule if it matches" in { diff --git a/okhttp-backend/monix/src/main/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixBackend.scala b/okhttp-backend/monix/src/main/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixBackend.scala index db36f32..e85d271 100644 --- a/okhttp-backend/monix/src/main/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixBackend.scala +++ b/okhttp-backend/monix/src/main/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixBackend.scala @@ -14,7 +14,6 @@ import okhttp3.{MediaType, OkHttpClient, RequestBody => OkHttpRequestBody} import okio.BufferedSink import scala.concurrent.Future -import scala.concurrent.duration.FiniteDuration import scala.util.{Failure, Success, Try} class OkHttpMonixBackend private (client: OkHttpClient, closeClient: Boolean)( |