高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
@isTest
public with sharing class AccChangeApprovalResponseControllerTest {
    
 
    static User setNewUser(String firstName, String lastName, String aName, String email) {
        User user = new User(Test_staff__c = true);
        user.LastName = ' ' + lastName;
        user.FirstName = firstName;
        user.Alias = aName;
        user.Email = email;
        user.Username = 'Olympus' + email;
        user.CommunityNickname = aName;
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '上海市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        insert user;
 
        return user;
    }
 
    static testMethod void test_method_one() {
        User user1 = setNewUser('ztest01', 'User001', 'Zhang001', 'test001@excemaple.com');
        User user2 = setNewUser('ztest02', 'User002', 'Zhang002', 'test002@excemaple.com');
        User user3 = setNewUser('ztest03', 'User003', 'Zhang003', 'test003@excemaple.com');
        User user4 = setNewUser('ztest04', 'User004', 'Zhang004', 'test004@excemaple.com');
        User user5 = setNewUser('ztest05', 'User005', 'Zhang005', 'test005@excemaple.com');
        User toUser = setNewUser('shenqing', 'shenpi', 'spsqTest', 'shenpi@excemaple.com');
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.OwnerId = toUser.Id;
 
        //WLIG-BS2CJW --执行测试类报异常MIXED_DML_OPERATION ---20200807---update By rentongxiao ---Start
        // insert hospital;
        if (Test.isRunningTest()) {
                System.runAs(new User(Id = UserInfo.getUserId())){
                        insert hospital;
                }
        }
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---End
        
        //新建 客户变更申请
        Account_Delay_Apply__c ada = new Account_Delay_Apply__c();
        ada.Hospital__c = hospital.Id;
        ada.ChangeReason__c = '地址错误';
        ada.Is_Active__c = '申请中';
        ada.Is_upload_file__c = true;
        ada.OpenWindow__c = user5.Id;
        ada.InstitutionalType__c = '非医疗机构';
        ada.CreatedById = toUser.Id;
        
        if (Test.isRunningTest()) {
            System.runAs(new User(Id = UserInfo.getUserId())){
                insert ada;
            }
        }
 
        // 画面迁移--沟通应答画面
        PageReference page = new PageReference('/apex/AccChangeApprovalResponseControllerPopUp?accid=' + ada.Id + '&type=response2system');
        System.Test.setCurrentPage(page);
        AccChangeApprovalResponseController controller = new AccChangeApprovalResponseController();
        controller.init();
 
        controller.cc.ResponseNew__c = 'test goutong';
        // 保存
        controller.saveBtn();
    }
 
    static testMethod void test_method_two() {
        User user1 = setNewUser('ztest01', 'User001', 'Zhang001', 'test001@excemaple.com');
        User user2 = setNewUser('ztest02', 'User002', 'Zhang002', 'test002@excemaple.com');
        User user3 = setNewUser('ztest03', 'User003', 'Zhang003', 'test003@excemaple.com');
        User user4 = setNewUser('ztest04', 'User004', 'Zhang004', 'test004@excemaple.com');
        User user5 = setNewUser('ztest05', 'User005', 'Zhang005', 'test005@excemaple.com');
        User toUser = setNewUser('shenqing', 'shenpi', 'spsqTest', 'shenpi@excemaple.com');
 
        // 病院を作る
        // Account hospital = new Account();
        // hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        // hospital.Name = 'test hospital';
        // hospital.Is_Active__c = '申请中';
        // hospital.OwnerId = toUser.Id;
 
        // //WLIG-BS2CJW --执行测试类报异常MIXED_DML_OPERATION ---20200807---update By rentongxiao ---Start
        // // insert hospital;
        // if (Test.isRunningTest()) {
        //         System.runAs(new User(Id = UserInfo.getUserId())){
        //                 insert hospital;
        //         }
        // }
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---End
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.OwnerId = toUser.Id;
 
        //WLIG-BS2CJW --执行测试类报异常MIXED_DML_OPERATION ---20200807---update By rentongxiao ---Start
        // insert hospital;
        if (Test.isRunningTest()) {
                System.runAs(new User(Id = UserInfo.getUserId())){
                        insert hospital;
                }
        }
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---End
        
        //新建 客户变更申请
        Account_Delay_Apply__c ada = new Account_Delay_Apply__c();
        ada.Hospital__c = hospital.Id;
        ada.ChangeReason__c = '地址错误';
        ada.Is_Active__c = '申请中';
        ada.Is_upload_file__c = true;
        ada.OpenWindow__c = user5.Id;
        ada.InstitutionalType__c = '非医疗机构';
        ada.CreatedById = toUser.Id;
        
        if (Test.isRunningTest()) {
            System.runAs(new User(Id = UserInfo.getUserId())){
                insert ada;
            }
        }
 
        // 画面迁移--沟通应答画面
        PageReference page = new PageReference('/apex/AccChangeApprovalResponseControllerPopUp?accid=' + ada.Id + '&type=response2user');
        System.Test.setCurrentPage(page);
        AccChangeApprovalResponseController controller2 = new AccChangeApprovalResponseController(new ApexPages.StandardController(ada));
        controller2.init();
        controller2.saveBtn();
 
        // 发送按钮
        controller2.cc.Response__c = 'test goutong';
        controller2.cc.ResponseNew__c = 'test .......';
        controller2.cc.Response_Cc_User1__c = user1.Id;
        controller2.cc.Response_Cc_User2__c = user2.Id;
        controller2.cc.Response_Cc_User3__c = user3.Id;
        controller2.cc.Response_Cc_User4__c = user4.Id;
        controller2.cc.Response_Cc_User5__c = user5.Id;
        controller2.saveBtn();
    }
 
    static testMethod void test_method_three() {
        User toUser = setNewUser('shenqing', 'shenpi', 'spsqTest', 'shenpi@excemaple.com');
        User user5 = setNewUser('ztest05', 'User005', 'Zhang005', 'test005@excemaple.com');
 
        // 病院を作る
        // Account hospital = new Account();
        // hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        // hospital.Name = 'test hospital';
        // hospital.Is_Active__c = '申请中';
        // hospital.OwnerId = toUser.Id;
 
        // //WLIG-BS2CJW --执行测试类报异常MIXED_DML_OPERATION ---20200807---update By rentongxiao ---Start
        // // insert hospital;
        // if (Test.isRunningTest()) {
        //         System.runAs(new User(Id = UserInfo.getUserId())){
        //                 insert hospital;
        //         }
        // }
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---Start
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.OwnerId = toUser.Id;
 
        //WLIG-BS2CJW --执行测试类报异常MIXED_DML_OPERATION ---20200807---update By rentongxiao ---Start
        // insert hospital;
        if (Test.isRunningTest()) {
                System.runAs(new User(Id = UserInfo.getUserId())){
                        insert hospital;
                }
        }
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---End
        
        //新建 客户变更申请
        Account_Delay_Apply__c ada = new Account_Delay_Apply__c();
        ada.Hospital__c = hospital.Id;
        ada.ChangeReason__c = '地址错误';
        ada.Is_Active__c = '申请中';
        ada.Is_upload_file__c = true;
        ada.OpenWindow__c = user5.Id;
        ada.InstitutionalType__c = '非医疗机构';
        ada.CreatedById = toUser.Id;
        
        if (Test.isRunningTest()) {
            System.runAs(new User(Id = UserInfo.getUserId())){
                insert ada;
            }
        }
 
        // 画面迁移--沟通应答画面
        PageReference page = new PageReference('/apex/AccChangeApprovalResponseControllerPopUp?accid=' + ada.Id + '&type=response2user');
        System.Test.setCurrentPage(page);
        AccChangeApprovalResponseController controller3 = new AccChangeApprovalResponseController();
        controller3.init();
 
        controller3.cc.Response__c = 'test goutong';
        controller3.ra.CreatedBy.Email = '111111111111';
        // 发送按钮
        controller3.saveBtn();
    }
}