Interface AsyncApiControlPlane

All Known Implementing Classes:
AsyncApiControlPlaneImpl

public interface AsyncApiControlPlane
SPI interface for the AsyncAPI control-plane, defined in mockserver-core so that HttpState can route PUT/GET /mockserver/asyncapi without depending on the mockserver-async module.

The implementation lives in org.mockserver.async.controlplane.AsyncApiControlPlaneImpl (mockserver-async) and is registered at server startup via AsyncApiControlPlaneRegistry.register(AsyncApiControlPlane).

This follows the same singleton-registry pattern used by GrpcHealthRegistry, WasmStore, and DriftStore: a lightweight interface/holder in core, implementation in an optional module, HttpState routes to the holder, and the holder gracefully returns "not available" when no implementation is registered.

  • Method Summary

    Modifier and Type
    Method
    Description
    Generate HTTP mock expectations from an AsyncAPI spec so that example messages can be served over plain HTTP (one GET expectation per channel returning a schema-aware example payload), without standing up a live message broker.
    com.fasterxml.jackson.databind.JsonNode
    load(String requestBody)
    Load an AsyncAPI spec and start mocking (publishing and/or subscribing).
    void
    Reset all async mocking state — stop publishers/subscribers, clear recorded messages.
    com.fasterxml.jackson.databind.JsonNode
    Return the current status: loaded spec info, active channels, publishers, subscribers, and recorded messages.
    verify(String verificationJson)
    Verify that recorded messages match the given criteria.
  • Method Details

    • load

      com.fasterxml.jackson.databind.JsonNode load(String requestBody)
      Load an AsyncAPI spec and start mocking (publishing and/or subscribing).
      Parameters:
      requestBody - the raw request body — either a plain AsyncAPI spec (JSON/YAML) or a JSON wrapper {"spec": "...", "brokerConfig": {...}}
      Returns:
      a JSON status node describing what was loaded and started
    • status

      com.fasterxml.jackson.databind.JsonNode status()
      Return the current status: loaded spec info, active channels, publishers, subscribers, and recorded messages.
      Returns:
      a JSON status node
    • reset

      void reset()
      Reset all async mocking state — stop publishers/subscribers, clear recorded messages. Called from HttpState.reset().
    • verify

      String verify(String verificationJson)
      Verify that recorded messages match the given criteria.

      The verification request is a JSON string with fields:

      • channel (required) — the channel/topic to check
      • payloadSubstring (optional) — payload must contain this substring
      • payloadJsonPath (optional) — a dot-notation JSON path to extract
      • expectedValue (optional) — the expected value at the JSON path
      • count (optional) — object with atLeast, atMost, or exactly fields; defaults to atLeast: 1
      Parameters:
      verificationJson - the JSON verification request
      Returns:
      null or empty string if the verification passes; a human-readable failure description if it does not
      Throws:
      IllegalArgumentException - if the request is malformed
    • generateHttpExpectations

      String generateHttpExpectations(String requestBody)
      Generate HTTP mock expectations from an AsyncAPI spec so that example messages can be served over plain HTTP (one GET expectation per channel returning a schema-aware example payload), without standing up a live message broker.

      This is the import analogue of load(String): instead of publishing example messages to a broker, it returns expectations the caller can register on the HTTP mock. Implemented in mockserver-async (which has access to mockserver-core types), the result is returned as a JSON array string in the standard MockServer expectation format, so that HttpState can deserialize and add it without a compile-time dependency on the async module's parser.

      Parameters:
      requestBody - the raw request body — a plain AsyncAPI spec (JSON/YAML) or a JSON wrapper {"spec": "...", "channelPathPrefix": "..."}
      Returns:
      a JSON array string of MockServer expectations (one per channel)
      Throws:
      IllegalArgumentException - if the spec is missing or cannot be parsed