高章伟
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
@isTest
private class UpdateLeaderBeEmptyBatchTest {
    static testMethod void testMethod1() {
 
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
                                    Alias = 'hp', CommunityNickname = 'TestMao2', Email = 'Test2@sunbridge.com',
                                    Username = 'ooo234@sunbridge.com', IsActive = false, EmailEncodingKey = 'ISO-2022-JP', 
                                    TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                                    Stay_or_not__c = '已离职');
        insert hpOwner2;
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;
 
        // 病院を作る
        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.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        hospital.FSE_GI_Main_Leader__c = hpOwner2.Id;
        insert hospital;
 
        System.Test.startTest();
        Database.executeBatch(new UpdateLeaderBeEmptyBatch(hpOwner2.Id));
        System.Test.StopTest();
    }
    //2021-09-27  mzy SFDC-合并batch  end
    static testMethod void testMethod2() {
 
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
                                    Alias = 'hp', CommunityNickname = 'TestMao2', Email = 'Test2@sunbridge.com',
                                    Username = 'ooo234@sunbridge.com', IsActive = false, EmailEncodingKey = 'ISO-2022-JP', 
                                    TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                                    Stay_or_not__c = '已离职');
        insert hpOwner2;
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;
 
        // 病院を作る
        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.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        hospital.FSE_GI_Main_Leader__c = hpOwner2.Id;
        insert hospital;
 
        System.Test.startTest();
        Database.executeBatch(new UpdateLeaderBeEmptyBatch(true));
        System.Test.StopTest();
    }
    static testMethod void testMethod3() {
 
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
                                    Alias = 'hp', CommunityNickname = 'TestMao2', Email = 'Test2@sunbridge.com',
                                    Username = 'ooo234@sunbridge.com', IsActive = false, EmailEncodingKey = 'ISO-2022-JP', 
                                    TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                                    Stay_or_not__c = '已离职');
        insert hpOwner2;
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;
 
        // 病院を作る
        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.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        hospital.FSE_GI_Main_Leader__c = hpOwner2.Id;
        insert hospital;
 
        System.Test.startTest();
        Database.executeBatch(new UpdateLeaderBeEmptyBatch());
        System.Test.StopTest();
    }
    //2021-09-27  mzy SFDC-合并batch  end
}