Class BreakpointMatcher
The prebuilt HttpRequestMatcher is created once at registration time
(via MatcherBuilder.transformsToMatcher(RequestDefinition))
and reused for every findMatch call — no allocation on the hot path.
The clientId identifies the owning callback WebSocket client.
It is required -- matched exchanges are always dispatched over the callback
WebSocket to the owning client for interactive resolution.
Conditional (Nth-hit / skip-count) breakpoints: an optional
skipCount delays the first pause. The matcher still matches
normally on every hit, but only pauses once it has been hit more than
skipCount times. With skipCount = 2 the breakpoint does NOT
pause on hits 1 and 2 and DOES pause from hit 3 onward. When skipCount
is null (the default) the breakpoint pauses on every hit (legacy
behaviour). The per-matcher hit counter (hitCount) is incremented
atomically by shouldPause(), so the decision is thread-safe under
concurrent matching.
Response-content conditional breakpoints: optional response conditions
(responseStatusCodeMin/responseStatusCodeMax for an inclusive
status-code range, and responseBodyContains for a regex searched within
the response body) gate whether a RESPONSE-phase breakpoint pauses. They are only
evaluated at the response phase (the response is not yet known at the request
phase). When set, the breakpoint pauses only when the response satisfies all
configured conditions (in addition to the request matcher and any skip-count). When
all are null (the default) the breakpoint pauses regardless of response
content (legacy behaviour). The responseBodyContains pattern is compiled
once at registration (find semantics — pauses if the body contains a match).
Value-equality is on id only (UUID assigned at registration).
-
Constructor Summary
ConstructorsConstructorDescriptionBreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher) BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher, String clientId) BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher, String clientId, Integer skipCount) BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher, String clientId, Integer skipCount, Integer responseStatusCodeMin, Integer responseStatusCodeMax, String responseBodyContains) -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe callback WebSocket client id that owns this breakpoint (required).longThe number of times this breakpoint has matched (for diagnostics / tests).getId()The optional regular expression searched (find semantics) within the response body, ornullif no body condition is configured.Upper bound (inclusive) of the optional response status-code condition, ornullif no upper bound is configured.Lower bound (inclusive) of the optional response status-code condition, ornullif no lower bound is configured.The optional skip-count: the number of matching hits to skip before the breakpoint starts pausing.inthashCode()booleanWhether this breakpoint has any response-content condition (status-code range or body pattern) that must be satisfied for it to pause at the RESPONSE phase.booleanresponseConditionMatches(HttpResponse response) Evaluates the optional response-content conditions against the given response.booleanRecords a matching hit and decides whether this hit should actually pause.toString()
-
Constructor Details
-
BreakpointMatcher
public BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher) -
BreakpointMatcher
public BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher, String clientId) -
BreakpointMatcher
public BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher, String clientId, Integer skipCount) -
BreakpointMatcher
public BreakpointMatcher(String id, RequestDefinition requestMatcher, Set<BreakpointPhase> phases, HttpRequestMatcher prebuiltMatcher, String clientId, Integer skipCount, Integer responseStatusCodeMin, Integer responseStatusCodeMax, String responseBodyContains)
-
-
Method Details
-
getId
-
getRequestMatcher
-
getPhases
-
getPrebuiltMatcher
-
getClientId
The callback WebSocket client id that owns this breakpoint (required). -
getSkipCount
The optional skip-count: the number of matching hits to skip before the breakpoint starts pausing.null(the default) means pause on every hit. A value ofnmeans do not pause on the firstnhits and pause from hitn + 1onward. -
getResponseStatusCodeMin
Lower bound (inclusive) of the optional response status-code condition, ornullif no lower bound is configured. -
getResponseStatusCodeMax
Upper bound (inclusive) of the optional response status-code condition, ornullif no upper bound is configured. -
getResponseBodyContains
The optional regular expression searched (find semantics) within the response body, ornullif no body condition is configured. -
hasResponseCondition
public boolean hasResponseCondition()Whether this breakpoint has any response-content condition (status-code range or body pattern) that must be satisfied for it to pause at the RESPONSE phase. -
responseConditionMatches
Evaluates the optional response-content conditions against the given response.Returns
truewhen the response satisfies all configured conditions (status-code within the inclusive[min, max]range, and the body matches theresponseBodyContainsregex via find semantics). When no conditions are configured this returnstrue(the legacy behaviour: pause regardless of response content). Anullresponse ornullstatus code fails any configured status-code condition; anull/empty body fails any configured body condition.- Parameters:
response- the response about to be written to the downstream client- Returns:
trueif the response satisfies all configured conditions
-
getHitCount
public long getHitCount()The number of times this breakpoint has matched (for diagnostics / tests). -
shouldPause
public boolean shouldPause()Records a matching hit and decides whether this hit should actually pause.Called exactly once per matching exchange/phase (from
BreakpointMatcherRegistry.findMatch(org.mockserver.model.RequestDefinition, org.mockserver.mock.breakpoint.BreakpointPhase)). Increments the per-matcher counter atomically and returnstrueif the breakpoint should pause for this hit,falseif the hit falls within the configured skip-count window. WhenskipCountisnullthis always returnstrue(pause every time).- Returns:
trueto pause this hit,falseto skip it
-
equals
-
hashCode
public int hashCode() -
toString
-