Class HttpTestTarget

  • All Implemented Interfaces:
    au.com.dius.pact.provider.junit5.TestTarget

    
    public class HttpTestTarget
     implements TestTarget
                        

    Test target for HTTP tests. This is the default target.

    • Constructor Detail

      • HttpTestTarget

        HttpTestTarget(String host, Integer port, String path, Function0<IHttpClientFactory> httpClientFactory)
      • HttpTestTarget

        HttpTestTarget(String host)
      • HttpTestTarget

        HttpTestTarget()
    • Method Detail

      • getHost

         final String getHost()

        Host to bind to. Defaults to localhost.

      • getPort

         final Integer getPort()

        Port that the provider is running on. Defaults to 8080.

      • getPath

         final String getPath()

        The path that the provider is mounted on. Defaults to the root path.

      • getProviderInfo

         IProviderInfo getProviderInfo(String serviceName, PactSource pactSource)

        Returns information about the provider

      • prepareRequest

         Pair<Object, Object> prepareRequest(Pact pact, Interaction interaction, Map<String, Object> context)

        Prepares the request for the interaction.

        Returns:

        a pair of the client class and request to use for the test, or null if there is none

      • prepareVerifier

         Unit prepareVerifier(IProviderVerifier verifier, Object testInstance, Pact pact)

        Prepares the verifier for use during the test

      • executeInteraction

         ProviderResponse executeInteraction(Object client, Object request)

        Executes the test (using the client and request from prepareRequest, if any)

        Returns:

        Map of failures, or an empty map if there were not any

      • fromUrl

         final static HttpTestTarget fromUrl(URL url)

        Creates a HttpTestTarget from a URL. If the URL does not contain a port, 8080 will be used.