TST_InvokeFlowMock.MockBuilder
Class
global class TST_InvokeFlowMock.MockBuilderFluent builder for registering a mock flow response.
Since: 1.0
Example:
TST_InvokeFlowMock.forFlow('Foobar_SetDefaults')
.succeed()
.withOutputRecord(record)
.register();Methods
| Method | Description |
|---|---|
| global TST_InvokeFlowMock.MockBuilder fail(String errorMessage) | Declares this mock simulates a flow failure. |
| global void register() | Registers this mock in the static registry. |
| global TST_InvokeFlowMock.MockBuilder succeed() | Declares this mock returns a successful flow result. |
| global TST_InvokeFlowMock.MockBuilder throwOnStart(Exception toThrow) | Configures this mock to raise the supplied exception at the point in the trigger framework where Flow.Interview.start() would have run for a real flow. |
| global TST_InvokeFlowMock.MockBuilder withOutputRecord(SObject outputRecord) | Supplies the SObject the mocked flow's record output returns. |
| global TST_InvokeFlowMock.MockBuilder withOutputRecords(List<SObject> outputRecords) | Supplies the list of SObjects the mocked flow returns when the registration needs to seed multiple output records (e.g. |
Method Details
fail
global TST_InvokeFlowMock.MockBuilder fail(String errorMessage)Declares this mock simulates a flow failure.
Parameters:
errorMessage(String) - The error message returned by the mock
Returns: TST_InvokeFlowMock.MockBuilder - This builder for chaining
Since: 1.0
register
global void register()Registers this mock in the static registry. Terminal.
Throws if a mock for the same flow is already registered. Tests that need to reconfigure a mock mid-method must call TST_InvokeFlowMock.clear() first.
Throws:
- UTIL_Exceptions.IllegalStateException - When a mock is already registered for this flow
Since: 1.0
succeed
global TST_InvokeFlowMock.MockBuilder succeed()Declares this mock returns a successful flow result.
Default state — call is optional but improves readability.
Returns: TST_InvokeFlowMock.MockBuilder - This builder for chaining
Since: 1.0
throwOnStart
global TST_InvokeFlowMock.MockBuilder throwOnStart(Exception toThrow)Configures this mock to raise the supplied exception at the point in the trigger framework where Flow.Interview.start() would have run for a real flow. Lets test authors drive the runtime-error catch path (the framework's catch (Exception runtimeError) branch and the LogAndContinue / BlockDml routing that depends on it) without deploying a deliberately-broken flow XML.
Marks this mock as a failure (success = false); the supplied exception's getMessage() is what the trigger framework records and surfaces to subscribers.
Parameters:
toThrow(Exception) - The exception the trigger framework will throw on the test author's behalf
Returns: TST_InvokeFlowMock.MockBuilder - This builder for chaining
Since: 1.0
Example:
TST_InvokeFlowMock.forFlow('Foobar_SetDefaults')
.throwOnStart(new System.NullPointerException())
.register();withOutputRecord
global TST_InvokeFlowMock.MockBuilder withOutputRecord(SObject outputRecord)Supplies the SObject the mocked flow's record output returns.
Parameters:
outputRecord(SObject) - The SObject the flow's record output variable yields
Returns: TST_InvokeFlowMock.MockBuilder - This builder for chaining
Since: 1.0
withOutputRecords
global TST_InvokeFlowMock.MockBuilder withOutputRecords(List<SObject> outputRecords)Supplies the list of SObjects the mocked flow returns when the registration needs to seed multiple output records (e.g. a flow that populates a records collection variable). For the default per-record dispatch path, use withOutputRecord(SObject) instead.
Parameters:
outputRecords(List) - The list of SObjects the flow returns
Returns: TST_InvokeFlowMock.MockBuilder - This builder for chaining
Since: 1.0