Packages

  • package root
    Definition Classes
    root
  • package sttp
    Definition Classes
    root
  • package client
    Definition Classes
    sttp
  • package testing
    Definition Classes
    client
  • class SttpBackendStub[F[_], S, WS_HANDLER[_]] extends SttpBackend[F, S, WS_HANDLER]

    A stub backend to use in tests.

    A stub backend to use in tests.

    The stub can be configured to respond with a given response if the request matches a predicate (see the whenRequestMatches() method).

    Note however, that this is not type-safe with respect to the type of the response body - the stub doesn't have a way to check if the type of the body in the configured response is the same as the one specified by the request. Some conversions will be attempted (e.g. from a String to a custom mapped type, as specified in the request, see the documentation for more details).

    Hence, the predicates can match requests basing on the URI or headers. A ClassCastException might occur if for a given request, a response is specified with the incorrect or inconvertible body type.

    Definition Classes
    testing
  • WhenRequest

class WhenRequest extends AnyRef

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. WhenRequest
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new WhenRequest(p: (Request[_, _]) ⇒ Boolean)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  15. def thenHandleOpenWebSocket[WS_RESULT](headers: Headers, useHandler: (WS_HANDLER[WS_RESULT]) ⇒ WS_RESULT): SttpBackendStub[F, S, WS_HANDLER]

    When openWebsocket() is called, the given headers and handler are used to create the result.

    When openWebsocket() is called, the given headers and handler are used to create the result. This method of stubbing is best suited when openWebsocket() is called with a handler that doesn't return a "high-level" WebSocket, but instead e.g. a backend-specific stream.

  16. def thenHandleOpenWebSocket[WS_RESULT](useHandler: (WS_HANDLER[WS_RESULT]) ⇒ WS_RESULT): SttpBackendStub[F, S, WS_HANDLER]

    When openWebsocket() is called, the given headers and handler are used to create the result.

    When openWebsocket() is called, the given headers and handler are used to create the result. This method of stubbing is best suited when openWebsocket() is called with a handler that doesn't return a "high-level" WebSocket, but instead e.g. a backend-specific stream.

  17. def thenRespond[T](resp: ⇒ Response[T]): SttpBackendStub[F, S, WS_HANDLER]
  18. def thenRespond[T](body: T): SttpBackendStub[F, S, WS_HANDLER]
  19. def thenRespondCyclic[T](bodies: T*): SttpBackendStub[F, S, WS_HANDLER]

    Not thread-safe!

  20. def thenRespondCyclicResponses[T](responses: Response[T]*): SttpBackendStub[F, S, WS_HANDLER]

    Not thread-safe!

  21. def thenRespondNotFound(): SttpBackendStub[F, S, WS_HANDLER]
  22. def thenRespondOk(): SttpBackendStub[F, S, WS_HANDLER]
  23. def thenRespondServerError(): SttpBackendStub[F, S, WS_HANDLER]
  24. def thenRespondWebSocket(headers: Headers, wsStub: WebSocketStub[_]): SttpBackendStub[F, S, WS_HANDLER]

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned.

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned. This method of stubbing should be used when using the "high-level" websockets, that is when WS_RESULT is WebSocket.

    The websocket instance will be built using the given WebSocketStub.

  25. def thenRespondWebSocket(wsStub: WebSocketStub[_]): SttpBackendStub[F, S, WS_HANDLER]

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned.

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned. This method of stubbing should be used when using the "high-level" websockets, that is when WS_RESULT is WebSocket.

    The websocket instance will be built using the given WebSocketStub.

  26. def thenRespondWebSocket[WS_RESULT](headers: Headers, result: WS_RESULT): SttpBackendStub[F, S, WS_HANDLER]

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned.

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned. This method of stubbing is best suited when using the "high-level" websockets, that is when WS_RESULT is WebSocket.

  27. def thenRespondWebSocket[WS_RESULT](result: WS_RESULT): SttpBackendStub[F, S, WS_HANDLER]

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned.

    When openWebsocket() is called, the passed handler will be ignored, and the given result will be returned. This method of stubbing is best suited when using the "high-level" websockets, that is when WS_RESULT is WebSocket.

  28. def thenRespondWithCode(status: StatusCode, msg: String = ""): SttpBackendStub[F, S, WS_HANDLER]
  29. def thenRespondWrapped(resp: (Request[_, _]) ⇒ F[Response[_]]): SttpBackendStub[F, S, WS_HANDLER]
  30. def thenRespondWrapped(resp: ⇒ F[Response[_]]): SttpBackendStub[F, S, WS_HANDLER]
  31. def toString(): String
    Definition Classes
    AnyRef → Any
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  34. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped