-
Notifications
You must be signed in to change notification settings - Fork 0
The MockDml.History Class
Jason Siders edited this page Aug 5, 2025
·
9 revisions
This class stores records that were submitted for a particular DML operation while using mocks. It contains methods that allow callers to inspect what changes were made during the course of a test.
Clears all MockDml.History objects in the current mock Database.
static void eraseAllHistories()
DatabaseLayer.useMocks();
DatabaseLayer.Dml.doInsert(account);
MockDml.INSERTED.eraseHistory();
Assert.isFalse(MockDml.INSERTED.wasProcessed(account));Returns a specific record that was processed by the current DML operation. Returns null if no such record was processed.
get(SObjectType objectType, String idOrUuid)get(Id recordId)get(SObject record)
DatabaseLayer.useMocks();
DatabaseLayer.Dml.doInsert(account);
Account insertedAcc = (Account) MockDml.INSERTED.get(account);Retrieves a map of records that were processed by the current DML operation, grouped by their SObjectType:
Map<SObjectType, List<SObject>> getAll()
DatabaseLayer.useMocks();
DatabaseLayer.Dml.doInsert(account);
Assert.isFalse(MockDml.INSERTED.getAll()?.isEmpty(), 'Did not insert any records');Retrieves a list of all records of the provided SObjectType that were processed by the current DML operation.
List<SObject> getRecords(SObjectType objectType)
DatabaseLayer.useMocks();
DatabaseLayer.Dml.doInsert(account);
Assert.isFalse(MockDml.INSERTED.getRecords(Account.SObjectType)?.isEmpty(), 'Did not insert accounts');Determines if a specific record was processed by the current DML operation.
wasProcessed(SObjectType objectType, String idOrUuid)wasProcessed(Id recordId)wasProcessed(SObject record)
DatabaseLayer.useMocks();
DatabaseLayer.Dml.doInsert(account);
Assert.isTrue(MockDml.INSERTED.wasProcessed(account), 'Did not insert account');- Generating Test Records
- Dml
- Soql
- Cmdt
- Duplicates
- Plugins
- DatabaseLayer
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- Duplicates
- MockDuplicates
- MockSoql
-
Soql
- Soql.AggregateResult
- Soql.Aggregation
- Soql.Binder
- Soql.Builder
- Soql.Condition
- Soql.ConditionalLogic
- Soql.Criteria
- Soql.Cursor
- Soql.Function
- Soql.InnerQuery
- Soql.InvalidParameterValueException
- Soql.LogicType
- Soql.NullOrder
- Soql.Operation
- Soql.Operator
- Soql.ParentField
- Soql.PreAndPostProcessor
- Soql.QueryLocator
- Soql.Request
- Soql.Scope
- Soql.Selectable
- Soql.SortDirection
- Soql.SortOrder
- Soql.Subquery
- Soql.TypeOf
- Soql.Usage
- Soql.WhenClause