Class PactVerifier

java.lang.Object
org.mockserver.mock.pact.PactVerifier

public class PactVerifier extends Object
Verifies that MockServer's currently-active expectations satisfy each interaction in a Pact v3 consumer contract. This closes the consumer-driven-contract loop: the consumer can export a contract via PactExporter, and the provider (MockServer) can verify that its expectations produce the expected responses.

For each interaction, the verifier:

  1. Builds an HttpRequest from the interaction's request fields (method, path, query, headers, body) — mirroring how PactExporter maps fields, in reverse.
  2. Finds matching active expectations via the matching engine (RequestMatchers.retrieveExpectationsMatchingRequest(org.mockserver.model.RequestDefinition)).
  3. Compares the first matched expectation's response to the interaction's expected response (status, headers subset, body).

Only expectations with a static HttpResponse action are verifiable. Forward, callback, and template actions are flagged as "unverifiable (non-static action)".