Class AsyncApiControlPlaneImpl
java.lang.Object
org.mockserver.async.controlplane.AsyncApiControlPlaneImpl
- All Implemented Interfaces:
AsyncApiControlPlane
Implementation of
AsyncApiControlPlane that lives in the mockserver-async
module and is registered into the core's AsyncApiControlPlaneRegistry
at server startup.
Handles:
- Loading AsyncAPI specs via the REST control-plane
- Creating publishers and subscribers for each channel
- Schema validation of generated and consumed messages
- Returning status including recorded messages
- Resetting all state on server reset
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodeLoad an AsyncAPI spec and start mocking (publishing and/or subscribing).static voidRegister this implementation into the core registry.voidreset()Reset all async mocking state — stop publishers/subscribers, clear recorded messages.com.fasterxml.jackson.databind.JsonNodestatus()Return the current status: loaded spec info, active channels, publishers, subscribers, and recorded messages.Verify that recorded messages match the given criteria.
-
Constructor Details
-
AsyncApiControlPlaneImpl
public AsyncApiControlPlaneImpl()
-
-
Method Details
-
registerIfAvailable
public static void registerIfAvailable()Register this implementation into the core registry. Call at server startup (e.g. from MockServerLifeCycle or Main). -
load
Description copied from interface:AsyncApiControlPlaneLoad an AsyncAPI spec and start mocking (publishing and/or subscribing).- Specified by:
loadin interfaceAsyncApiControlPlane- 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
public com.fasterxml.jackson.databind.JsonNode status()Description copied from interface:AsyncApiControlPlaneReturn the current status: loaded spec info, active channels, publishers, subscribers, and recorded messages.- Specified by:
statusin interfaceAsyncApiControlPlane- Returns:
- a JSON status node
-
verify
Description copied from interface:AsyncApiControlPlaneVerify that recorded messages match the given criteria.The verification request is a JSON string with fields:
channel(required) — the channel/topic to checkpayloadSubstring(optional) — payload must contain this substringpayloadJsonPath(optional) — a dot-notation JSON path to extractexpectedValue(optional) — the expected value at the JSON pathcount(optional) — object withatLeast,atMost, orexactlyfields; defaults toatLeast: 1
- Specified by:
verifyin interfaceAsyncApiControlPlane- Parameters:
verificationJson- the JSON verification request- Returns:
nullor empty string if the verification passes; a human-readable failure description if it does not
-
reset
public void reset()Description copied from interface:AsyncApiControlPlaneReset all async mocking state — stop publishers/subscribers, clear recorded messages. Called fromHttpState.reset().- Specified by:
resetin interfaceAsyncApiControlPlane
-