高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
@isTest //TODO resend unit test
private class NFM105WebServiceTest {
    
    static Repair__c makeTestRepair() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
        }
        // テストデータ
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM105TestCompany';
        upsert company;
        Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId = :company.Id and RecordTypeId = :rectSct[0].Id];
 
        Account depart = new Account();
        depart.RecordTypeId        = rectDpt[0].Id;
        depart.Name                = '*';
        depart.Department_Name__c  = 'NFM105TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        // 再取得
        List<Account> accList = new List<Account>();
        company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :company.Id];
        accList.add(company);
        accList.add(section);
        depart = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :depart.Id];
        accList.add(depart);
 
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'NFM105Prd1';
        prd1.ProductCode            = 'NFM105Prd1';
        prd1.Repair_Product_Code__c = 'NFM105Prd1_RP';
        prd1.Name                   = 'NFM105Prd1';
        prd1.Manual_Entry__c        = false;
        prdList.add(prd1);
        Product2 prd2 = new Product2();
        prd2.ProductCode_Ext__c     = 'NFM105Prd2';
        prd2.ProductCode            = 'NFM105Prd2';
        prd2.Repair_Product_Code__c = 'NFM105Prd2_RP';
        prd2.Name                   = 'NFM105Prd2';
        prd2.Manual_Entry__c        = false;
        prdList.add(prd2);
        insert prdList;
 
        Asset ast = new Asset();
        ast.Name                   = 'NFM105Ast1';
        ast.AccountId              = depart.Id;
        ast.Department_Class__c    = section.Id;
        ast.Hospital__c            = company.Id;
        ast.Product2Id             = prd1.Id;
        ast.SerialNumber           = 'NFM105SerialNumber';
        ast.Guarantee_period_for_products__c = Date.today();
        ast.InstallDate                      = Date.today();
        insert ast;
        ast = [select Id, Name, Product_Serial_No__c, AccountId, Department_Class__c, Department_Class__r.Management_Code_Auto__c, Hospital__c, Product2Id, Product2.ProductCode, Product2.Repair_Product_Code__c, SerialNumber
                                 from Asset
                                where Id = :ast.Id];
 
        Repair__c rpr = new Repair__c();
        rpr.SAPRepairNo__c   = 'NFM105Rpr1';
        rpr.Account__c             = depart.Id;
        rpr.Department_Class__c    = section.Id;
        rpr.Hospital__c            = company.Id;
        rpr.Delivered_Product__c   = ast.Id;
        rpr.Status__c              = '1.受理完毕';
        rpr.Incharge_Staff__c = Userinfo.getUserId();
        rpr.Repair_Detail__c = 'test';
        insert rpr;
        rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c where Id =: rpr.Id];
        return rpr;
    }
 
    // そのままreturn
    @isTest
    static void testNFM105_void() {
        // null
        NFM105WebService.NFM105(null);
 
        NFM105WebService.RepairStatusUpdate RepairStatusUpdate                   = new NFM105WebService.RepairStatusUpdate();
        NFM105WebService.GeneralData GeneralData                                 = new NFM105WebService.GeneralData();
        NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation();
        NFM105WebService.FailureInformation FailureInformation                   = new NFM105WebService.FailureInformation();
 
        GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation };
        GeneralData.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation };
        RepairStatusUpdate.GeneralData          = new NFM105WebService.GeneralData[] { GeneralData };
 
        // Monitoringをセットしない
        NFM105WebService.NFM105(RepairStatusUpdate);
 
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring();
        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '01';
        // 必須項目をセットしない
        NFM105WebService.NFM105(RepairStatusUpdate);
 
        // 商品コードが存在しない
        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '02';
        GeneralData.SAPRepairNo = 'NFM105X';
        NFM105WebService.NFM105(RepairStatusUpdate);
 
        // 修理受付番号 を受信したけど、SFDC側レコードがない
        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '03';
        GeneralData.SAPRepairNo = 'NFM105X';
        GeneralData.SFDCRepairNo = 'AAAA';
        NFM105WebService.NFM105(RepairStatusUpdate);
    }
 
    //StatusCode = 'B95'; 1件
//    @isTest
//    static void testNFM105_update_B95_1() {
//        Repair__c rpr = makeTestRepair();
 
//        Repair_Quotation__c rq1 = new Repair_Quotation__c();
//        rq1.Name            = 'NFM105U1';
//        rq1.Repair__c       = rpr.Id;
//        Repair_Quotation__c rq2 = new Repair_Quotation__c();
//        rq2.Quotation_agreement__c = true;
//        rq2.Name            = 'NFM105U2';
//        rq2.Repair__c       = rpr.Id;
//        insert new Repair_Quotation__c[]{rq1, rq2};
        
//        NFM105WebService.RepairStatusUpdate RepairStatusUpdate                   = new NFM105WebService.RepairStatusUpdate();
//        NFM105WebService.GeneralData GeneralData                                 = new NFM105WebService.GeneralData();
//        NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation();
//        NFM105WebService.FailureInformation FailureInformation                   = new NFM105WebService.FailureInformation();
 
//        GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation };
//        GeneralData.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation };
//        RepairStatusUpdate.GeneralData          = new NFM105WebService.GeneralData[] { GeneralData };
 
//        // Monitoringの設定
//        Datetime nowDT = Datetime.now();
//        String nowStr = nowDT.format('yyyyMMddHHmm');
//        RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring();
 
//        // SAPQuotationNo NotExist
//        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u1';
//        GeneralData.SFDCRepairNo                         = rpr.Name;
//        GeneralData.SAPRepairNo                          = rpr.SAPRepairNo__c;
//        GeneralData.RepairOrderStatusCode                = 'B95';
//        GeneralData.RepairOrderStatusName                = '报价同意确认';
//        GeneralData.StatusUpdateDate                     = '20150101';
//        GeneralData.StatusUpdateTime                     = '101010';
//        GeneralData.StatusUpdatePersonName               = 'John';
//        GeneralData.CancellationReason                   = 'R2    到其他公司修理 ';
//        GeneralData.IncorrectDataComment                 = 'xxxxx';
//        GeneralData.SAPQuotationNo                       = 'NFM105UXX';
//        NFM105WebService.NFM105(RepairStatusUpdate);
 
//        // NFM105U1 => B95
//        GeneralData.SAPQuotationNo                       = 'NFM105U1';
//        InspectionResultInformation.InspectionResultFlag = 'X';
//        InspectionResultInformation.InspectionComment    = 'CCD线长度: 248MM  把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。';
//        InspectionResultInformation.FailureCause         = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10';
//        FailureInformation.LocationGroupName             = '内镜连接座部';
//        FailureInformation.LocationName                  = 'LG导光杆部';
//        FailureInformation.PhenomenonName                = 'IG导光束异常(红裂缝、折损、彩虹斑)';
//        FailureInformation.CauseName                     = '劣化, 老化';
//        FailureInformation.DescriptionName               = '由于送气・送水圆筒的刮痕导致气囊送水量不能达到规格值。';
 
//        System.Test.startTest();
//        NFM105WebService.NFM105(RepairStatusUpdate);
//        System.Test.stopTest();
        
//        List<Repair__c> sapRpairList = [select Id, Name, SAPRepairNo__c, Agreed_Date__c
//                                                , RepairOrderStatusName__c, RepairOrderStatusCode__c
//                                                , CancellationReason__c, IncorrectDataComment__c
//                                                , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c
//                                                , Repair_Quotation_Id__c
//                                           from Repair__c
//                                          where SAPRepairNo__c = :GeneralData.SAPRepairNo];
//        List<Repair_Quotation__c> quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c
//                                                  , InspectionComment__c, InspectionResultFlag__c
//                                                  , InspectionFailureCause__c
//                                                  , LatestQuotationDate__c
//                                                  , FirstQuotationDate__c, DiscountAmount__c
//                                                  , TotalPrice__c, DiscountType__c
//                                                  , CafeteriaFlag__c, MessageGroupNumber__c
//                                             from Repair_Quotation__c
//                                            where Name = :GeneralData.SAPQuotationNo];
//        System.assertEquals(1, sapRpairList.size());
//        System.assertEquals(1, quotationList.size());
//        if (sapRpairList.size() == 1) {
//            System.assertEquals(nowStr + 'u1', sapRpairList[0].NFM105_MessageGroupNumber__c);
//            System.assertEquals(quotationList[0].Id, sapRpairList[0].Repair_Quotation_Id__c);
//            System.assertEquals(Date.valueOf('2015-01-01'), sapRpairList[0].Agreed_Date__c);
//            System.assertEquals(GeneralData.SAPRepairNo, sapRpairList[0].SAPRepairNo__c);
//            System.assertEquals(GeneralData.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c);
//            System.assertEquals(GeneralData.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c);
//            System.assertEquals(null, sapRpairList[0].CancellationReason__c);
//            System.assertEquals(null, sapRpairList[0].IncorrectDataComment__c);
//        }
//        if (quotationList.size() == 1) {
//            Repair_Quotation__c qr = [Select Id, Quotation_agreement__c from Repair_Quotation__c where Name <> :GeneralData.SAPQuotationNo];
//            System.assertEquals(false, qr.Quotation_agreement__c);
//            System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name);
//            System.assertEquals(true, quotationList[0].Quotation_agreement__c);
//            System.assertEquals('OK', quotationList[0].InspectionResultFlag__c);
//            System.assertEquals(InspectionResultInformation.InspectionComment, quotationList[0].InspectionComment__c);
//            System.assertEquals(InspectionResultInformation.FailureCause, quotationList[0].InspectionFailureCause__c);
//            List<Repair_quotation_reason__c> qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c];
//            System.assertEquals(1, qrsnList.size());
//            System.assertEquals(quotationList[0].Id, qrsnList[0].Repair_quotation__c);
//            System.assertEquals(FailureInformation.LocationGroupName, qrsnList[0].LocationGroupName__c);
//            System.assertEquals(FailureInformation.LocationName, qrsnList[0].LocationName__c);
//            System.assertEquals(FailureInformation.PhenomenonName, qrsnList[0].PhenomenonName__c);
//            System.assertEquals(FailureInformation.CauseName, qrsnList[0].CauseName__c);
//            System.assertEquals(FailureInformation.DescriptionName, qrsnList[0].DescriptionName__c);
//            List<Repair_reason__c> rrsnList = [select Repair__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_reason__c];
//            System.assertEquals(1, rrsnList.size());
//            System.assertEquals(rpr.Id, rrsnList[0].Repair__c);
//            System.assertEquals(quotationList[0].Id, rrsnList[0].Repair_quotation__c);
//            System.assertEquals(FailureInformation.LocationGroupName, rrsnList[0].LocationGroupName__c);
//            System.assertEquals(FailureInformation.LocationName, rrsnList[0].LocationName__c);
//            System.assertEquals(FailureInformation.PhenomenonName, rrsnList[0].PhenomenonName__c);
//            System.assertEquals(FailureInformation.CauseName, rrsnList[0].CauseName__c);
//            System.assertEquals(FailureInformation.DescriptionName, rrsnList[0].DescriptionName__c);
//        }
//    }
 
//    //StatusCode = 'B95'; 同じ修理、2件
//    @isTest
//    static void testNFM105_update_B95_2() {
//        Repair__c rpr = makeTestRepair();
 
//        Repair_Quotation__c rq1 = new Repair_Quotation__c();
//        rq1.Name            = 'NFM105U1';
//        rq1.Repair__c       = rpr.Id;
//        Repair_Quotation__c rq2 = new Repair_Quotation__c();
//        rq2.Name            = 'NFM105U2';
//        rq2.Repair__c       = rpr.Id;
//        insert new Repair_Quotation__c[]{rq1, rq2};
        
//        NFM105WebService.RepairStatusUpdate RepairStatusUpdate                   = new NFM105WebService.RepairStatusUpdate();
//        NFM105WebService.GeneralData GeneralData                                 = new NFM105WebService.GeneralData();
//        NFM105WebService.GeneralData GeneralData2                                 = new NFM105WebService.GeneralData();
//        NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation();
//        NFM105WebService.InspectionResultInformation InspectionResultInformation2 = new NFM105WebService.InspectionResultInformation();
//        NFM105WebService.FailureInformation FailureInformation                   = new NFM105WebService.FailureInformation();
//        NFM105WebService.FailureInformation FailureInformation1                  = new NFM105WebService.FailureInformation();
 
//        GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation };
//        GeneralData2.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation2 };
//        GeneralData2.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation, FailureInformation1 };
//        RepairStatusUpdate.GeneralData          = new NFM105WebService.GeneralData[] { GeneralData, GeneralData2 };
 
//        // Monitoringの設定
//        Datetime nowDT = Datetime.now();
//        String nowStr = nowDT.format('yyyyMMddHHmm');
//        RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring();
 
//        // NFM105U2 => A20
//        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u2';
//        GeneralData.SFDCRepairNo                         = rpr.Name;
//        GeneralData.SAPRepairNo                          = rpr.SAPRepairNo__c;
//        GeneralData.RepairOrderStatusCode                = 'A20';
//        GeneralData.RepairOrderStatusName                = '报价同意确认';
//        GeneralData.StatusUpdateDate                     = '20150101';
//        GeneralData.StatusUpdateTime                     = '101010';
//        GeneralData.StatusUpdatePersonName               = 'John';
//        GeneralData.CancellationReason                   = 'R2    到其他公司修理 ';
//        GeneralData.IncorrectDataComment                 = 'xxxxx';
//        GeneralData.SAPQuotationNo                       = 'NFM105U2';
//        InspectionResultInformation.InspectionResultFlag = 'X';
//        InspectionResultInformation.InspectionComment    = 'CCD线长度: 248MM  把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。';
//        InspectionResultInformation.FailureCause         = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10';
 
//        // NFM105U2 => B95
//        GeneralData2.SFDCRepairNo                         = rpr.Name;
//        GeneralData2.SAPRepairNo                          = rpr.SAPRepairNo__c;
//        GeneralData2.RepairOrderStatusCode                = 'B95';
//        GeneralData2.RepairOrderStatusName                = '报价同意确认';
//        GeneralData2.StatusUpdateDate                     = '20150202';
//        GeneralData2.StatusUpdateTime                     = '111111';
//        GeneralData2.StatusUpdatePersonName               = 'John';
//        GeneralData2.CancellationReason                   = 'R2    到其他公司修理 ';
//        GeneralData2.IncorrectDataComment                 = 'xxxxx';
//        GeneralData2.SAPQuotationNo                       = 'NFM105U2';
//        InspectionResultInformation2.InspectionResultFlag = '';
//        InspectionResultInformation2.InspectionComment    = 'CCD线长度: 248MM  把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。';
//        InspectionResultInformation2.FailureCause         = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10';
//        FailureInformation.LocationGroupName             = '内镜连接座部';
//        FailureInformation.LocationName                  = 'LG导光杆部';
//        FailureInformation.PhenomenonName                = 'IG导光束异常(红裂缝、折损、彩虹斑)';
//        FailureInformation.CauseName                     = '劣化, 老化';
//        FailureInformation.DescriptionName               = '由于送气・送水圆筒的刮痕导致气囊送水量不能达到规格值。';
//        FailureInformation1.LocationGroupName            = '1内镜连接座部';
//        FailureInformation1.LocationName                 = '1LG导光杆部';
//        FailureInformation1.PhenomenonName               = '1IG导光束异常(红裂缝、折损、彩虹斑)';
//        FailureInformation1.CauseName                    = '1劣化, 老化';
//        FailureInformation1.DescriptionName              = '1由于送气・送水圆筒的刮痕导致气囊送水量不能达到规格值。';
 
//        GeneralData2.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation, FailureInformation1 };
 
//        System.Test.startTest();
//        NFM105WebService.NFM105(RepairStatusUpdate);
//        System.Test.stopTest();
 
//        List<Repair__c> sapRpairList = [select Id, Name, SAPRepairNo__c, Agreed_Date__c
//                                                , RepairOrderStatusName__c, RepairOrderStatusCode__c
//                                                , CancellationReason__c, IncorrectDataComment__c
//                                                , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c
//                                                , Repair_Quotation_Id__c
//                                           from Repair__c
//                                          where SAPRepairNo__c = :GeneralData.SAPRepairNo];
//        List<Repair_Quotation__c> quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c
//                                                  , InspectionComment__c, InspectionResultFlag__c
//                                                  , InspectionFailureCause__c
//                                                  , LatestQuotationDate__c
//                                                  , FirstQuotationDate__c, DiscountAmount__c
//                                                  , TotalPrice__c, DiscountType__c
//                                                  , CafeteriaFlag__c, MessageGroupNumber__c
//                                             from Repair_Quotation__c
//                                            where Name = :GeneralData.SAPQuotationNo];
//        System.assertEquals(1, sapRpairList.size());
//        System.assertEquals(1, quotationList.size());
//        if (sapRpairList.size() == 1) {
//            //System.assertEquals(quotationList[0].Id, sapRpairList[0].Repair_Quotation_Id__c);
//            //System.assertEquals(Date.valueOf('2015-02-02'), sapRpairList[0].Agreed_Date__c);
////            System.assertEquals(GeneralData2.SAPRepairNo, sapRpairList[0].SAPRepairNo__c);
//            //System.assertEquals(GeneralData2.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c);
//            //System.assertEquals(GeneralData2.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c);
//            //System.assertEquals(null, sapRpairList[0].CancellationReason__c);
//            //System.assertEquals(null, sapRpairList[0].IncorrectDataComment__c);
//        }
//        if (quotationList.size() == 1) {
//            Repair_Quotation__c qr = [Select Id, Quotation_agreement__c from Repair_Quotation__c where Name <> :GeneralData.SAPQuotationNo];
//            System.assertEquals(false, qr.Quotation_agreement__c);
//            System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name);
//            System.assertEquals(true, quotationList[0].Quotation_agreement__c);
//            System.assertEquals('NG', quotationList[0].InspectionResultFlag__c);
//            System.assertEquals(InspectionResultInformation2.InspectionComment, quotationList[0].InspectionComment__c);
//            System.assertEquals(InspectionResultInformation2.FailureCause, quotationList[0].InspectionFailureCause__c);
//            List<Repair_quotation_reason__c> qrsn0List = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c <>: quotationList[0].Id];
//            System.assertEquals(0, qrsn0List.size());
//            List<Repair_quotation_reason__c> qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c =: quotationList[0].Id];
//            System.assertEquals(2, qrsnList.size());
//            System.assertEquals(FailureInformation.LocationGroupName, qrsnList[0].LocationGroupName__c);
//            System.assertEquals(FailureInformation.LocationName, qrsnList[0].LocationName__c);
//            System.assertEquals(FailureInformation.PhenomenonName, qrsnList[0].PhenomenonName__c);
//            System.assertEquals(FailureInformation.CauseName, qrsnList[0].CauseName__c);
//            System.assertEquals(FailureInformation.DescriptionName, qrsnList[0].DescriptionName__c);
//            System.assertEquals(FailureInformation1.LocationGroupName, qrsnList[1].LocationGroupName__c);
//            System.assertEquals(FailureInformation1.LocationName, qrsnList[1].LocationName__c);
//            System.assertEquals(FailureInformation1.PhenomenonName, qrsnList[1].PhenomenonName__c);
//            System.assertEquals(FailureInformation1.CauseName, qrsnList[1].CauseName__c);
//            System.assertEquals(FailureInformation1.DescriptionName, qrsnList[1].DescriptionName__c);
//            List<Repair_reason__c> rrsnList = [select Repair__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_reason__c];
//            System.assertEquals(2, rrsnList.size());
//            System.assertEquals(rpr.Id, rrsnList[0].Repair__c);
//            System.assertEquals(quotationList[0].Id, rrsnList[0].Repair_quotation__c);
//            System.assertEquals(FailureInformation.LocationGroupName, rrsnList[0].LocationGroupName__c);
//            System.assertEquals(FailureInformation.LocationName, rrsnList[0].LocationName__c);
//            System.assertEquals(FailureInformation.PhenomenonName, rrsnList[0].PhenomenonName__c);
//            System.assertEquals(FailureInformation.CauseName, rrsnList[0].CauseName__c);
//            System.assertEquals(FailureInformation.DescriptionName, rrsnList[0].DescriptionName__c);
//            System.assertEquals(rpr.Id, rrsnList[1].Repair__c);
//            System.assertEquals(quotationList[0].Id, rrsnList[1].Repair_quotation__c);
//            System.assertEquals(FailureInformation1.LocationGroupName, rrsnList[1].LocationGroupName__c);
//            System.assertEquals(FailureInformation1.LocationName, rrsnList[1].LocationName__c);
//            System.assertEquals(FailureInformation1.PhenomenonName, rrsnList[1].PhenomenonName__c);
//            System.assertEquals(FailureInformation1.CauseName, rrsnList[1].CauseName__c);
//            System.assertEquals(FailureInformation1.DescriptionName, rrsnList[1].DescriptionName__c);
 
//        }
//    }
 
//    //StatusCode = 'A95';
//    @isTest
//    static void testNFM105_update_A95() {
//        Repair__c rpr = makeTestRepair();
 
//        Repair_Quotation__c rq1 = new Repair_Quotation__c();
//        rq1.Name            = 'NFM105U1';
//        rq1.Repair__c       = rpr.Id;
//        Repair_Quotation__c rq2 = new Repair_Quotation__c();
//        rq2.Name            = 'NFM105U2';
//        rq2.Repair__c       = rpr.Id;
//        insert new Repair_Quotation__c[]{rq1, rq2};
 
//        NFM105WebService.RepairStatusUpdate RepairStatusUpdate                   = new NFM105WebService.RepairStatusUpdate();
//        NFM105WebService.GeneralData GeneralData                                 = new NFM105WebService.GeneralData();
//        NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation();
//        NFM105WebService.FailureInformation FailureInformation                   = new NFM105WebService.FailureInformation();
 
//        GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation };
//        GeneralData.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation };
//        RepairStatusUpdate.GeneralData          = new NFM105WebService.GeneralData[] { GeneralData };
 
//        // Monitoringの設定
//        Datetime nowDT = Datetime.now();
//        String nowStr = nowDT.format('yyyyMMddHHmm');
//        RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring();
//        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u2';
 
//        // update
//        GeneralData.SFDCRepairNo                         = rpr.Name;
//        GeneralData.SAPRepairNo                          = rpr.SAPRepairNo__c;
//        GeneralData.RepairOrderStatusCode                = 'A95';
//        GeneralData.RepairOrderStatusName                = '报价同意确认';
//        GeneralData.StatusUpdateDate                     = '20150101';
//        GeneralData.StatusUpdateTime                     = '101010';
//        GeneralData.StatusUpdatePersonName               = 'John';
//        GeneralData.CancellationReason                   = 'R2    到其他公司修理';
//        GeneralData.IncorrectDataComment                 = 'xxxxx';
 
//        GeneralData.SAPQuotationNo                       = 'NFM105U2';
//        InspectionResultInformation.InspectionResultFlag = 'X';
//        InspectionResultInformation.InspectionComment    = 'CCD线长度: 248MM  把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。';
//        InspectionResultInformation.FailureCause         = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10';
//        FailureInformation.LocationGroupName             = '内镜连接座部';
//        FailureInformation.LocationName                  = 'LG导光杆部';
//        FailureInformation.PhenomenonName                = 'IG导光束异常(红裂缝、折损、彩虹斑)';
//        FailureInformation.CauseName                     = '劣化, 老化';
//        FailureInformation.DescriptionName               = '由于送气・送水圆筒的刮痕导致气囊送水量不能达到规格值。';
 
//        System.Test.startTest();
//        NFM105WebService.NFM105(RepairStatusUpdate);
//        System.Test.stopTest();
 
//        List<Repair__c> sapRpairList = [select Id, Name, SAPRepairNo__c
//                                                , RepairOrderStatusName__c, RepairOrderStatusCode__c
//                                                , CancellationReason__c, IncorrectDataComment__c
//                                                , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c
//                                                , Repair_Quotation_Id__c
//                                           from Repair__c
//                                          where SAPRepairNo__c = :GeneralData.SAPRepairNo];
//        System.assertEquals(1, sapRpairList.size());
//        if (sapRpairList.size() == 1) {
//            System.assertEquals(GeneralData.SAPRepairNo, sapRpairList[0].SAPRepairNo__c);
//            System.assertEquals(GeneralData.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c);
//            System.assertEquals(GeneralData.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c);
//            System.assertEquals(GeneralData.CancellationReason, sapRpairList[0].CancellationReason__c);
//            System.assertEquals(null, sapRpairList[0].IncorrectDataComment__c);
//        }
//        List<Repair_Quotation__c> quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c
//                                                          , InspectionComment__c, InspectionResultFlag__c
//                                                          , InspectionFailureCause__c, CauseName__c, DescriptionName__c
//                                                          , LocationName__c, LocationGroupName__c
//                                                          , PhenomenonName__c, LatestQuotationDate__c
//                                                          , FirstQuotationDate__c, DiscountAmount__c
//                                                          , TotalPrice__c, DiscountType__c
//                                                          , CafeteriaFlag__c, MessageGroupNumber__c
//                                                     from Repair_Quotation__c
//                                                    where Name = :GeneralData.SAPQuotationNo
//                                                  ];
//        System.assertEquals(1, quotationList.size());
//        if (quotationList.size() == 1) {
//            System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name);
//            System.assertEquals(false, quotationList[0].Quotation_agreement__c);
//            System.assertEquals(null, quotationList[0].InspectionResultFlag__c);
//            System.assertEquals(null, quotationList[0].InspectionComment__c);
//            System.assertEquals(null, quotationList[0].InspectionFailureCause__c);
//            List<Repair_quotation_reason__c> qrsn0List = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c <>: quotationList[0].Id];
//            System.assertEquals(0, qrsn0List.size());
//            List<Repair_quotation_reason__c> qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c =: quotationList[0].Id];
//            System.assertEquals(0, qrsnList.size());
//        }
//    }
 
//    //StatusCode = 'A99';
//    @isTest
//    static void testNFM105_update_A99() {
//        Repair__c rpr = makeTestRepair();
 
//        Repair_Quotation__c rq1 = new Repair_Quotation__c();
//        rq1.Name            = 'NFM105U1';
//        rq1.Repair__c       = rpr.Id;
//        Repair_Quotation__c rq2 = new Repair_Quotation__c();
//        rq2.Name            = 'NFM105U2';
//        rq2.Repair__c       = rpr.Id;
//        insert new Repair_Quotation__c[]{rq1, rq2};
 
//        NFM105WebService.RepairStatusUpdate RepairStatusUpdate                   = new NFM105WebService.RepairStatusUpdate();
//        NFM105WebService.GeneralData GeneralData                                 = new NFM105WebService.GeneralData();
//        NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation();
//        NFM105WebService.FailureInformation FailureInformation                   = new NFM105WebService.FailureInformation();
 
//        GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation };
//        GeneralData.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation };
//        RepairStatusUpdate.GeneralData          = new NFM105WebService.GeneralData[] { GeneralData };
 
//        // Monitoringの設定
//        Datetime nowDT = Datetime.now();
//        String nowStr = nowDT.format('yyyyMMddHHmm');
//        RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring();
//        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u3';
 
//        // update
//        GeneralData.SFDCRepairNo                         = rpr.Name;
//        GeneralData.SAPRepairNo                          = rpr.SAPRepairNo__c;
//        GeneralData.RepairOrderStatusCode                = 'A99';
//        GeneralData.RepairOrderStatusName                = '报价同意确认';
//        GeneralData.StatusUpdateDate                     = '20150101';
//        GeneralData.StatusUpdateTime                     = '101010';
//        GeneralData.StatusUpdatePersonName               = 'John';
//        GeneralData.CancellationReason                   = 'R2    到其他公司修理 ';
//        GeneralData.IncorrectDataComment                 = 'xxxxx';
 
//        GeneralData.SAPQuotationNo                       = 'NFM105U2';
//        InspectionResultInformation.InspectionResultFlag = 'X';
//        InspectionResultInformation.InspectionComment    = 'CCD线长度: 248MM  把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。';
//        InspectionResultInformation.FailureCause         = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10';
//        FailureInformation.LocationGroupName             = '内镜连接座部';
//        FailureInformation.LocationName                  = 'LG导光杆部';
//        FailureInformation.PhenomenonName                = 'IG导光束异常(红裂缝、折损、彩虹斑)';
//        FailureInformation.CauseName                     = '劣化, 老化';
//        FailureInformation.DescriptionName               = '由于送气・送水圆筒的刮痕导致气囊送水量不能达到规格值。';
 
//        System.Test.startTest();
//        NFM105WebService.NFM105(RepairStatusUpdate);
//        System.Test.stopTest();
 
        
//        List<Repair__c> sapRpairList = [select Id, Name, SAPRepairNo__c
//                                                , RepairOrderStatusName__c, RepairOrderStatusCode__c
//                                                , CancellationReason__c, IncorrectDataComment__c
//                                                , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c
//                                                , Repair_Quotation_Id__c
//                                           from Repair__c
//                                          where SAPRepairNo__c = :GeneralData.SAPRepairNo];
//        System.assertEquals(1, sapRpairList.size());
//        if (sapRpairList.size() == 1) {
//            System.assertEquals(GeneralData.SAPRepairNo, sapRpairList[0].SAPRepairNo__c);
//            System.assertEquals(GeneralData.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c);
//            System.assertEquals(GeneralData.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c);
//            System.assertEquals(null, sapRpairList[0].CancellationReason__c);
//            System.assertEquals(GeneralData.IncorrectDataComment, sapRpairList[0].IncorrectDataComment__c);
//        }
//        List<Repair_Quotation__c> quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c
//                                                          , InspectionComment__c, InspectionResultFlag__c
//                                                          , InspectionFailureCause__c, CauseName__c, DescriptionName__c
//                                                          , LocationName__c, LocationGroupName__c
//                                                          , PhenomenonName__c, LatestQuotationDate__c
//                                                          , FirstQuotationDate__c, DiscountAmount__c
//                                                          , TotalPrice__c, DiscountType__c
//                                                          , CafeteriaFlag__c, MessageGroupNumber__c
//                                                     from Repair_Quotation__c
//                                                    where Name = :GeneralData.SAPQuotationNo
//                                                  ];
//        System.assertEquals(1, quotationList.size());
//        if (quotationList.size() == 1) {
//            System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name);
//            System.assertEquals(false, quotationList[0].Quotation_agreement__c);
//            System.assertEquals(null, quotationList[0].InspectionResultFlag__c);
//            System.assertEquals(null, quotationList[0].InspectionComment__c);
//            System.assertEquals(null, quotationList[0].InspectionFailureCause__c);
//            List<Repair_quotation_reason__c> qrsn0List = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c <>: quotationList[0].Id];
//            System.assertEquals(0, qrsn0List.size());
//            List<Repair_quotation_reason__c> qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c =: quotationList[0].Id];
//            System.assertEquals(0, qrsnList.size());
//        }
//    }
//    @isTest
//    static void NFM105_Resendtest() {
//        Repair__c rpr = makeTestRepair();
 
//        Repair_Quotation__c rq1 = new Repair_Quotation__c();
//        rq1.Name            = 'NFM105U1';
//        rq1.Repair__c       = rpr.Id;
//        Repair_Quotation__c rq2 = new Repair_Quotation__c();
//        rq2.Name            = 'NFM105U2';
//        rq2.Repair__c       = rpr.Id;
//        insert new Repair_Quotation__c[]{rq1, rq2};
 
//        NFM105WebService.RepairStatusUpdate RepairStatusUpdate                   = new NFM105WebService.RepairStatusUpdate();
//        NFM105WebService.GeneralData GeneralData                                 = new NFM105WebService.GeneralData();
//        NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation();
//        NFM105WebService.FailureInformation FailureInformation                   = new NFM105WebService.FailureInformation();
 
//        GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation };
//        GeneralData.FailureInformation          = new NFM105WebService.FailureInformation[] { FailureInformation };
//        RepairStatusUpdate.GeneralData          = new NFM105WebService.GeneralData[] { GeneralData };
 
//        // Monitoringの設定
//        Datetime nowDT = Datetime.now();
//        String nowStr = nowDT.format('yyyyMMddHHmm');
//        RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring();
//        RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u2';
 
//        // update
//        GeneralData.SFDCRepairNo                         = rpr.Name;
//        GeneralData.SAPRepairNo                          = rpr.SAPRepairNo__c;
//        GeneralData.RepairOrderStatusCode                = 'A95';
//        GeneralData.RepairOrderStatusName                = '报价同意确认';
//        GeneralData.StatusUpdateDate                     = '20150101';
//        GeneralData.StatusUpdateTime                     = '101010';
//        GeneralData.StatusUpdatePersonName               = 'John';
//        GeneralData.CancellationReason                   = 'R2    到其他公司修理';
//        GeneralData.IncorrectDataComment                 = 'xxxxx';
 
//        GeneralData.SAPQuotationNo                       = 'NFM105U2';
//        InspectionResultInformation.InspectionResultFlag = 'X';
//        InspectionResultInformation.InspectionComment    = 'CCD线长度: 248MM  把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。';
//        InspectionResultInformation.FailureCause         = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10';
//        FailureInformation.LocationGroupName             = '内镜连接座部';
//        FailureInformation.LocationName                  = 'LG导光杆部';
//        FailureInformation.PhenomenonName                = 'IG导光束异常(红裂缝、折损、彩虹斑)';
//        FailureInformation.CauseName                     = '劣化, 老化';
//        FailureInformation.DescriptionName               = '由于送气・送水圆筒的刮痕导致气囊送水量不能达到规格值。';
 
//        System.Test.startTest();
//        NFM105WebService.NFM105(RepairStatusUpdate);
//        System.Test.stopTest();
 
//        List<Repair__c> repair = [select Id, Name from Repair__c where Id=:rpr.Id];
//        System.assertEquals(1, repair.size());
 
//        List<BatchIF_Log__c> rowbl = [Select Id, Log__c,
//                                            ErrorLog__c,
//                                            retry_cnt__c 
//                                        from BatchIF_Log__c
//                                        where RowDataFlg__c = true
//                                        and Type__c = 'NFM105'
//                                        order by CreatedDate desc];
//        System.assertEquals(1, rowbl.size());
//        rowbl[0].retry_cnt__c = 1;
//        update rowbl;
 
//        NFM105WebService.execute(rowbl[0].id);
 
//        List<BatchIF_Log__c> bl = [Select Id, Is_Error__c,
//                Type__c, Log__c, ErrorLog__c,retry_cnt__c
//                from BatchIF_Log__c
//                where Id = :rowbl[0].id];
//        System.assertEquals(1, bl.size());
//        System.assertEquals(1, bl[0].retry_cnt__c);
//    }
    // TODO Assetの値のasset、未修理 と 再受付
}