Package org.mockserver.model
Class FuzzyBody
A body matcher that matches when the request body is "similar enough" to an
expected string, using a deterministic string-similarity metric
(normalised Jaro-Winkler) with a configurable threshold between
0.0
and 1.0.
Unlike the LLM-based semantic body matcher this matcher is fully deterministic and requires no external service — the same inputs always produce the same similarity ratio.
- Author:
- jamesdbloom
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic FuzzyBodyMatch when the request body is at least80%similar tovalue.static FuzzyBodyMatch when the request body is at leastthresholdsimilar tovalue.static FuzzyBodyMatch when the request body is at leastthresholdsimilar tovalue, optionally ignoring case (and surrounding whitespace) when comparing.doublegetValue()inthashCode()booleanMethods inherited from class org.mockserver.model.Body
getCharset, getContentType, getOptional, getRawBytes, getType, withOptionalMethods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
fieldsExcludedFromEqualsAndHashCode
-
Field Details
-
DEFAULT_THRESHOLD
public static final double DEFAULT_THRESHOLD- See Also:
-
DEFAULT_IGNORE_CASE
public static final boolean DEFAULT_IGNORE_CASE- See Also:
-
-
Constructor Details
-
FuzzyBody
-
FuzzyBody
-
FuzzyBody
-
-
Method Details
-
getValue
-
getThreshold
public double getThreshold() -
isIgnoreCase
public boolean isIgnoreCase() -
fuzzy
Match when the request body is at least80%similar tovalue. -
fuzzy
Match when the request body is at leastthresholdsimilar tovalue.- Parameters:
threshold- required similarity ratio between0.0and1.0
-
fuzzy
Match when the request body is at leastthresholdsimilar tovalue, optionally ignoring case (and surrounding whitespace) when comparing.- Parameters:
threshold- required similarity ratio between0.0and1.0ignoreCase- whentrueboth strings are trimmed and lower-cased before comparison
-
equals
-
hashCode
public int hashCode()
-