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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
@isTest
public with sharing class EquipmentRentalResponseControllerTest {
    
        final static Integer okStatus = 99;
 
        //public Rental_Apply__c rentalApplyselect { get; set; }
 
        static testMethod void myUnitTest() {
        
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        insert hospital;
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
 
        //用户
        User wanghaijuan = new User();
        //wanghaijuan.Name = '王海娟';
        //wanghaijuan.Employee_No__c = '12345';
        //insert wanghaijuan;
 
        // システム管理者=jingliwanghaijuan
        User wanghaijuan_user = new User(Test_staff__c = true);
        wanghaijuan_user.LastName = '_haijuan';
        wanghaijuan_user.FirstName = 'wang';
        wanghaijuan_user.Alias = 'う';
        wanghaijuan_user.Email = 'olympusTest03@sunbridge.com';
        wanghaijuan_user.Username = 'wanghaijuan@sunbridge.com';
        wanghaijuan_user.CommunityNickname = 'wanghaijuan';
        wanghaijuan_user.IsActive = true;
        wanghaijuan_user.EmailEncodingKey = 'ISO-2022-JP';
        wanghaijuan_user.TimeZoneSidKey = 'Asia/Tokyo';
        wanghaijuan_user.LocaleSidKey = 'ja_JP';
        wanghaijuan_user.LanguageLocaleKey = 'ja';
        wanghaijuan_user.ProfileId = System.Label.ProfileId_SystemAdmin;
        wanghaijuan_user.Job_Category__c = '销售推广';
        wanghaijuan_user.Province__c = '上海市';
        wanghaijuan_user.Use_Start_Date__c = Date.today().addMonths(-6);
        insert wanghaijuan_user;
 
        User sl_test_user = new User(Test_staff__c = true);
        sl_test_user.LastName = '_sl';
        sl_test_user.FirstName = 'test';
        sl_test_user.Alias = 'う';
        sl_test_user.Email = 'olympusTest03@sunbridge.com';
        sl_test_user.Username = 'sl_test_user@sunbridge.com';
        sl_test_user.CommunityNickname = 'sl_test_user';
        sl_test_user.IsActive = true;
        sl_test_user.EmailEncodingKey = 'ISO-2022-JP';
        sl_test_user.TimeZoneSidKey = 'Asia/Tokyo';
        sl_test_user.LocaleSidKey = 'ja_JP';
        sl_test_user.LanguageLocaleKey = 'ja';
        sl_test_user.ProfileId = System.Label.ProfileId_SystemAdmin;
        sl_test_user.Job_Category__c = '销售推广';
        sl_test_user.Province__c = '上海市';
        sl_test_user.Use_Start_Date__c = Date.today().addMonths(-6);
        sl_test_user.JingliApprovalManager__c = wanghaijuan_user.UserId__c;
        insert sl_test_user;
 
        
        Shipment_address__c SAC = new Shipment_address__c();
        SAC.Name = 'Test办事处地址';
        SAC.Address__c = '北京市朝阳区酒仙桥';
        SAC.Post_Code__c = '137001';
        insert SAC;
 
        //借出申请bean
        Rental_Apply__c rentalApply =  new Rental_Apply__c();
        rentalApply.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Chu_Ku_Zhi_Shi.ordinal());
        //rentalApply.Shippment_adreess__c = '直送';
        //rentalApply.direct_shippment_address__c = 'test直送';
        rentalApply.delivery_company__c = '嘉里大通';
        rentalApply.Distributor_method__c = '陆运';
        rentalApply.Tracking_Number__c = '23333333';
        rentalApply.Return_to_wh_staff__c = 
        rentalApply.applyUser__c = UserInfo.getUserId();
        //rentalApply.applyUser__c = sl_test_user.ID;
        rentalApply.direct_send__c = '办事处';
        rentalApply.Shipment_address__c = SAC.id;
        rentalApply.direct_shippment_address__c = 'test';
        rentalApply.Request_return_day__c = Date.today() + 30;
        rentalApply.demo_purpose1__c = '其他';
        rentalApply.demo_purpose2__c = '其他';
        //rentalApply.Loaner_centre_mail_address__c = 'hiroki_hotta@olympus.com.cn';
        rentalApply.JingliApprovalManager__c = wanghaijuan.Employee_No__c ;
        rentalApply.SalesManager__c = wanghaijuan.Employee_No__c;
        rentalApply.Response__c = 'test goutongyingda';
        rentalApply.Hope_Lonaer_date_Num__c = 10;
        insert rentalApply;
 
        EquipmentRentalResponseController.test();// 20211130 ljh
        //画面迁移--沟通应答画面
        PageReference page = new PageReference('/apex/EquipmentRentalResponsePopUp?raid=' + rentalApply.Id + '&type=response2center');
        System.Test.setCurrentPage(page);
        
        EquipmentRentalResponseController controller = new EquipmentRentalResponseController();
        
 
        //取得借出申请
        Rental_Apply__c rentalApplyselect = [select Id, Name, Account__r.Name, Account__r.Owner.Name, Campaign__r.Name, Loaner_medical_Staff__r.Name, Repair__r.Name, Prepare_Day__c, Demo_purpose1__c, Phone_number__c, 
                                  OPD__r.Name, Follow_UP_Opp__r.Name, Calendar_start_date__c, Request_demo_detail__c, Owner.Name , Status__c, RA_Status__c, 
                                  Loaner_centre_mail_address__c
                                  ,Response__c
                             from Rental_Apply__c where Id = :rentalApply.Id];
 
        //初始化
        controller.init();
        
        System.assertEquals(rentalApplyselect.Loaner_centre_mail_address__c, controller.ra.Loaner_centre_mail_address__c);
        //System.assertEquals(wanghaijuan_user.ID, controller.cc.JingliApprovalManager__c);
        System.assertEquals(wanghaijuan_user.NAME, controller.cc.JingliApprovalManager__r.name);
        //System.assertEquals('name01', controller.equipmentSetDetailRecords[0].esd.Asset__r.Product2.Name);
 
        //发送按钮
        controller.cc.Response__c = 'test goutong';
        controller.cc.ResponseNew__c = 'test';
 
        //保存后
        controller.saveBtn();
 
       
    }
 
    static testMethod void TestToPersen() {
        
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        insert hospital;
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
 
        //用户
        User wanghaijuan = new User();
        //wanghaijuan.Name = '王海娟';
        //wanghaijuan.Employee_No__c = '12345';
        //insert wanghaijuan;
 
        // システム管理者=jingliwanghaijuan
        User wanghaijuan_user = new User(Test_staff__c = true);
        wanghaijuan_user.LastName = '_haijuan';
        wanghaijuan_user.FirstName = 'wang';
        wanghaijuan_user.Alias = 'う';
        wanghaijuan_user.Email = 'olympusTest03@sunbridge.com';
        wanghaijuan_user.Username = 'wanghaijuan@sunbridge.com';
        wanghaijuan_user.CommunityNickname = 'wanghaijuan';
        wanghaijuan_user.IsActive = true;
        wanghaijuan_user.EmailEncodingKey = 'ISO-2022-JP';
        wanghaijuan_user.TimeZoneSidKey = 'Asia/Tokyo';
        wanghaijuan_user.LocaleSidKey = 'ja_JP';
        wanghaijuan_user.LanguageLocaleKey = 'ja';
        wanghaijuan_user.ProfileId = System.Label.ProfileId_SystemAdmin;
        wanghaijuan_user.Job_Category__c = '销售推广';
        wanghaijuan_user.Province__c = '上海市';
        wanghaijuan_user.Use_Start_Date__c = Date.today().addMonths(-6);
        insert wanghaijuan_user;
 
        User sl_test_user = new User(Test_staff__c = true);
        sl_test_user.LastName = '_sl';
        sl_test_user.FirstName = 'test';
        //sl_test_user. = 'test';
        sl_test_user.Alias = 'う';
        sl_test_user.Email = 'olympusTest03@sunbridge.com';
        sl_test_user.Username = 'sl_test_user@sunbridge.com';
        sl_test_user.CommunityNickname = 'sl_test_user';
        sl_test_user.IsActive = true;
        sl_test_user.EmailEncodingKey = 'ISO-2022-JP';
        sl_test_user.TimeZoneSidKey = 'Asia/Tokyo';
        sl_test_user.LocaleSidKey = 'ja_JP';
        sl_test_user.LanguageLocaleKey = 'ja';
        sl_test_user.ProfileId = System.Label.ProfileId_SystemAdmin;
        sl_test_user.Job_Category__c = '销售推广';
        sl_test_user.Province__c = '上海市';
        sl_test_user.Dept__c = '医疗华北营业本部';
        sl_test_user.Use_Start_Date__c = Date.today().addMonths(-6);
        sl_test_user.JingliApprovalManager__c = wanghaijuan_user.UserId__c;
        insert sl_test_user;
 
        
        Shipment_address__c SAC = new Shipment_address__c();
        SAC.Name = 'Test办事处地址';
        SAC.Address__c = '北京市朝阳区酒仙桥';
        SAC.Post_Code__c = '137001';
        insert SAC;
 
        //借出申请bean
        Rental_Apply__c rentalApply =  new Rental_Apply__c();
        rentalApply.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Chu_Ku_Zhi_Shi.ordinal());
        //rentalApply.Shippment_adreess__c = '直送';
        //rentalApply.direct_shippment_address__c = 'test直送';
        rentalApply.delivery_company__c = '嘉里大通';
        rentalApply.Distributor_method__c = '陆运';
        rentalApply.Tracking_Number__c = '23333333';
        rentalApply.Return_to_wh_staff__c = 
        //rentalApply.applyUser__c = UserInfo.getUserId();
        rentalApply.applyUser__c = sl_test_user.ID;
        rentalApply.Person_In_Charge__c = sl_test_user.ID;
        rentalApply.direct_send__c = '办事处';
        rentalApply.Shipment_address__c = SAC.id;
        rentalApply.direct_shippment_address__c = 'test';
        rentalApply.Request_return_day__c = Date.today() + 30;
        rentalApply.demo_purpose1__c = '其他';
        rentalApply.demo_purpose2__c = '其他';
        //rentalApply.Loaner_centre_mail_address__c = 'hiroki_hotta@olympus.com.cn';
        rentalApply.JingliApprovalManager__c = wanghaijuan.Employee_No__c ;
        rentalApply.SalesManager__c = wanghaijuan.Employee_No__c;
        rentalApply.Response__c = 'test goutongyingda';
        rentalApply.Hope_Lonaer_date_Num__c = 10;
        insert rentalApply;
 
        
        //画面迁移--沟通应答画面
        PageReference page = new PageReference('/apex/EquipmentRentalResponsePopUp?raid=' + rentalApply.Id + '&type=response2user');
        System.Test.setCurrentPage(page);
        
        EquipmentRentalResponseController controller = new EquipmentRentalResponseController();
        
 
        //取得借出申请
        Rental_Apply__c rentalApplyselect = [select Id, Name, Account__r.Name, Account__r.Owner.Name, Campaign__r.Name, Loaner_medical_Staff__r.Name, Repair__r.Name, Prepare_Day__c, Demo_purpose1__c, Phone_number__c, 
                                  OPD__r.Name, Follow_UP_Opp__r.Name, Calendar_start_date__c, Request_demo_detail__c, Owner.Name , Status__c, RA_Status__c, 
                                  Loaner_centre_mail_address__c
                                  ,Response__c
                             from Rental_Apply__c where Id = :rentalApply.Id];
 
        //初始化
        controller.init();
        System.assertEquals(rentalApplyselect.Loaner_centre_mail_address__c, controller.ra.Loaner_centre_mail_address__c);
        //System.assertEquals(wanghaijuan_user.ID, controller.cc.JingliApprovalManager__c);
        //System.assertEquals(wanghaijuan_user.NAME, controller.cc.JingliApprovalManager__r.name);
        //System.assertEquals('name01', controller.equipmentSetDetailRecords[0].esd.Asset__r.Product2.Name);
 
        //发送按钮
        controller.cc.Response__c = 'test goutong';
        //System.assertEquals('name01', controller.ra.Person_In_Charge__c);
        controller.cc.JingliApprovalManager__c = sl_test_user.ID;
        controller.cc.SalesManager__c = sl_test_user.ID;
        controller.cc.BuchangApprovalManager__c = sl_test_user.ID;
        controller.cc.BuchangApprovalManagerSales__c = sl_test_user.ID;
        controller.cc.ZongjianApprovalManager__c = sl_test_user.ID;
        controller.cc.ResponseNew__c = 'test';
 
 
        //保存后
        controller.saveBtn();
 
       
    }
 
     static testMethod void TestToStrcut() {
        
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        insert hospital;
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
 
        // システム管理者=jingliwanghaijuan
        User wanghaijuan_user = new User(Test_staff__c = true);
        wanghaijuan_user.LastName = '_haijuan';
        wanghaijuan_user.FirstName = 'wang';
        wanghaijuan_user.Alias = 'う';
        wanghaijuan_user.Email = 'olympusTest03@sunbridge.com';
        wanghaijuan_user.Username = 'wanghaijuan@sunbridge.com';
        wanghaijuan_user.CommunityNickname = 'wanghaijuan';
        wanghaijuan_user.IsActive = true;
        wanghaijuan_user.EmailEncodingKey = 'ISO-2022-JP';
        wanghaijuan_user.TimeZoneSidKey = 'Asia/Tokyo';
        wanghaijuan_user.LocaleSidKey = 'ja_JP';
        wanghaijuan_user.LanguageLocaleKey = 'ja';
        wanghaijuan_user.ProfileId = System.Label.ProfileId_SystemAdmin;
        wanghaijuan_user.Job_Category__c = '销售推广';
        wanghaijuan_user.Province__c = '上海市';
        wanghaijuan_user.Use_Start_Date__c = Date.today().addMonths(-6);
        insert wanghaijuan_user;
 
        User sl_test_user = new User(Test_staff__c = true);
        sl_test_user.LastName = '_sl';
        sl_test_user.FirstName = 'test';
        //sl_test_user. = 'test';
        sl_test_user.Alias = 'う';
        sl_test_user.Email = 'olympusTest03@sunbridge.com';
        sl_test_user.Username = 'sl_test_user@sunbridge.com';
        sl_test_user.CommunityNickname = 'sl_test_user';
        sl_test_user.IsActive = true;
        sl_test_user.EmailEncodingKey = 'ISO-2022-JP';
        sl_test_user.TimeZoneSidKey = 'Asia/Tokyo';
        sl_test_user.LocaleSidKey = 'ja_JP';
        sl_test_user.LanguageLocaleKey = 'ja';
        sl_test_user.ProfileId = System.Label.ProfileId_SystemAdmin;
        sl_test_user.Job_Category__c = '销售推广';
        sl_test_user.Province__c = '上海市';
        sl_test_user.Dept__c = '医疗华北营业本部';
        sl_test_user.Use_Start_Date__c = Date.today().addMonths(-6);
        sl_test_user.JingliApprovalManager__c = wanghaijuan_user.UserId__c;
        insert sl_test_user;
 
        
        Shipment_address__c SAC = new Shipment_address__c();
        SAC.Name = 'Test办事处地址';
        SAC.Address__c = '北京市朝阳区酒仙桥';
        SAC.Post_Code__c = '137001';
        insert SAC;
 
        //借出申请bean
        Rental_Apply__c rentalApply =  new Rental_Apply__c();
        rentalApply.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Chu_Ku_Zhi_Shi.ordinal());
        //rentalApply.Shippment_adreess__c = '直送';
        //rentalApply.direct_shippment_address__c = 'test直送';
        rentalApply.delivery_company__c = '嘉里大通';
        rentalApply.Distributor_method__c = '陆运';
        rentalApply.Tracking_Number__c = '23333333';
        rentalApply.Return_to_wh_staff__c = 
        //rentalApply.applyUser__c = UserInfo.getUserId();
        rentalApply.applyUser__c = sl_test_user.ID;
        rentalApply.Person_In_Charge__c = sl_test_user.ID;
        rentalApply.direct_send__c = '办事处';
        rentalApply.Shipment_address__c = SAC.id;
        rentalApply.direct_shippment_address__c = 'test';
        rentalApply.Request_return_day__c = Date.today() + 30;
        rentalApply.demo_purpose1__c = '其他';
        rentalApply.demo_purpose2__c = '其他';
        //rentalApply.Loaner_centre_mail_address__c = 'hiroki_hotta@olympus.com.cn';
        rentalApply.JingliApprovalManager__c = wanghaijuan_user.ID ;
        rentalApply.SalesManager__c = wanghaijuan_user.ID;
        rentalApply.Response__c = 'test goutongyingda';
        rentalApply.Hope_Lonaer_date_Num__c = 10;
        insert rentalApply;
 
        
        //画面迁移--沟通应答画面
        PageReference page = new PageReference('/apex/EquipmentRentalResponsePopUp?raid=' + rentalApply.Id + '&type=response2user');
        System.Test.setCurrentPage(page);
        
        EquipmentRentalResponseController controller = new EquipmentRentalResponseController(new ApexPages.StandardController(rentalApply));
 
    }
 
}