高章伟
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
@isTest
private class CampaignSendMailBatchTest {
 
    @isTest static void test_method_one() {
        RecordType rectCam =
            [select Id from RecordType
             where IsActive = true and SobjectType = 'Campaign'
                              and DeveloperName = 'ServiceEngineerTraining'];
        Campaign cam = new Campaign();
        cam.Name = 'cam1';
        cam.Name2__c = 'cam11';
        cam.RecordTypeId = rectCam.Id;
        cam.CeremonyDate__c = Date.today().addDays(7);
        cam.Lesson1Date__c = Date.today().addDays(10);
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        cam.TeachingFrequency__c = '连续四天';
        cam.status = '公开中';
        cam.Mailflg_6Month_service__c = 6;
        cam.StartDate = Date.today();
        cam.EndDate = Date.today();
        cam.Mailflgafter3serviceDate__c = true;
        cam.Mailflg_Approval_service__c = true;
        cam.Mailflg_before7_service__c = true;
        cam.Mailflg_Cancel_Service__c = true;
        insert cam;
        Instruct_report__c tempIR = new Instruct_report__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true);
        insert tempIR;
        AssessmentReport__c tempAR = new AssessmentReport__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true);
        AssessmentReport__c tempAR2 = new AssessmentReport__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true,
            Type__c = '授课');
        list<AssessmentReport__c> ARlist = new list<AssessmentReport__c>();
        ARlist.add(tempAR);
        ARlist.add(tempAR2);
        insert ARlist;
 
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new CampaignSendMailBatch(), 1);
        System.Test.StopTest();
    }
 
    @isTest static void test_method_two() {
        RecordType rectCam =
            [select Id from RecordType
             where IsActive = true and SobjectType = 'Campaign'
                              and DeveloperName = 'ServiceEngineerTraining'];
        Campaign cam = new Campaign();
        cam.Name = 'cam1';
        cam.Name2__c = 'cam11';
        cam.RecordTypeId = rectCam.Id;
        cam.CeremonyDate__c = Date.today().addDays(7);
        cam.Lesson1Date__c = Date.today().addDays(10);
        cam.FinalExamDate__c = Date.today().addDays(13);
        cam.TeachingFrequency__c = '连续四天';
        cam.status = '公开中';
        cam.Mailflg_6Month_service__c = 6;
        cam.Mailflgafter3serviceDate__c = true;
        cam.Mailflg_Approval_service__c = true;
        cam.Mailflg_before7_service__c = true;
        cam.Mailflg_Cancel_Service__c = true;        
        insert cam;
        Instruct_report__c tempIR = new Instruct_report__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true);
        insert tempIR;
        AssessmentReport__c tempAR = new AssessmentReport__c(
                Campaign__c = cam.id,
                MailFlag_Approved__c = true,
                Type__c = '考核');
        AssessmentReport__c tempAR2 = new AssessmentReport__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true,
            Type__c = '授课');
        list<AssessmentReport__c> ARlist = new list<AssessmentReport__c>();
        ARlist.add(tempAR);
        ARlist.add(tempAR2);
        insert ARlist;
 
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new CampaignSendMailBatch(true), 1);
        System.Test.StopTest();
 
    }
    @isTest static void test_method_three() {
        CampaignSendMailBatch controller = new CampaignSendMailBatch();
        controller.sendMailAllFSE();
    }
 
    @isTest static void test_method_four() {
        RecordType rectCam =
            [select Id from RecordType
             where IsActive = true and SobjectType = 'Campaign'
                              and DeveloperName = 'ServiceEngineerTraining'];
 
        Campaign cam = new Campaign();
        cam.Name = 'cam1';
        cam.Name2__c = 'cam11';
        cam.RecordTypeId = rectCam.Id;
        cam.CeremonyDate__c = Date.today().addDays(-5);
        cam.Lesson1Date__c = Date.today().addDays(-4);
        cam.FinalExamDate__c = Date.today().addDays(-3);
 
 
        cam.TeachingFrequency__c = '连续四天';
        cam.status = '公开中';
        cam.Mailflg_6Month_service__c = 6;
        cam.Mailflgafter3serviceDate__c = true;
        cam.Mailflg_Approval_service__c = true;
        cam.Mailflg_before7_service__c = true;
        cam.Mailflg_Cancel_Service__c = true;        
        insert cam;
        Instruct_report__c tempIR = new Instruct_report__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true);
        insert tempIR;
        AssessmentReport__c tempAR = new AssessmentReport__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true);
        AssessmentReport__c tempAR2 = new AssessmentReport__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true,
            Type__c = '授课');
        list<AssessmentReport__c> ARlist = new list<AssessmentReport__c>();
        ARlist.add(tempAR);
        ARlist.add(tempAR2);
        insert ARlist;
 
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new CampaignSendMailBatch(true), 1);
        System.Test.StopTest();
    }
 
        @isTest static void test_method_five() {
            RecordType rectCam =
            [select Id from RecordType
             where IsActive = true and SobjectType = 'Campaign'
                              and DeveloperName = 'ServiceEngineerTraining'];
 
        Campaign cam = new Campaign();
        cam.Name = 'cam1';
        cam.Name2__c = 'cam11';
        cam.RecordTypeId = rectCam.Id;
        cam.CeremonyDate__c = Date.today().addDays(7);
        cam.Lesson1Date__c = Date.today().addDays(10);
        cam.FinalExamDate__c = Date.today().addDays(13);
        cam.TeachingFrequency__c = '连续四天';
        cam.status = '公开中';
        cam.Mailflg_6Month_service__c = 6;
        cam.Mailflgafter3serviceDate__c = true;
        cam.Mailflg_Approval_service__c = true;
        cam.Mailflg_before7_service__c = true;
        cam.Mailflg_Cancel_Service__c = true;
        insert cam;
        Instruct_report__c tempIR = new Instruct_report__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true);
        insert tempIR;
        /*AssessmentReport__c tempAR = new AssessmentReport__c(
                Campaign__c = cam.id,
                MailFlag_Approved__c = true,
                Type__c = '考核');*/
        AssessmentReport__c tempAR2 = new AssessmentReport__c(
            Campaign__c = cam.id,
            MailFlag_Approved__c = true,
            Type__c = '授课');
        list<AssessmentReport__c> ARlist = new list<AssessmentReport__c>();
        //ARlist.add(tempAR);
        ARlist.add(tempAR2);
        insert ARlist;
 
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new CampaignSendMailBatch('a'), 1);
        System.Test.StopTest();
 
    }
 
    
 
}