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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.flowable.http.common.api.client.FlowableHttpClientprotected final ServiceInvocationContextstatic final StringReserved additionalData/serviceData key carrying the per-call mock override Map ({mode, mockResponseKey}).static final StringMode applying standard mock resolution (priority + match condition + sampling).static final StringMode bypassing mocks: the real HTTP call is performed.static final StringMode pinning a specific mock by itsmockResponseKey, bypassing standard selection.static final Stringprotected final ServiceDefinitionModelprotected final ServiceOperation -
Constructor Summary
ConstructorsConstructorDescriptionMockingFlowableHttpClient(org.flowable.http.common.api.client.FlowableHttpClient delegate, ServiceDefinitionModel serviceDefinition, ServiceOperation serviceOperation, ServiceInvocationContext invocationContext) -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanprotected org.flowable.http.common.api.HttpResponsebuildMockHttpResponse(MockResponseConfig mock, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer) protected ServiceInvocationVariablesContainerprotected StringevaluateExpression(org.flowable.common.engine.impl.el.ExpressionManager expressionManager, String value, ServiceInvocationVariablesContainer variablesContainer) protected org.flowable.http.common.api.HttpResponseexecuteMockResponse(MockResponseConfig mock, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer) protected MockResponseConfigfindMockByKey(String key) protected static booleanhasJsonContentType(org.flowable.http.common.api.HttpHeaders headers) static booleanisMockEnabled(ServiceRegistryEngineConfiguration engineConfiguration, String serviceKey, String tenantId) Returns whether mocking is enabled for the given service key.org.flowable.http.common.api.client.ExecutableHttpRequestprepareRequest(org.flowable.http.common.api.HttpRequest request) protected List<MockResponseConfig> readMockResponses(ServiceOperation serviceOperation) protected List<MockResponseConfig> readMockResponsesFromConfig(tools.jackson.databind.JsonNode config) Resolves a per-call mock override from the reservedMOCK_OVERRIDE_KEY.protected MockResponseConfigselectMockResponse(List<MockResponseConfig> mockResponses, org.flowable.common.engine.impl.el.ExpressionManager expressionManager, ServiceInvocationVariablesContainer variablesContainer)
-
Field Details
-
MOCK_RESPONSE_FLAG
- See Also:
-
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 (seeAgentMockOverrideConstants .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
Mode bypassing mocks: the real HTTP call is performed.- See Also:
-
MOCK_OVERRIDE_MODE_AUTO
Mode applying standard mock resolution (priority + match condition + sampling).- See Also:
-
MOCK_OVERRIDE_MODE_SPECIFIC
Mode pinning a specific mock by itsmockResponseKey, bypassing standard selection.- See Also:
-
delegate
protected final org.flowable.http.common.api.client.FlowableHttpClient delegate -
serviceDefinition
-
serviceOperation
-
invocationContext
-
-
Constructor Details
-
MockingFlowableHttpClient
public MockingFlowableHttpClient(org.flowable.http.common.api.client.FlowableHttpClient delegate, ServiceDefinitionModel serviceDefinition, ServiceOperation serviceOperation, ServiceInvocationContext invocationContext)
-
-
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:
prepareRequestin interfaceorg.flowable.http.common.api.client.FlowableHttpClient
-
resolveOverride
Resolves a per-call mock override from the reservedMOCK_OVERRIDE_KEY. Value is aMap<String,Object>withmode(one ofMOCK_OVERRIDE_MODE_NONE,MOCK_OVERRIDE_MODE_AUTO,MOCK_OVERRIDE_MODE_SPECIFIC) and an optionalmockResponseKey. Mode parsing is case-insensitive — frontend payloads are lowercase but legacy callers sending uppercase keep working.Both serviceData and additionalData are consulted because
InvokeServiceCmdfolds the builder'sadditionalDatainto the context'sserviceDatabefore invocation, so a value stamped on the builder viaadditionalData(...)surfaces oncontext.getServiceData()at this point. The reserved key namespace (__flowable*) keeps it from colliding with real request payload entries. -
findMockByKey
-
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
-
readMockResponses
-
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 aMockingFlowableHttpClientinstance. -
asBoolean
-