function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MMA_FORCEMMA_FORCE 

Test class for aggregate result?

Hi:

   How would one write a test class for aggregate result?

    public String getCustomers(String id){


    
    AggregateResult[] groupedResults = [SELECT Ownerid,Count(Id) ce 
                                        FROM Account 
                                        Where Owner.Level__c = 'AA' 
                                        AND Ownerid=:id AND CreatedDate = LAST_MONTH
                                        GROUP BY Ownerid]; 
                    
    queryResultscs = new List<customers>();
    
    for (AggregateResult ar : groupedResults)  {
        customers myObject = new customers();
        myObject.aaxCS = String.valueOf(ar.get('Ownerid'));
        AACSid =  myObject.aaxCS;
        myObject.TotalCS = (Integer) ar.get('ce');
        Customers = myObject.TotalCS ;
    
    queryResultscs.add(myObject); 
      
    }
    return null;    
    }                               

 Thanks

Z

Rahul BorgaonkarRahul Borgaonkar

Can you provide more details ? Thanks