Class FuzzyBody


public class FuzzyBody extends Body<String>
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
  • Field Details

  • Constructor Details

    • FuzzyBody

      public FuzzyBody(String value)
    • FuzzyBody

      public FuzzyBody(String value, double threshold)
    • FuzzyBody

      public FuzzyBody(String value, double threshold, boolean ignoreCase)
  • Method Details

    • getValue

      public String getValue()
      Specified by:
      getValue in class Body<String>
    • getThreshold

      public double getThreshold()
    • isIgnoreCase

      public boolean isIgnoreCase()
    • fuzzy

      public static FuzzyBody fuzzy(String value)
      Match when the request body is at least 80% similar to value.
    • fuzzy

      public static FuzzyBody fuzzy(String value, double threshold)
      Match when the request body is at least threshold similar to value.
      Parameters:
      threshold - required similarity ratio between 0.0 and 1.0
    • fuzzy

      public static FuzzyBody fuzzy(String value, double threshold, boolean ignoreCase)
      Match when the request body is at least threshold similar to value, optionally ignoring case (and surrounding whitespace) when comparing.
      Parameters:
      threshold - required similarity ratio between 0.0 and 1.0
      ignoreCase - when true both strings are trimmed and lower-cased before comparison
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Body<String>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Body<String>