Class CaptureProcessor

java.lang.Object
org.mockserver.mock.CaptureProcessor

public class CaptureProcessor extends Object
Declarative capture-rule processor (WS2.2). When an expectation matches an incoming request, process(List, RequestDefinition) evaluates each CaptureRule against the request and stores the extracted value into scenario state, so a later request's response template can read it back via scenario.get(name) (WS2.1).

The state is written to the live ScenarioManager resolved from CrossProtocolEventBus.getInstance() — the same instance the scenario template helper reads from — so a value captured here is immediately visible to a subsequent template read and to matcher matchesState checks.

Capture is best-effort and side-effect-only: a malformed expression, a missing value, or the absence of a live ScenarioManager is logged at debug and skipped, never failing the matched response. An expectation without capture rules is entirely unaffected.

  • Method Details

    • process

      public static void process(List<CaptureRule> captureRules, RequestDefinition requestDefinition)
      Evaluates each capture rule against the request and writes the captured value into scenario state. No-op when captureRules is null/empty, the request is not an HttpRequest, or no live ScenarioManager is available.