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
roshrosh 

please help me for this test class?

global class VConnect_RetailerClassificationUpdate implements Database.Batchable<sobject>{
    
    global Database.QueryLocator start(Database.BatchableContext BC) 
    {
        String query = 'SELECT Id,Name,VConnect_Retailer_Class__c,RecordType.name FROM Account where RecordType.DeveloperName=\'VConnect_Retailer\' ';
        System.debug('query'+query);
        return Database.getQueryLocator(query);
        
    }
    global void execute(Database.BatchableContext BC, List<Account>scope)
    {
        map<id,String> updatemap = new map<id,String>();
        Decimal TotalInv=0;
        String Classname;
        Account[] updates = new Account[] {}; 
            for (AggregateResult ar : [ select VConnect_Retailer__c a,Sum(Total_Volume_In_Ltrs__c) Inv from VConnect_Invoice__c where VConnect_Retailer__c in :scope group by VConnect_Retailer__c])
        { 
            updates.add(new Account( Id = (Id) ar.get('a'), Total_Invoice_Volume__c = (Decimal) ar.get('Inv') ));   
            System.debug('updates'+updates);
            TotalInv= (Decimal) ar.get('Inv');
            
        } 
        update updates; 
        System.debug('***** TotalInvc*****'+ TotalInv);
        list< Retailer_Classification__mdt> rc = [SELECT Retailer_Class__c,Start_Range_Vol_In_Ltrs__c,End_Range_Vol_In_Ltrs__c FROM Retailer_Classification__mdt where Start_Range_Vol_In_Ltrs__c<=:TotalInv AND End_Range_Vol_In_Ltrs__c>:TotalInv];
        System.debug('*****rc*****'+rc);
        for(Retailer_Classification__mdt rc2: rc){
            Classname = rc2.Retailer_Class__c;
        }
        System.debug('Classname45454'+Classname);
        For (Account ac : scope) {
            ac.VConnect_Retailer_Class__c=Classname;
        }
        update scope; 
        
    } 
    global void finish(Database.BatchableContext BC) 
    {
    }
    
    
}