Esempio Schedulable in apex

Come schedulare una classe Apex:

Per schedulare una classe Apex usando la UI, bisogna prima creare una classe che implementa Schedulable Method

global class WarehouseSyncSchedule  implements Schedulable {
  // implement scheduled code here
  global void execute(SchedulableContext sc){
  	  	WarehouseCalloutService.runWarehouseEquipmentSync();
  }
}

In questo caso viene schedulata una callout

@isTest 
private class WarehouseSyncScheduleTest {
    
    public static String CRON_EXP = '0 0 1 * * ? 2019';
    
    @isTest
    static void testScheduledJob() {
        Integer sCount = 0;
        CronTrigger cTId;
        
        Test.startTest();
        	Test.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock());
        	String jobID = System.schedule('Test Scheduler', CRON_EXP, new WarehouseSyncSchedule());        	
        Test.stopTest();
        
    }
}