@isTest
|
private class CampaignCopyToOPDPlanHandlerTest {
|
static testMethod void testMethod1() {
|
|
//记录类型 : 1.学会/会议 --> Society 2.社外培训 --> Training_event 3.服务培训/学会会议 -->Service_trainig 6.营业部专用会议 -->BusinessTraining
|
List<Id> recordTypeIds = new List<Id>();
|
recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId()); //学会/会议
|
//recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Training_event').getRecordTypeId()); //社外培训
|
//recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Service_trainig').getRecordTypeId()); //服务培训/学会会议
|
//recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('BusinessTraining').getRecordTypeId()); //营业部专用会议
|
|
//备品借出省
|
Address_Level__c al = new Address_Level__c();
|
al.Name = '北京市';
|
insert al;
|
|
Campaign campaign01 = new Campaign();
|
campaign01.RecordTypeId = recordTypeIds.get(0);
|
// campaign01.StartDate = Date.newInstance(2020,10,29);
|
campaign01.StartDate = Date.today();
|
campaign01.Name = 'mzyTest02';
|
campaign01.EndDate = Date.today().addDays(1);
|
campaign01.Status = '草案中';
|
campaign01.Is_LendProduct__c = '是';
|
campaign01.Internal_in_charge_province__c = al.id; //备品出借省
|
campaign01.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期
|
campaign01.LoadNum__c = '3D主机*2; BF-290镜子*4; CV-170*1; CV-190*6;'; //计划出借备品信息
|
campaign01.HostName__c = '1';
|
campaign01.cooperatorCompany__c = '1';
|
insert campaign01;
|
|
Campaign campaign02 = new Campaign();
|
campaign02.RecordTypeId = recordTypeIds.get(0);
|
//update by rentx
|
campaign02.StartDate = Date.today();
|
//update by rentx
|
campaign02.Name = 'mzyTest03';
|
campaign02.EndDate = Date.today().addDays(1);
|
campaign02.Status = '草案中';
|
campaign02.Is_LendProduct__c = '是';
|
campaign02.Internal_in_charge_province__c = al.id; //备品出借省
|
campaign02.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期
|
campaign02.LoadNum__c = '3D主机*4; BF-290镜子*2; CV-170*1; CV-190*6;'; //计划出借备品信息
|
campaign02.HostName__c = '1';
|
campaign02.cooperatorCompany__c = '1';
|
insert campaign02;
|
|
Campaign campaign03 = new Campaign();
|
campaign03.RecordTypeId = recordTypeIds.get(0);
|
//update by rentx
|
// campaign03.StartDate = Date.newInstance(2020,10,29);
|
campaign03.StartDate = Date.today();
|
//update by rentx
|
campaign03.Name = 'mzyTest04';
|
campaign03.EndDate = Date.today().addDays(1);
|
campaign03.Status = '草案中';
|
campaign03.Is_LendProduct__c = '是';
|
campaign03.Internal_in_charge_province__c = al.id; //备品出借省
|
campaign03.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期
|
campaign03.LoadNum__c = '3D主机*5; BF-290镜子*2; CV-170*1; CV-190*6;'; //计划出借备品信息
|
campaign03.HostName__c = '1';
|
campaign03.cooperatorCompany__c = '1';
|
insert campaign03;
|
|
Campaign campaign04 = new Campaign();
|
campaign04.RecordTypeId = recordTypeIds.get(0);
|
//update by rentx
|
// campaign04.StartDate = Date.newInstance(2020,10,29);
|
campaign04.StartDate = Date.today();
|
//update by rentx
|
campaign04.Name = 'mzyTest05';
|
campaign04.EndDate = Date.today().addDays(1);
|
campaign04.Status = '草案中';
|
campaign04.Is_LendProduct__c = '否';
|
campaign04.HostName__c = 'TestHostName';
|
campaign04.cooperatorCompany__c = 'TestcooperatorCompany';
|
campaign04.HostName__c = '1';
|
campaign04.cooperatorCompany__c = '1';
|
insert campaign04;
|
|
Campaign target1 = new Campaign();
|
target1.Id = campaign01.Id;
|
target1.Name = 'mzy campaign01';
|
target1.Status = '公开中';
|
update target1;
|
|
Campaign target2 = new Campaign();
|
target2.Id = campaign02.Id;
|
target2.Name = 'mzy campaign02';
|
target2.Status = '公开中';
|
update target2;
|
|
Campaign target3 = new Campaign();
|
target3.Id = campaign03.Id;
|
target3.Name = 'mzy campaign03';
|
target3.Status = '公开中'; //2020-11-18 mzy update 学会取消则创建OPD计划取消延期对象
|
update target3;
|
|
Campaign target4 = new Campaign();
|
target4.Id = campaign04.Id;
|
target4.Name = 'mzy campaign04';
|
target4.Status = '公开中';
|
update target4;
|
|
Campaign target5 = new Campaign();
|
target5.Id = campaign04.Id;
|
target5.Name = 'mzy campaign04';
|
target5.StartDate = Date.newInstance(2020,11,24); //2020-11-18 mzy update 学会延期则创建OPD计划延期对象
|
target5.EndDate = Date.newInstance(2020,11,30); //2020-11-18 mzy update 学会延期则创建OPD计划延期对象
|
update target5;
|
|
System.Test.startTest();
|
Campaign target6 = new Campaign();
|
target6.Id = campaign03.Id;
|
target6.Name = 'mzy campaign03';
|
target6.Status = '取消'; //2020-11-18 mzy update 学会取消则创建OPD计划取消延期对象
|
update target6;
|
|
System.assertEquals('取消', target6.Status);
|
System.Test.stopTest();
|
|
|
|
}
|
|
static testMethod void testMethod2() {
|
CampaignCopyToOPDPlanHandler controller = new CampaignCopyToOPDPlanHandler();
|
OPDPlan__c oPDPlan2 = new OPDPlan__c();
|
oPDPlan2.Status__c = '计划中';
|
oPDPlan2.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
|
oPDPlan2.NoOpp_Reason__c = 'HCP对应';
|
oPDPlan2.OPDType__c = '学会';
|
insert oPDPlan2;
|
controller.QX_OPDPlanBuild(oPDPlan2.id);
|
controller.YQ_OPDPlanBuild(oPDPlan2,Date.today().addDays(7));
|
|
}
|
|
static testMethod void testMethod3(){
|
List<Id> recordTypeIds = new List<Id>();
|
recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId()); //学会/会议
|
Campaign campaign01 = new Campaign();
|
campaign01.RecordTypeId = recordTypeIds.get(0);
|
campaign01.StartDate = Date.newInstance(2020,10,29);
|
campaign01.Name = 'Test';
|
campaign01.EndDate = Date.newInstance(2020,10,30);
|
campaign01.Status = '草案中';
|
campaign01.Is_LendProduct__c = '是';
|
campaign01.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期
|
campaign01.LoadNum__c = '3D主机*2; BF-290镜子*4; CV-170*1; CV-190*6;'; //计划出借备品信息
|
campaign01.HostName__c = '1';
|
campaign01.cooperatorCompany__c = '1';
|
insert campaign01;
|
|
//创建备品借出申请
|
OPDPlan__c oPDPlan0 = new OPDPlan__c();
|
oPDPlan0.Status__c = '草案中';
|
oPDPlan0.OPDPlan_ImplementDate__c = Date.today();
|
oPDPlan0.NoOpp_Reason__c = 'HCP对应';
|
oPDPlan0.Campaign__c = campaign01.Id;
|
oPDPlan0.Status__c='草案中';
|
oPDPlan0.OPDType__c='学会';
|
insert oPDPlan0;
|
|
System.Test.startTest();
|
campaign01.Status='已提交报告';
|
update campaign01;
|
|
// System.assertEquals('取消', target6.Status);
|
System.Test.stopTest();
|
|
}
|
}
|