Class MessageTestTarget

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

    
    public class MessageTestTarget
     implements TestTarget
                        

    Test target for use with asynchronous providers (like with message queues) and synchronous request/response message flows (like gRPC or Kafka request/reply strategies).

    This target will look for methods with a @PactVerifyProvider annotation where the value is the description of the interaction. For asynchronous messages, these functions must take no parameter and return the message (or message + metadata), while for synchronous messages they can receive the request message then must return the response message (or message + metadata).

    • Constructor Detail

      • MessageTestTarget

        MessageTestTarget(List<String> packagesToScan)
      • MessageTestTarget

        MessageTestTarget()
    • Method Detail

      • 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