TST_InvokeFlowMock.MockBuilder
Class
global class TST_InvokeFlowMock.MockBuilderFluent builder for registering a mock flow response.
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. |
fail
global TST_InvokeFlowMock.MockBuilder fail(String errorMessage)Declares this mock simulates a flow failure.
Parameters
| Parameter | Type | Description |
|---|---|---|
errorMessage | String | The error message returned by the mock |
Returns TST_InvokeFlowMock.MockBuilder — This builder for chaining
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
| Exception | Description |
|---|---|
| UTIL_Exceptions.IllegalStateException | When a mock is already registered for this flow |
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
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
| Parameter | Type | Description |
|---|---|---|
toThrow | Exception | The exception the trigger framework will throw on the test author's behalf |
Returns TST_InvokeFlowMock.MockBuilder — This builder for chaining
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
| Parameter | Type | Description |
|---|---|---|
outputRecord | SObject | The SObject the flow's record output variable yields |
Returns TST_InvokeFlowMock.MockBuilder — This builder for chaining
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
| Parameter | Type | Description |
|---|---|---|
outputRecords | List | The list of SObjects the flow returns |
Returns TST_InvokeFlowMock.MockBuilder — This builder for chaining