Created
November 3, 2016 15:00
-
-
Save mannharleen/78981a4ee4478dc4f950d7914bcd53f7 to your computer and use it in GitHub Desktop.
Salesforce trailhead - Asynchronous Apex Scheduling Jobs Using the Apex Scheduler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DailyLeadProcessor implements schedulable{ | |
public void execute(schedulableContext sc) { | |
List<lead> l_lst_new = new List<lead>(); | |
List<lead> l_lst = new List<lead>([select id, leadsource from lead where leadsource = null]); | |
for(lead l : l_lst) { | |
l.leadsource = 'Dreamforce'; | |
l_lst_new.add(l); | |
} | |
update l_lst_new; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class DailyLeadProcessorTest { | |
@isTest | |
public static void testing() { | |
List<lead> l_lst = new List<lead>(); | |
for(Integer i=0;i<200;i++) { | |
lead l = new lead(); | |
l.lastname = 'lastname'+i; | |
l.Company = 'company'+i; | |
l_lst.add(l); | |
} | |
insert l_lst; | |
Test.startTest(); | |
DailyLeadProcessor dlp = new DailyLeadProcessor (); | |
String jobId = System.Schedule('dailyleadprocessing','0 0 0 1 12 ? 2016',dlp); | |
Test.stopTest(); | |
List<lead> l_lst_chk = new List<lead>([select id,leadsource from lead where leadsource != 'Dreamforce']); | |
System.assertequals(0,l_lst_chk.size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In daily lead processor is not complete 100% coverage of code please send me the 100% code coverage