高章伟
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
@isTest
public class RentalEquipmentCreateConTest {
 
    static testMethod void unitTest01() {
        OPDPlan__c target1 = new OPDPlan__c();
        target1.OPDType__c = '学会';
        insert target1;
 
        List<Rental_Equipment__c> res = new List<Rental_Equipment__c>();
        Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子');
        res.add(re1);
        Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2');
        res.add(re2);
        Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190');
        res.add(re3);
        Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170');
        res.add(re4);
        Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300');
        res.add(re5);
        insert res;
 
        Test.startTest();
        RentalEquipmentCreateController ren = new RentalEquipmentCreateController();
        ren.opdId = target1.Id;
        ren.getProds();
        Map<String,String> tempMap = new Map<String,String>();
        tempMap.put('GI-290镜子', '1');
        tempMap.put('EU-ME2', '2');
        ren.planProductMap = tempMap;
        ren.save();
        Test.stopTest();
    }
 
    static testMethod void unitTest04() {
        OPDPlan__c target1 = new OPDPlan__c();
        target1.OPDType__c = '事件';
        target1.NoOpp_Reason__c = 'HCP对应';
        insert target1;
        Date t1 = Date.today();
        Event e = new Event(
            StartDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 9, 0, 0),
            EndDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 10, 0, 0),
            Opd_Plan__c = target1.Id,
            noOpp_Reason__c = 'HCP对应'
        );
        insert e;
 
        List<Rental_Equipment__c> res = new List<Rental_Equipment__c>();
        Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子');
        res.add(re1);
        Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2');
        res.add(re2);
        Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190');
        res.add(re3);
        Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170');
        res.add(re4);
        Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300');
        res.add(re5);
        insert res;
 
        Test.startTest();
        RentalEquipmentCreateController ren = new RentalEquipmentCreateController();
        ren.opdId = target1.Id;
        ren.getProds();
        Map<String,String> tempMap = new Map<String,String>();
        tempMap.put('GI-290镜子', '1');
        tempMap.put('EU-ME2', '2');
        ren.planProductMap = tempMap;
        ren.save();
        Test.stopTest();
    }
    
    static testMethod void unitTest02() {
        Campaign target1 = new Campaign();
        target1.Name = 'test campaign1';
        target1.Meeting_Type__c = '赞助会';
        target1.IsDocLOGO__c = true;
        target1.IsDocLOGO__c = true;
        target1.formality1__c  = true;
        target1.IsShowingEquipment__c = true;
        target1.IsAnimalExperience__c = true;
        target1.cooperatorCompany__c = '测试';
        target1.HostName__c = '测试';
        target1.isOther__c = true;
        string rec = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('BusinessTraining').getRecordTypeId();
        target1.RecordTypeId = rec;
        insert target1;
 
        List<Rental_Equipment__c> res = new List<Rental_Equipment__c>();
        Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子');
        res.add(re1);
        Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2');
        res.add(re2);
        Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190');
        res.add(re3);
        Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170');
        res.add(re4);
        Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300');
        res.add(re5);
        insert res;
 
        Test.startTest();
        RentalEquipmentCreateController ren = new RentalEquipmentCreateController();
        ren.campaignId = target1.Id;
        ren.getProds();
        Map<String,String> tempMap = new Map<String,String>();
        tempMap.put('GI-290镜子', '1');
        tempMap.put('EU-ME2', '2');
        ren.planProductMap = tempMap;
        ren.save();
        Test.stopTest();
    }
 
    static testMethod void unitTest03() {
        Campaign target1 = new Campaign();
        target1.Name = 'test campaign1';
        target1.Meeting_Type__c = '赞助会';
        target1.IsDocLOGO__c = true;
        target1.IsDocLOGO__c = true;
        target1.formality1__c  = true;
        target1.IsShowingEquipment__c = true;
        target1.IsAnimalExperience__c = true;
        target1.cooperatorCompany__c = '测试';
        target1.HostName__c = '测试';
        target1.isOther__c = true;
        string rec = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('BusinessTraining').getRecordTypeId();
        target1.RecordTypeId = rec;
        insert target1;
 
        Plan_Rental_Equipment__c plan1 = new Plan_Rental_Equipment__c(Campaign__c = target1.Id,Rental_Equipment__c = 'OTV-S300',Rental_Quantity__c = '3');
        insert plan1;
 
        List<Rental_Equipment__c> res = new List<Rental_Equipment__c>();
        Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子');
        res.add(re1);
        Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2');
        res.add(re2);
        Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190');
        res.add(re3);
        Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170');
        res.add(re4);
        Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300');
        res.add(re5);
        insert res;
 
        Test.startTest();
        RentalEquipmentCreateController ren = new RentalEquipmentCreateController();
        ren.campaignId = target1.Id;
        ren.getProds();
        Map<String,String> tempMap = new Map<String,String>();
        tempMap.put('GI-290镜子', '1');
        tempMap.put('EU-ME2', '2');
        tempMap.put('OTV-S300', '4');
        ren.planProductMap = tempMap;
        ren.save();
        Test.stopTest();
    }
 
    static testMethod void unitTest05() {
        OPDPlan__c target1 = new OPDPlan__c();
        target1.OPDType__c = '事件';
        target1.NoOpp_Reason__c = 'HCP对应';
        insert target1;
        Date t1 = Date.today();
        Event e = new Event(
            StartDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 9, 0, 0),
            EndDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 10, 0, 0),
            Opd_Plan__c = target1.Id,
            noOpp_Reason__c = 'HCP对应'
        );
        insert e;
 
        Plan_Rental_Equipment__c plan1 = new Plan_Rental_Equipment__c(OPD_Plan__c = target1.Id,Rental_Equipment__c = 'OTV-S300',Rental_Quantity__c = '3');
        insert plan1;
 
        List<Rental_Equipment__c> res = new List<Rental_Equipment__c>();
        Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子');
        res.add(re1);
        Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2');
        res.add(re2);
        Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190');
        res.add(re3);
        Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170');
        res.add(re4);
        Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300');
        res.add(re5);
        insert res;
 
        Test.startTest();
        RentalEquipmentCreateController ren = new RentalEquipmentCreateController();
        ren.opdId = target1.Id;
        ren.getProds();
        Map<String,String> tempMap = new Map<String,String>();
        tempMap.put('GI-290镜子', '1');
        tempMap.put('EU-ME2', '2');
        tempMap.put('OTV-S300', '4');
        ren.planProductMap = tempMap;
        ren.save();
        Test.stopTest();
    }
    
}