@isTest
|
private class InfrastructureProductTriggerHandlerTest {
|
|
static testMethod void testShare(){
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
|
//医院
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
//科室
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert hpOwner;
|
User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '北京', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert hpOwner2;
|
|
// 医院
|
Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
|
hp.GI_Main__c = hpOwner.Id;
|
hp.GI_Product_Leader__c = hpOwner2.Alias;
|
hp.BF_owner__c = hpOwner.Id;
|
hp.BF_Product_Leader__c = hpOwner2.Alias;
|
hp.ENT_owner_ID__c = hpOwner.Id;
|
hp.ENT_Product_Leader__c = hpOwner2.Alias;
|
hp.URO_owner_ID__c = hpOwner.Id;
|
hp.URO_Produc_Leader__c = hpOwner2.Alias;
|
hp.SP_Main__c = hpOwner.Id;
|
hp.GS_Product_Leader__c = hpOwner2.Alias;
|
hp.GYN_owner__c = hpOwner.Id;
|
hp.GYN_Product_Leader__c = hpOwner2.Alias;
|
hp.FSE_GI_Main_Leader__c = hpOwner.Id;
|
hp.FSE_SP_Main_Leader__c = hpOwner.Id;
|
hp.Is_Active__c = '有効';
|
insert hp;
|
|
OCM_Management_Province__c mp = new OCM_Management_Province__c();
|
mp.Name = '北京';
|
mp.GI_assistant__c = hpOwner.Id;
|
mp.SP_assistant__c = hpOwner.Id;
|
mp.Window1__c = hpOwner.Id;
|
insert mp;
|
|
Infrastructure_Project__c project = new Infrastructure_Project__c();
|
project.Name = 'Test';
|
project.Province__c = '北京市';
|
project.City__c = '北京市';
|
insert project;
|
|
project.OCSM_Hospital__c = hp.Id;
|
update project;
|
}
|
|
static testMethod void testOpportunityFollow(){
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
|
//医院
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
//科室
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert hpOwner;
|
User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '北京', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert hpOwner2;
|
|
// 医院
|
Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
|
hp.GI_Main__c = hpOwner.Id;
|
hp.GI_Product_Leader__c = hpOwner2.Alias;
|
hp.BF_owner__c = hpOwner.Id;
|
hp.BF_Product_Leader__c = hpOwner2.Alias;
|
hp.ENT_owner_ID__c = hpOwner.Id;
|
hp.ENT_Product_Leader__c = hpOwner2.Alias;
|
hp.URO_owner_ID__c = hpOwner.Id;
|
hp.URO_Produc_Leader__c = hpOwner2.Alias;
|
hp.SP_Main__c = hpOwner.Id;
|
hp.GS_Product_Leader__c = hpOwner2.Alias;
|
hp.GYN_owner__c = hpOwner.Id;
|
hp.GYN_Product_Leader__c = hpOwner2.Alias;
|
hp.FSE_GI_Main_Leader__c = hpOwner.Id;
|
hp.FSE_SP_Main_Leader__c = hpOwner.Id;
|
insert hp;
|
|
Account sct = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :hp.Id and RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_BF').getRecordTypeId() Limit 1];
|
|
Account depart = new Account();
|
depart.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
|
depart.Name = '*';
|
depart.Department_Name__c = 'aiueo診療科';
|
depart.ParentId = sct.Id;
|
depart.Department_Class__c = sct.Id;
|
depart.Hospital__c = hp.Id;
|
|
insert depart;
|
|
Infrastructure_Project__c project = new Infrastructure_Project__c();
|
project.Name = 'Test';
|
project.Province__c = '北京市';
|
project.City__c = '北京市';
|
insert project;
|
|
StaticParameter.EscapeOpportunityBefUpdTrigger = true;
|
StaticParameter.EscapeOppandStaTrigger = true;
|
Opportunity opp = new Opportunity(OwnerId = hpOwner.Id , Name = 'aiueo商談', StageName = '引合', CloseDate=Date.today().addDays(200), AccountId = hp.Id,Department_Class__c = depart.id);
|
opp.Infrastructure_Project__c = project.Id;
|
insert opp;
|
}
|
}
|