SoqlStubProvider Class

Contains a method to create a mock test class for handling SOQL query responses for Data 360 data model objects (DMOs).

System

To create mock test classes, extend the SoqlStubProvider class and override the handleSoqlQuery() class method.

SOQL For Loops in Apex aren’t supported for SOQL stubs in static or dynamic SOQL queries against DMOs.

See Mock SOQL Tests for Data 360 Data Model Objects in the Apex Developer Guide.

This example shows a mock test class for the SkyMilesForBusinessOptInController class.

The following are methods for SoqlStubProvider.

Defines a mocked response for a SOQL query executed against the specified SObject type.

public List<SObject> handleSoqlQuery(Schema.SObjectType targetType, String stubbedQuery, Map<String,Object> bindMap)

  • targetType: Type: Schema.SObjectType The SObject type to be stubbed. This parameter can’t be null.
  • stubbedQuery: Type: String The SOQL query whose response is to be stubbed. Bind variables are replaced with placeholders.
  • bindMap: Type: Map<String,Object> A map that contains placeholder keys for each bind variable specified in the SOQL query string and its value.

Type: List<SObject>

The list of stubbed SObjects resulting from the SOQL query.

See Also