Class LlmMockBuilder


  • public class LlmMockBuilder
    extends Object
    Fluent builder for creating LLM mock expectations.

    Usage:

     llmMock("/v1/messages")
         .withProvider(Provider.ANTHROPIC)
         .withModel("claude-sonnet-4")
         .respondingWith(
             completion()
                 .withText("The capital of France is Paris.")
                 .withStopReason("end_turn")
                 .withUsage(usage().withInputTokens(42).withOutputTokens(8))
         )
         .applyTo(mockServerClient);
     
    • Method Detail

      • llmMock

        public static LlmMockBuilder llmMock​(String path)
        Entry point for building an LLM mock expectation.
        Parameters:
        path - the HTTP path to match (e.g. "/v1/messages", "/v1/chat/completions")
        Returns:
        a new LlmMockBuilder
      • applyTo

        public Expectation[] applyTo​(MockServerClient client)
        Build the expectation and register it with the MockServerClient.
        Parameters:
        client - the MockServerClient to register with
        Returns:
        the created expectations
      • build

        public Expectation build()
        Build the expectation without registering it.
        Returns:
        the built expectation