@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();
|
|
}
|
|
|
|
}
|