The answer to this depends on whether you want to mock the response using ApexMocks or some other dependency injection scheme
No mocking of response required
Within your selector class
public virtual AggregateResult[] selectTurnoverGroupedByName(..) {
return [SELECT DX_Support__r.Name support, SUM(total__c) total
FROM DX_Turnover__c GROUP BY DX_Support__r.Name LIMIT 10
}
That is, the selector class includes a normal Aggregate Query SOQL without using any of the fflib_QueryFactory methods as those don't support aggregate queries.
Mocking of Response required
If using ApexMocks or other dependency injection, Apex doesn't permit mocking AggregateResult
, even if you use the JSON serialize/deserialize approach. So, your selector method is going to have to return a Proxy object that models AggregateResult
as a Map<String,Object>
. There's a Q&A on approaches to do this in this answer