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
// 2023/08/06  批量选择修理LWC处理  测试类
@isTest
private class lexBatchSelectRepairLWCControllerTest {
    @TestSetup
    public static void init(){
 
        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', 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;
        List<RecordType> rectHp = [SELECT Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        List<RecordType> rectDpt = [SELECT Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
        if (rectDpt.size() == 0) {
            return;
        }
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'SoakupTestHp', OwnerId = hpOwner.Id);
        insert hp;
        Account dc = [SELECT Id, Name, RecordType_DeveloperName__c, Account2__c FROM Account WHERE ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
        Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
        dpt.Name         = '*';
        dpt.Department_Name__c  = 'TestDepart';
        dpt.ParentId            = dc.Id;
        dpt.Department_Class__c = dc.Id;
        dpt.Hospital__c         = hp.Id;
        insert dpt;
        Asset asset = new Asset();
        asset.Name = 'テスト機器';
        asset.AccountId = dpt.Id;
        asset.Department_Class__c = dc.Id;
        asset.Hospital__c = hp.Id;
        asset.SerialNumber = 'testserial';
 
        insert asset;
    
        Repair__c repair01 = new Repair__c();
        repair01.Account__c = dpt.Id;
        repair01.Department_Class__c = dc.Id;
        repair01.Hospital__c = hp.Id;
        repair01.Delivered_Product__c = asset.Id;
        repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); 
        repair01.FSE_Work_Location__c = '上海';
        repair01.Service_Repair_No__c = 'SAP0001';
        repair01.Incharge_Staff__c = hpOwner.Id;
        repair01.On_site_repair__c = 'RC修理';
        repair01.work_location_select__c = '北京办事处';
        repair01.AWS_Data_Id__c='test123';
        insert repair01;
        System.assertEquals(true,repair01.Id != null, '插入失败');
    }
    
    static testMethod void testSearch() {
        System.Test.StartTest();
        List<Repair__c> objRepair = [SELECT Status1__c,Status2__c,HP_Name__c,Name,SAP_Service_Repair_No__c,SerialNumber__c,work_location_select__c,On_site_repair__c,Incharge_Staff__c
                                      FROM Repair__c LIMIT 5];
        lexBatchSelectRepairLWCController.RetrievalData returnData = new lexBatchSelectRepairLWCController.RetrievalData();
        returnData.Status1 = objRepair[0].Status1__c;
        returnData.Status2 = objRepair[0].Status2__c;
        returnData.HospitalName = objRepair[0].HP_Name__c;
        returnData.RepairName = objRepair[0].Name;
        returnData.SAPRepairNo =objRepair[0].SAP_Service_Repair_No__c+','+objRepair[0].SAP_Service_Repair_No__c+' '+objRepair[0].SAP_Service_Repair_No__c;
        returnData.SerialNumber =objRepair[0].SerialNumber__c+','+objRepair[0].SerialNumber__c;
        returnData.workLocationSelect =objRepair[0].work_location_select__c+','+objRepair[0].work_location_select__c+' '+objRepair[0].work_location_select__c;
        returnData.repair.Aware_date__c = Date.today();
        returnData.repair.Incharge_Staff__c = objRepair[0].Incharge_Staff__c;
 
        returnData.onSiteRepair = objRepair[0].On_site_repair__c;
        lexBatchSelectRepairLWCController.ReturnData serachRes = lexBatchSelectRepairLWCController.search(JSON.serialize(returnData));
        returnData = new lexBatchSelectRepairLWCController.RetrievalData();
        serachRes = lexBatchSelectRepairLWCController.search(JSON.serialize(returnData));
        serachRes = lexBatchSelectRepairLWCController.search('{"Status1":"0.删除"}');
        lexBatchSelectRepairLWCController.showPDF(JSON.serialize(objRepair));
        System.Test.StopTest();
 
    }
    // static testMethod void testShowPDF() {
    //     System.Test.StartTest();
    //     List<Repair__c> objRepair = [SELECT Status1__c,Status2__c,HP_Name__c,Name,SAP_Service_Repair_No__c,SerialNumber__c  FROM Repair__c LIMIT 10];
    //     // String showPDFRes = lexBatchSelectRepairLWCController.showPDF(JSON.serialize(objRepair));
    //     // System.assertEquals(true, showPDFRes != null);
    //     // objRepair = [SELECT Id,Status1__c,Status2__c,HP_Name__c,Name,SAP_Service_Repair_No__c,SerialNumber__c  FROM Repair__c WHERE FSE_Work_Location__c = '上海'];
    //     // showPDFRes = lexBatchSelectRepairLWCController.showPDF(JSON.serialize(objRepair));
    //     // System.assertEquals(true, showPDFRes != null);
    //     // objRepair = [SELECT Status1__c,Status2__c,HP_Name__c,Name,SAP_Service_Repair_No__c,SerialNumber__c  FROM Repair__c LIMIT 60];
    //     // showPDFRes = lexBatchSelectRepairLWCController.showPDF(JSON.serialize(objRepair));
    //     // System.assertEquals(true, showPDFRes != null);
    //     // objRepair.clear();
    //     // showPDFRes = lexBatchSelectRepairLWCController.showPDF(JSON.serialize(objRepair));
    //     // System.assertEquals(true, showPDFRes != null);      
    //     System.Test.StopTest();
    // }
    
}