liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
@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;
    }
}