Class HttpInteractionDsl

  • All Implemented Interfaces:

    
    public final class HttpInteractionDsl
    
                        

    Receiver for an interaction or uponReceiving block. Configures a single HTTP interaction.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit given(String state, Map<String, Object> params) Adds a provider state to this interaction.
      final Unit given(String state, Pair<String, Object> params) Adds a provider state with key/value parameters to this interaction.
      final Unit pending(Boolean pending) Marks this interaction as pending.
      final Unit comment(String comment) Adds a text comment to the interaction.
      final Unit withRequest(Function1<HttpRequestBuilder, Unit> block) Configures the expected HTTP request.
      final Unit willRespondWith(Function1<HttpResponseBuilder, Unit> block) Configures the expected HTTP response.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpInteractionDsl

        HttpInteractionDsl()
    • Method Detail

      • given

         final Unit given(String state, Map<String, Object> params)

        Adds a provider state to this interaction. May be called multiple times for multiple states.

      • pending

         final Unit pending(Boolean pending)

        Marks this interaction as pending. A pending interaction will not cause provider verification to fail.

      • comment

         final Unit comment(String comment)

        Adds a text comment to the interaction.

      • withRequest

         final Unit withRequest(Function1<HttpRequestBuilder, Unit> block)

        Configures the expected HTTP request. The block receives an HttpRequestBuilder as its receiver, giving access to HttpRequestBuilder.method, HttpRequestBuilder.path, HttpRequestBuilder.header, HttpRequestBuilder.queryParameter, HttpRequestBuilder.body, and more.

      • willRespondWith

         final Unit willRespondWith(Function1<HttpResponseBuilder, Unit> block)

        Configures the expected HTTP response. The block receives an HttpResponseBuilder as its receiver, giving access to HttpResponseBuilder.status, HttpResponseBuilder.header, HttpResponseBuilder.body, and semantic status matchers like HttpResponseBuilder.successStatus.