高章伟
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
32
33
34
35
36
37
38
39
@isTest
private class updateCampaignMailflg7BeTrueBatchTest {
    static testMethod void testMethod1() {
        RecordType rectCam =
            [select Id from RecordType
             where IsActive = true and SobjectType = 'Campaign'
                              and DeveloperName = 'BusinessTraining'];
 
        Campaign cam = new Campaign();
        cam.Name = 'cam';
        cam.Name2__c = '1234';
        cam.RecordTypeId = rectCam.Id;
        cam.Meeting_Type__c = '赞助会';
        cam.HostName__c = 'test12';
        cam.cooperatorCompany__c = 'test34';
        cam.StartDate = Date.today().addDays(7);
        cam.StartDate__c = Date.today().addDays(7);
        cam.EndDate = Date.today().addDays(18);
        cam.Status = '草案中';
        cam.Open_day__c = Date.today();
        insert cam;
 
        Campaign cam1 = [select id,BetweenTodayStartDate__c from Campaign where id = :cam.Id];
        System.debug('20000000000000000000000000'+cam1 +' ::'+cam1.BetweenTodayStartDate__c);
 
        BatchIF_Log__c log = new BatchIF_Log__c();
        log.Type__c = 'updateCampaignMailflg7BeTrue';
        log.ErrorLog__c = '更新:'+cam.Id+'失败\n';
        insert log;
 
        System.Test.startTest();
        String CRON_EXP = '0 0 0 3 9 ? 2022';
        system.schedule('updateCampaignMailflg7BeTrueSchedulable', CRON_EXP, new updateCampaignMailflg7BeTrueSchedulable());
        Database.executeBatch(new updateCampaignMailflg7BeTrueBatch());
        Database.executeBatch(new updateCampaignMailflg7BeTrueBatch(log.Id));
        System.Test.stopTest();
 
    }
}