Class RealtimeMockBuilder

java.lang.Object
org.mockserver.client.RealtimeMockBuilder

public class RealtimeMockBuilder extends Object
Fluent builder that stands MockServer up as a mock realtime voice API — either the OpenAI Realtime API or the Google Gemini Live API — over a WebSocket, so an application/agent using those SDKs can be tested offline.

It produces a single httpWebSocketResponse expectation that reuses the generic WebSocket mock primitive: an initial pushed frame (OpenAI session.created) plus per-incoming-frame matchers that reply to the client's control messages with the provider-correct scripted event sequence generated by OpenAiRealtimeCodec / GeminiLiveCodec. No new action type, DTO, or JSON schema is required — exactly as A2A streaming reuses httpSseResponse.

OpenAI Realtime (wss://.../v1/realtime): the mock pushes session.created on connect, acknowledges session.updatesession.updated and conversation.item.createconversation.item.created, and answers each response.create with the scripted response event sequence (…deltas… → response.done with usage).

Gemini Live (BidiGenerateContent): the mock answers setupsetupComplete and each clientContent turn with the scripted serverContent chunk stream + turnComplete.

The same script answers every matching frame, so a client that sends response.create / clientContent N times receives the scripted turn N times.

 RealtimeMockBuilder.openAiRealtime()
     .withModel("gpt-realtime")
     .respondingWith("The capital of France is Paris.")
     .applyTo(mockServerClient);