v6.0.1
Release Notes - Fix toIdsOf/toValuesOf Mocking
SOQL_Test.cls
Added comprehensive test methods for mocking scenarios:
- ✅
toIdWithMocking(): Tests single Id extraction with mocked data - ✅
toIdsWithMocking(): Tests multiple Ids extraction with mocked data - ✅
toIdsOfWithMocking(): Tests field aliasing for Id extraction with AggregateResult mocking - ✅
toIdsOfRelationshipFieldWithMocking(): Tests relationship field Id extraction with mocking
Key Testing Pattern:
SOQL.mock('mockingQuery').thenReturn(
(List<AggregateResult>) JSON.deserialize(
JSON.serialize(new List<Map<String, Object>>{
new Map<String, Object>{ 'Id' => SOQL.IdGenerator.get(Account.SObjectType) }
}),
List<AggregateResult>.class
)
);What This Fixes
Before the Fix
// This would fail with mocking
Set<Id> parentIds = SOQL.of(Account.SObjectType)
.mockId('test')
.toIdsOf(Account.ParentId);After the Fix
// Setup mock with AggregateResult structure
SOQL.mock('test').thenReturn(
(List<AggregateResult>) JSON.deserialize(
JSON.serialize(new List<Map<String, Object>>{
new Map<String, Object>{ 'Id' => someAccountId }
}),
List<AggregateResult>.class
)
);
// Now works properly
Set<Id> parentIds = SOQL.of(Account.SObjectType)
.mockId('test')
.toIdsOf(Account.ParentId);