 Let's understand implementation of Scheduled Apex class. So in previous lesson, you understood how Scheduled Apex is scheduled through code and UI. So let's see a real example now. So I'm just creating a Scheduled Apex class. So I'm naming it as daily opportunity processor and using interface as schedule label. So I just implemented this schedule label interface. Now I'm going to define execute method. So public void execute schedule label context CTX. Then now I'm going to query some data. So list of opportunity. OPP list equals to select ID lead source from opportunity. Here lead source equals to null and I'm setting limit as 200. So after querying this data, I'm going to implement a loop. So this loop will be on opportunity list. So one by one, the records which are available under OPP list will be available in this OPP instance. And here I'm writing OPP.leadsource equals to VAP. So wherever lead source is null, those records will be queried automatically and their lead source will be set as VAP. And after that, I'm going to write update OPP list. And like I can write null check as well. So if not OPP list dot is empty and inside this, I can write this statement. So this way, this Scheduled Apex class is implemented. So now we can schedule this Apex class. So we have two options like we can go with code and we can go with UI as well. So let me just search for this Apex classes. So here we have Apex classes option and I can click on this schedule Apex button. And let's say I'm naming the job as run opportunity processor daily. And here I need to search for the Scheduled Apex class. So those classes where Schedule Apex interface is implemented, those class will reflect here automatically. So the class name is daily opportunity processor. So I'm selecting that. Then I am selecting weekly, Monday, and start date is today's date, 23, 1, 22 and end date will be 23, 2, FAP. So one month duration and before the time, let's say 12 a.m. So this data I provided and I clicked on Save. So as soon as I click on Save and I go to Apex job, so here you can see one Scheduled action is available here in this row and this is the information. So submitted date and here you can see the Apex class through which it will be executed and this is the job ID. So this way you can see like whenever you schedule any Apex Scheduled Apex. So this way the entry will be available in your Apex job list. But now after this I'm jumping to Developer Console again and now I'm going to implement its test class. So daily OPP processor test. So I will be implementing its test class so that we can see whether code is covered or not. Because whenever you will be deploying this Scheduled Apex to production, you need test class as well because their limit is 75% code coverage. So I am creating at the rate is test annotation and then I'm writing a method, public, static, void. Method name is test Scheduled Apex. So I created a variable OPP list of type, list of opportunity. And now I'm going to create some opportunity records. So I'm going to create 500 opportunity records. So if I is less than 250, so different set of opportunity records will be created. So OPP list.add the new opportunity, name equals to test plus I, stays name equals to prospecting, close date equals to system.today. So this way this part is implemented. Now inside else, I need to implement it false case. So I copy pasted this and here I'm going to provide lead source as well. So I'm providing lead source as web. So basically, so with the help of this loop to sorry, 500 records will be created, 250 will be having lead source as web and 250 won't be having any lead source, they will be blank. So as a daily opportunity processor queries those records where lead source are null. So that's why I created records in such a way. Now I'm writing insert OPP list. So all the opportunity records that we created will be inserted, then test.starttest and string job ID equals to, now here I'm writing system.schedule and here process opportunities. Now here I need to pass acronym for date and time where we want to execute this and then the instance of that scheduled apex class. So here I'm creating that string as 0, 0, 0, 15, P, question mark, 20, 22. And I'm passing that as a parameter here and new daily OPP processor. So this will be the instance of that scheduled apex class. Now after implementing this, I can call test.stoptest. It is saying variable doesn't exist, okay. So I just, I'm just creating it here. So now this error will be removed and for assertion, I'm going to create one more list, updated opportunity list. So here I will be querying the data. So select ID, lead source, form, opportunity, where. So now I need to apply the condition. So here in the condition, I'm writing lead source equals to web. Now here earlier I mentioned lead source as web. So here I'm putting other. So just jump into object manager and I'm going to open a opportunity object. Under fields and relationships, I'm going to search for lead source and in lead source, like we have these pick list values. So I'm choosing others here because what will happen like on these 250 records, like we have not provided any lead source. So after execution, they will be having lead source as web. And if I provide lead source web here as well, so a total number of records will be more. So out of these 500, like 250 will be having lead source as other and 250 is having nothing as lead source. Now, when I execute this code, when I execute this code, so this statement will be executing that scheduled apex and after execution, we need to make sure like we have some opportunity records where lead source is available, right? So here I'm going to write system.assert equals and expected 200 and then update opportunity list.size. So these two arguments will be compared. If they are equal, then this assert will be executed properly, otherwise not. So this way this test class is implemented and now we need to execute this test class so that we can see like whether the code is completely covered or not. So now if I run this test class, so here you can see this grown expression. So earlier I mistakenly said this has a chronem, so this is not a chronem, this is grown expression. So here for test class, like you can put a question mark and then a stress, a stress, a stress. So it will be executed like every midnight. So you can use this grown expression for test class. Now, just opening this tree and clicking on tests, run test. So it is executed successfully. No error is there. And if I go here and if I check the code coverage, so it is 100%. Every statement is covered with the help of this test class. So this way, like scheduled apics, I demonstrated with the help of this schedulable interface and I also demoed you like how you can implement its test class.