Class MockingFlowableHttpClient

java.lang.Object
com.flowable.serviceregistry.engine.impl.invoker.rest.mock.MockingFlowableHttpClient
All Implemented Interfaces:
org.flowable.http.common.api.client.FlowableHttpClient

public class MockingFlowableHttpClient extends Object implements org.flowable.http.common.api.client.FlowableHttpClient
  • Field Details

    • MOCK_RESPONSE_FLAG

      public static final String MOCK_RESPONSE_FLAG
      See Also:
    • MOCK_OVERRIDE_KEY

      public static final String MOCK_OVERRIDE_KEY
      Reserved additionalData/serviceData key carrying the per-call mock override Map ({mode, mockResponseKey}). Stamped by agent-side callers (tool callback, guardrail invoker) to drive test-only mock selection. The agent-engine module intentionally duplicates this literal (see AgentMockOverrideConstants .MOCK_OVERRIDE_INVOCATION_KEY); the two constants meet at the wire and neither side depends on the other's module.
      See Also:
    • MOCK_OVERRIDE_MODE_NONE

      public static final String MOCK_OVERRIDE_MODE_NONE
      Mode bypassing mocks: the real HTTP call is performed.
      See Also:
    • MOCK_OVERRIDE_MODE_AUTO

      public static final String MOCK_OVERRIDE_MODE_AUTO
      Mode applying standard mock resolution (priority + match condition + sampling).
      See Also:
    • MOCK_OVERRIDE_MODE_SPECIFIC

      public static final String MOCK_OVERRIDE_MODE_SPECIFIC
      Mode pinning a specific mock by its mockResponseKey, bypassing standard selection.
      See Also:
    • delegate

      protected final org.flowable.http.common.api.client.FlowableHttpClient delegate
    • serviceDefinition

      protected final ServiceDefinitionModel serviceDefinition
    • serviceOperation

      protected final ServiceOperation serviceOperation
    • invocationContext

      protected final ServiceInvocationContext invocationContext
  • Constructor Details

  • Method Details

    • hasJsonContentType

      protected static boolean hasJsonContentType(org.flowable.http.common.api.HttpHeaders headers)
    • prepareRequest

      public org.flowable.http.common.api.client.ExecutableHttpRequest prepareRequest(org.flowable.http.common.api.HttpRequest request)
      Specified by:
      prepareRequest in interface org.flowable.http.common.api.client.FlowableHttpClient
    • resolveOverride

      protected MockingFlowableHttpClient.ResolvedOverride resolveOverride()
      Resolves a per-call mock override from the reserved MOCK_OVERRIDE_KEY. Value is a Map<String,Object> with mode (one of MOCK_OVERRIDE_MODE_NONE, MOCK_OVERRIDE_MODE_AUTO, MOCK_OVERRIDE_MODE_SPECIFIC) and an optional mockResponseKey. Mode parsing is case-insensitive — frontend payloads are lowercase but legacy callers sending uppercase keep working.

      Both serviceData and additionalData are consulted because InvokeServiceCmd folds the builder's additionalData into the context's serviceData before invocation, so a value stamped on the builder via additionalData(...) surfaces on context.getServiceData() at this point. The reserved key namespace (__flowable*) keeps it from colliding with real request payload entries.

    • findMockByKey

      protected MockResponseConfig findMockByKey(String key)
    • executeMockResponse

      protected org.flowable.http.common.api.HttpResponse executeMockResponse(MockResponseConfig mock, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer)
    • buildMockHttpResponse

      protected org.flowable.http.common.api.HttpResponse buildMockHttpResponse(MockResponseConfig mock, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer)
    • createInitializedVariablesContainer

      protected ServiceInvocationVariablesContainer createInitializedVariablesContainer()
    • readMockResponses

      protected List<MockResponseConfig> readMockResponses(ServiceOperation serviceOperation)
    • readMockResponsesFromConfig

      protected List<MockResponseConfig> readMockResponsesFromConfig(tools.jackson.databind.JsonNode config)
    • evaluateExpression

      protected String evaluateExpression(org.flowable.common.engine.impl.el.ExpressionManager expressionManager, String value, ServiceInvocationVariablesContainer variablesContainer)
    • selectMockResponse

      protected MockResponseConfig selectMockResponse(List<MockResponseConfig> mockResponses, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer)
    • isMockEnabled

      public static boolean isMockEnabled(ServiceRegistryEngineConfiguration engineConfiguration, String serviceKey, String tenantId)
      Returns whether mocking is enabled for the given service key. Can be called without creating a MockingFlowableHttpClient instance.
    • asBoolean

      protected static boolean asBoolean(Object object)