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
@isTest
private class lexBatchApprovalRecordsControllerTest {
    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;
    }
    public static testMethod void method1(){
                    RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
            Address_Level__c al = new Address_Level__c();
            al.Name = '東京';
            al.Level1_Code__c = 'CN-01';
            al.Level1_Sys_No__c = '999999';
            insert al;
            Account acc1 = new Account();
            acc1.RecordTypeId = rectCo.Id;
            acc1.Name = 'HP test2';
            acc1.Is_Active__c = '草案中';
            acc1.HospitalType__c = '企业集团';
            acc1.Is_upload_file__c = true;
            acc1.State_Master__c = al.id;
            acc1.InstitutionalType__c = '非医疗机构';
 
            insert acc1;
 
 
            
 
          // 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 = UserInfo.getUserId();
 
        //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 = UserInfo.getUserId();
        ada.InstitutionalType__c = '非医疗机构';
        ada.HospitalType__c = '企业集团';
        ada.CreatedById = UserInfo.getUserId();
        
        if (Test.isRunningTest()) {
            System.runAs(new User(Id = UserInfo.getUserId())){
                insert ada;
            }
        }
 
           
 
 
        List<User> users = [select Id, FirstName, LastName FROM User LIMIT 1];
 
         // 提交审批请求
        Approval.ProcessSubmitRequest submitReq = new Approval.ProcessSubmitRequest();
        submitReq.setObjectId(ada.Id);
        Approval.ProcessResult result = Approval.process(submitReq);
 
        Integer intvar = lexBatchApprovalRecordsController.gettotalcount();
        List<lexBatchApprovalRecordsController.SubmittedRecordsWrapper> prorec = new List<lexBatchApprovalRecordsController.SubmittedRecordsWrapper>();
        prorec = lexBatchApprovalRecordsController.getSubmittedRecords(5,0);
        try{
            string resultrec = lexBatchApprovalRecordsController.processRecords('Approve',Json.serialize(prorec),'test');
        }catch(Exception e){
            system.debug('Exception from process:'+e.getMessage());
        }
        lexBatchApprovalRecordsController.getObjectName(UserInfo.getUserId());
        ProcessInstance ps = [SELECT TargetObjectId,TargetObject.Name,CreatedDate,ProcessDefinitionId FROM ProcessInstance limit 1];
 
        lexBatchApprovalRecordsController.getSubmitRecord(ps);
 
 
 
 
        
 
    }
}