You need to sign in to do that
Don't have an account?
Runi
test class Schedulable
HI i AM new to apex how to write test class for below class.
public with sharing class RecordsBatch implements Database.Batchable<sObject>,Schedulable{
public Database.QueryLocator start(Database.BatchableContext pBatchContext) {
system.debug('\n\n Label.RecordsBatchQueryOnFeeSplit :: '+Label.RecordsBatchQueryOnFeeSplit);
return Database.getQueryLocator(Label.RecordsBatchQueryOnFeeSplit);
}
public void execute(Database.BatchableContext pBatchContext, List<bank__C> listFeeSplit) {
system.debug('...listFeeSplit...'+listFeeSplit);
List<bank__C> UpdateFeeSplit = new List<bank__C>();
for(bank__C oppFS: listFeeSplit){
bank__C UpdateObjFS = new bank__C();
system.debug('WIP*****');
if(oppFS.Recipient__r.Service_Line__c != oppFS.Recipient_Service_Line__c
|| oppFS.Recipient__r.Business_Unit__c != oppFS.Recipient_Business_Unit__c
|| oppFS.Recipient__r.Revenue_Generating_Team__c != oppFS.Recipient_Revenue_generating_team__c;
|| oppFS.Recipient__r.RGT_ID__c != oppFS.Recipient_RGT_ID__c){
UpdateObjFS.id = oppFS.ID;
UpdateObjFS.Recipient_Service_Line__c = oppFS.Recipient__r.Service_Line__c;
UpdateObjFS.Recipient_Business_Unit__c = oppFS.Recipient__r.Business_Unit__c;
UpdateObjFS.Recipient_Revenue_generating_team__c = oppFS.Recipient__r.Revenue_Generating_Team__c;
UpdateObjFS.Recipient_RGT_ID__c = oppFS.Recipient__r.RGT_ID__c;
system.debug('WIP UpdateObjFS*****'+UpdateObjFS);
UpdateFeeSplit.add(UpdateObjFS);
}
}
if(!UpdateFeeSplit.isEmpty()){
Database.update(UpdateFeeSplit,false);
}
}
public void execute(SchedulableContext ctx) {
RecordsBatch oWB = new RecordsBatch();
database.executebatch(oWB,Integer.valueof(Label.RecordsBatchLimit));
}
public void finish(Database.BatchableContext bc){
}
}
public with sharing class RecordsBatch implements Database.Batchable<sObject>,Schedulable{
public Database.QueryLocator start(Database.BatchableContext pBatchContext) {
system.debug('\n\n Label.RecordsBatchQueryOnFeeSplit :: '+Label.RecordsBatchQueryOnFeeSplit);
return Database.getQueryLocator(Label.RecordsBatchQueryOnFeeSplit);
}
public void execute(Database.BatchableContext pBatchContext, List<bank__C> listFeeSplit) {
system.debug('...listFeeSplit...'+listFeeSplit);
List<bank__C> UpdateFeeSplit = new List<bank__C>();
for(bank__C oppFS: listFeeSplit){
bank__C UpdateObjFS = new bank__C();
system.debug('WIP*****');
if(oppFS.Recipient__r.Service_Line__c != oppFS.Recipient_Service_Line__c
|| oppFS.Recipient__r.Business_Unit__c != oppFS.Recipient_Business_Unit__c
|| oppFS.Recipient__r.Revenue_Generating_Team__c != oppFS.Recipient_Revenue_generating_team__c;
|| oppFS.Recipient__r.RGT_ID__c != oppFS.Recipient_RGT_ID__c){
UpdateObjFS.id = oppFS.ID;
UpdateObjFS.Recipient_Service_Line__c = oppFS.Recipient__r.Service_Line__c;
UpdateObjFS.Recipient_Business_Unit__c = oppFS.Recipient__r.Business_Unit__c;
UpdateObjFS.Recipient_Revenue_generating_team__c = oppFS.Recipient__r.Revenue_Generating_Team__c;
UpdateObjFS.Recipient_RGT_ID__c = oppFS.Recipient__r.RGT_ID__c;
system.debug('WIP UpdateObjFS*****'+UpdateObjFS);
UpdateFeeSplit.add(UpdateObjFS);
}
}
if(!UpdateFeeSplit.isEmpty()){
Database.update(UpdateFeeSplit,false);
}
}
public void execute(SchedulableContext ctx) {
RecordsBatch oWB = new RecordsBatch();
database.executebatch(oWB,Integer.valueof(Label.RecordsBatchLimit));
}
public void finish(Database.BatchableContext bc){
}
}
Kindly refer this example to get the insight for writinh the test class for schedulable class :-
https://salesforce.stackexchange.com/questions/17428/test-class-for-schedulable-interface
https://developer.salesforce.com/forums/?id=906F00000008yhmIAA
If the information was helpful, Kindly mark it as the best answer.
Thanks