Class GrpcBidiRuleMatcher

java.lang.Object
org.mockserver.grpc.GrpcBidiRuleMatcher

public final class GrpcBidiRuleMatcher extends Object
Transport-neutral helper that matches an inbound gRPC bidi message (as JSON) against a GrpcBidiRule's matchJson pattern.

Shared by the HTTP/2 bidi handler (GrpcBidiStreamHandler) and the HTTP/3 bidi handler (Http3GrpcBidiStreamHandler) so the matching semantics are identical across transports:

  • a null/empty pattern matches everything;
  • exact string equality is tried first;
  • then a regex match using Pattern.DOTALL (so '.' matches the newlines that protobuf's JsonFormat.printer() emits in multiline JSON);
  • an invalid regex never matches (rather than throwing);
  • NottableString.isNot() inverts the result.
  • Method Details

    • matches

      public static boolean matches(GrpcBidiRule rule, String inboundJson)
      Parameters:
      rule - the bidi rule whose matchJson pattern is evaluated
      inboundJson - the inbound message converted to JSON
      Returns:
      true if the rule matches the inbound message