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
@isTest
public with sharing class AccountDelayApplyControllerTest {
    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;
    }
    @isTest
    static void testAccountDelayApply(){
        // List<Account> HP = [select Id from Account where RecordTypeId = '01210000000QemGAAS' and Is_Active__c = '有効' limit 1];//    病院
        // List<Account> Department_Class_ET = [select Id from Account where RecordTypeId = '01210000000QemQAAS' limit 1];//    戦略科室分類ET
        // List<Account> Agency = [select Id from Account where RecordTypeId = '01210000000Qem1AAC' and Is_Active__c = '有効' limit 1];//  販売店
        // User user5 = setNewUser('ztest05', 'User005', 'Zhang005', 'test005@excemaple.com');
        // User toUser = setNewUser('shenqing', 'shenpi', 'spsqTest', 'shenpi@excemaple.com');
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        String rectSct = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_GI').getRecordTypeId();
        String rectAgency = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectET = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_ET').getRecordTypeId();
        // 病院
        Account HP = new Account(RecordTypeId = rectHp, Name = 'HP');
        HP.Is_Active__c = '有効';
        insert HP;
        // if (Test.isRunningTest()) {
        //     System.runAs(new User(Id = UserInfo.getUserId())){
        //             insert HP;
        //     }
        // }
        //    戦略科室分類ET
        Account Department_Class_ET = new Account(RecordTypeId = rectET, Name = 'Department_Class_ET');
        Department_Class_ET.Is_Active__c = '有効';
        Department_Class_ET.ParentId = HP.id;
        insert Department_Class_ET;
        // if (Test.isRunningTest()) {
        //     System.runAs(new User(Id = UserInfo.getUserId())){
        //             insert Department_Class_ET;
        //     }
        // }
        //  販売店
        Account Agency = new Account(RecordTypeId = rectAgency, Name = 'Agency');
        Agency.Is_Active__c = '有効';
        insert Agency;
        // if (Test.isRunningTest()) {
        //     System.runAs(new User(Id = UserInfo.getUserId())){
        //             insert Agency;
        //     }
        // }
        // Account Department_Class_ET = new Account();//    戦略科室分類ET
        // Department_Class_ET.RecordTypeId = '01210000000QemQAAS';
        // Department_Class_ET.Is_Active__c = '有効';
        // insert Department_Class_ET;
        // Account HP = new Account();//  販売店
        // HP.RecordTypeId = '01210000000QemGAAS';
        // HP.Is_Active__c = '有効';
        // insert HP;
        // List<Account_Delay_Apply__c> b = [select Id from Account_Delay_Apply__c limit 1];
        Test.startTest();
       
        Account_Delay_Apply__c AccQuery = new Account_Delay_Apply__c();
        AccQuery.Is_Active__c = '草案中';
        AccQuery.Hospital__c = HP.Id;
        AccQuery.ChangeReason__c = '地址错误';
        AccQuery.Is_upload_file__c = true;
        AccQuery.InstitutionalType__c = '非医疗机构';
        insert AccQuery;
        // if (Test.isRunningTest()) {
        //     System.runAs(new User(Id = UserInfo.getUserId())){
        //             insert AccQuery;
        //     }
        // }
        System.debug('testAccountDelayApply  : ' + HP);
 
        AccountDelayApplyController.init(HP.Id);
        
        SubmitAndRefreshController.init(AccQuery.Id);
        SubmitAndRefreshController.init('');
 
        HosipitalToDeptController.init(HP.Id);
        HosipitalToDeptController.init('');
        HosipitalToDeptController.submitApproval(AccQuery.Id);
        HosipitalToDeptController.submitApproval('');
        HosipitalToDeptController.updataAccount(HP.Id,true);
        HosipitalToDeptController.updataAccount('',true);
 
        // HosipitalToDeptController.updataAccount(HP.Id,);
 
        MonthlyClaimsChangeController.init(Agency.Id);
        MonthlyClaimsChangeController.init('');
 
        CustomLink2AdvancePaymentController.init(Agency.Id);
        CustomLink2AdvancePaymentController.init('');
 
        NewAgencyContractController.UserInfo_Owner();
 
        SoakupTeamController.init(Department_Class_ET.Id);
        SoakupTeamController.init('');
 
        DealerVisitDetailsController.init(HP.Id);
        DealerVisitDetailsController.init('');
 
        AccountUrlRecordTypeIdController.AccountRecordTypeId('Department_Class_ET');
        // Report report = new Report();
        // List<Report> reportId = [select Id,DeveloperName from Report limit 1];
        // AccountUrlRecordTypeIdController.ReportId(reportId[0].DeveloperName);
 
        QuolifiedApplySPOController.init(HP.Id);
        QuolifiedApplySPOController.updata(HP.Id);
 
        AgencyContractCloneController.init();
 
        toBatchOwnerController.ProfileId();
        toBatchOwnerController.TypeId();
 
        AccountWebService.toBatchOwner(HP.Id);
 
        Test.stopTest();
    }
    
}