高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@isTest
public class SSPowerBIScheduleTest {
        static testMethod void Test01() {
                // This test runs a scheduled job at midnight Sept. 3rd. 2022
                String CRON_EXP = '0 0 0 3 9 ? 2022';
                SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'Rental_Apply__c', SS_TableName__c = 'Rental_Apply_Power_BI__c');
                oppMapping.From_Column_001__c = 'Name';
                oppMapping.SS_Column_001__c = 'Name';
                insert oppMapping;
                SS_Batch_Column_Mapping__c a02Mapping = new SS_Batch_Column_Mapping__c(Name = 'Rental_Apply_Equipment_Set__c', SS_TableName__c = 'Rental_Apply_Equipment_Set_Power_BI__c');
                a02Mapping.From_Column_001__c = 'Name';
                a02Mapping.SS_Column_001__c = 'Name';
                insert a02Mapping;
                SS_Batch_Column_Mapping__c a03Mapping = new SS_Batch_Column_Mapping__c(Name = 'Rental_Apply_Equipment_Set_Detail__c', SS_TableName__c = 'Rental_Apply_Equipment_Set_DetailPower_B__c');
                a03Mapping.From_Column_001__c = 'Name';
                a03Mapping.SS_Column_001__c = 'Name';
                insert a03Mapping;
                System.Test.startTest();
                // Schedule the test job
                String jobId = system.schedule('SSPowerBISchedule11', CRON_EXP, new SSPowerBISchedule());
                // Get the information from the CronTrigger API object
                CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
                // Verify the expressions are the same
                System.assertEquals(CRON_EXP, ct.CronExpression);
                // Verify the job has not run
                System.assertEquals(0, ct.TimesTriggered);
                // Verify the next time the job will run
                System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
                System.Test.stopTest();
        }
}