@isTest
|
private class CampaignTriggerBefInsHandlerTest {
|
private static final RecordType campaignRC = [SELECT Id, DeveloperName FROM RecordType WHERE DeveloperName = 'Internal_training' AND SObjectType = 'Campaign'];
|
private static final RecordType campaignMemberRC = [SELECT Id, DeveloperName FROM RecordType WHERE DeveloperName = 'Internal_training_participants' AND SObjectType = 'CampaignMember'];
|
|
@isTest static void test_method_one() {
|
StaticParameter.EscapeCampain =false;
|
StaticParameter.shareToOSCMFlag = false;
|
// Implement test code
|
Campaign cam = new Campaign();
|
cam.Name = 'test campaign';
|
cam.StartDate = Date.today().addDays(15);
|
cam.EndDate = Date.today().addDays(18);
|
cam.Name2__c = '1234';
|
cam.Status = '申请中';
|
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.HostName__c = '1';
|
cam.cooperatorCompany__c = '1';
|
cam.RecordTypeId = System.label.RecordType_CampaignService;
|
insert cam;
|
StaticParameter.EscapeCampain =false;
|
|
cam.Status = '取消';
|
update cam;
|
|
//Campaign cam1 = new Campaign();
|
//cam1.Id = cam.Id;
|
// cam.Status = '时间修改申请中';
|
// cam.is_true_or_false__c = true;
|
// cam.is_pass_or_fail__c = 1;
|
// update cam;
|
|
//Campaign cam2 = new Campaign();
|
//cam2.Id = cam.Id;
|
// cam.Status = '时间修改申请中';
|
// cam.is_true_or_false__c = true;
|
// cam.is_pass_or_fail__c = 2;
|
// update cam;
|
|
// cam = [SELECT Id, RecordType FROM Campaign WHERE Id = :cam.Id];
|
// System.assertEquals(campaignMemberRC.Id, target.CampaignMemberRecordTypeId);
|
|
}
|
|
static testMethod void testMethod2(){
|
StaticParameter.EscapeCampain =false;
|
StaticParameter.shareToOSCMFlag = false;
|
// Implement test code
|
Campaign cam = new Campaign();
|
cam.Name = 'test campaign';
|
cam.StartDate = Date.today().addDays(15);
|
cam.EndDate = Date.today().addDays(18);
|
cam.Name2__c = '1234';
|
cam.Status = '申请中';
|
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.HostName__c = '1';
|
cam.cooperatorCompany__c = '1';
|
cam.RecordTypeId = System.label.RecordType_CampaignService;
|
insert cam;
|
StaticParameter.EscapeCampain =false;
|
cam.Status = '时间修改申请中';
|
cam.is_true_or_false__c = true;
|
cam.is_pass_or_fail__c = 1;
|
update cam;
|
}
|
static testMethod void testMethod3(){
|
StaticParameter.EscapeCampain =false;
|
StaticParameter.shareToOSCMFlag = false;
|
// Implement test code
|
Campaign cam = new Campaign();
|
cam.Name = 'test campaign';
|
cam.StartDate = Date.today().addDays(15);
|
cam.EndDate = Date.today().addDays(18);
|
cam.Name2__c = '1234';
|
cam.Status = '申请中';
|
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.HostName__c = '1';
|
cam.cooperatorCompany__c = '1';
|
cam.RecordTypeId = System.label.RecordType_CampaignService;
|
insert cam;
|
StaticParameter.EscapeCampain =false;
|
cam.Status = '时间修改申请中';
|
cam.is_true_or_false__c = true;
|
cam.is_pass_or_fail__c = 2;
|
cam.IF_Submit__c = true;
|
update cam;
|
}
|
|
static testMethod void testMethod4(){
|
StaticParameter.EscapeCampain =false;
|
StaticParameter.shareToOSCMFlag = false;
|
Campaign target = new Campaign();
|
target.Name = 'test campaign';
|
target.RecordTypeId = campaignRC.Id; // 内部トレーニング
|
target.JingliApprovalManager__c = UserInfo.getUserId();
|
insert target;
|
|
StaticParameter.EscapeCampain =false;
|
|
Campaign target1 = new Campaign();
|
target1.Id = target.Id;
|
target1.Name= 'test1 campaign';
|
update target1;
|
|
// CanpaignMemberのレコードタイプを検査
|
target = [SELECT Id, CampaignMemberRecordTypeId FROM Campaign WHERE Id = :target.Id];
|
System.assertEquals(campaignMemberRC.Id, target.CampaignMemberRecordTypeId);
|
|
}
|
}
|