高章伟
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
@isTest
private class NextMonthVisitTwoBatchTest {
    //private static Event e{get;set;}
    private static String loginId {get; set;}
    private static User u1 {get; set;}
    private static User u2 {get; set;}
    private static User u3 {get; set;}
    private static Account accHP {get; set;}
    private static Account accDepClass {get; set;}
    private static Account accDep {get; set;}
    private static Contact con1 {get; set;}
    private static Contact con2 {get; set;}
    private static Contact con3 {get; set;}
    private static Contact con4 {get; set;}
    private static Contact con5 {get; set;}
    private static Opportunity opp1 {get; set;}
    private static Opportunity opp2 {get; set;}
    private static Opportunity opp3 {get; set;}
    private static Opportunity opp4 {get; set;}
    private static Opportunity opp5 {get; set;}
    private static Maintenance_Contract__c mc1 {get; set;}
    private static Maintenance_Contract__c mc2 {get; set;}
    private static String accDepId {get; set;}
    private static String accDepName {get; set;}
    private static void init() {
        loginId = UserInfo.getUserId();
        id pid = UserInfo.getProfileId();
        //Profile p = [select id from Profile where id = :System.Label.ProfileId_SystemAdmin];
        System.Test.startTest();
        u3 = new User(Test_staff__c = true);
        u3.LastName = '_サンブリッジ';
        u3.Batch_User__c = true;
        u3.FirstName = 'う';
        u3.Alias = 'う';
        u3.Email = 'olympusTest03@sunbridge.com';
        u3.Username = 'olympusTest03@sunbridge.com';
        u3.CommunityNickname = 'う';
        u3.IsActive = true;
        u3.EmailEncodingKey = 'ISO-2022-JP';
        u3.TimeZoneSidKey = 'Asia/Tokyo';
        u3.LocaleSidKey = 'ja_JP';
        u3.LanguageLocaleKey = 'ja';
        u3.ProfileId = pid;
        u3.Job_Category__c = '支援';
        u3.Province__c = '東京';
 
 
        u1 = new User(Test_staff__c = true);
        u1.LastName = '_サンブリッジ';
        u1.FirstName = 'あ';
        u1.Batch_User__c = true;
        u1.Alias = 'あ';
        u1.Email = 'olympusTest01@sunbridge.com';
        u1.Username = 'olympusTest10@sunbridge.com';
        u1.CommunityNickname = 'あ1';
        u1.IsActive = true;
        u1.EmailEncodingKey = 'ISO-2022-JP';
        u1.TimeZoneSidKey = 'Asia/Tokyo';
        u1.LocaleSidKey = 'ja_JP';
        u1.LanguageLocaleKey = 'ja';
        u1.ProfileId = pid;
        u1.Job_Category__c = '销售服务';
        u1.Province__c = '東京';
        u1.ManagerId = u3.id;
 
 
        u2 = new User(Test_staff__c = true);
        u2.LastName = '_サンブリッジ';
        u2.FirstName = 'い';
        u2.Batch_User__c = true;
        u2.Alias = 'い';
        u2.Email = 'olympusTest02@sunbridge.com';
        u2.Username = 'olympusTest02@sunbridge.com';
        u2.CommunityNickname = 'い';
        u2.IsActive = true;
        u2.EmailEncodingKey = 'ISO-2022-JP';
        u2.TimeZoneSidKey = 'Asia/Tokyo';
        u2.LocaleSidKey = 'ja_JP';
        u2.LanguageLocaleKey = 'ja';
        u2.ProfileId = pid;
        u2.Job_Category__c = '销售推广';
        u2.Province__c = '東京';
        insert New List<user>{u1,u2,u3};
 
 
        //RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT'];           // 耳鼻喉科
 
        //Address_Level__c al = [select id from Address_Level__c where Level1_Code__c =:'CN-01'];
        //Address_Level2__c al2 = [select id from Address_Level2__c where Name =:'延庆县'];
        // system.runAs(u2) {
            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;
 
            accHP = new Account();
            accHP.Name = '病院1';
            accHP.Grade__c = '一般';
            accHP.OCM_Category__c = '一般';
            accHP.Attribute_Type__c = '保険省';
            accHP.Speciality_Type__c = '総合病院';
            accHP.Is_Active__c = '有効';
            accHP.State_Master__c = al.id;
            accHP.City_Master__c = al2.id;
            accHP.RecordTypeId = '01210000000QemG';
            accHP.Valid_To__c = Date.today() + 2;
            accHP.FSE_GI_Main_Leader__c = UserInfo.getUserId();
            accHP.FSE_SP_Main_Leader__c = UserInfo.getUserId();
            insert accHP;
            /*
            accDepClass = new Account();
            accDepClass.Name = '戦略科室分類1';
            accDepClass.Department_Class_Label__c = '耳鼻喉科';
            accDepClass.Hospital_Department_Class__c = accHP.id;
            accDepClass.ParentId = accHP.id;
            accDepClass.RecordTypeId = rtDepClass.id;
            insert accDepClass;
            */
            accDepClass = [select Id from Account where ParentId = :accHP.Id and Department_Class_Label__c = '耳鼻喉科'];
 
            accDep = new Account();
            accDep.Name = '診療科1';
            accDep.Department_Class_Label__c = '診療科1';
            accDep.Hospital__c = accHP.id;
            accDep.ParentId = accDepClass.id;
            accDep.Department_Class__c = accDepClass.id;
            accDep.Department_Name__c = '診療科1';
            accDep.CurrencyIsoCode = 'CNY';
            accDep.RecordTypeId = '01210000000Qfm2';
            accDep.FSE_GI_Main_Leader__c = UserInfo.getUserId();
            accDep.FSE_SP_Main_Leader__c = UserInfo.getUserId();
 
            insert accDep;
            accDepId = accDep.Id;
            accDep = [select Name from Account where Id = :accDep.Id];
            accDepName = accDep.Name;
        // 取引先責任者の住所を数式項目に変更の為、当該項目を削除
        // 省の参照先は病院の住所になったため、カバレッジテストを行うには
        // 所属する病院の賞を変更して実施してください。by 宗像(真)
            List<Contact> conList = new List<Contact>();
            con1 = new Contact();
            con1.Firstname = 'ZZ1';
            con1.LastName = '取引先責任者1';
            con1.RecordTypeId = '01210000000QfWd';
            con1.AccountId = accDep.Id;
        //        con1.State__c = '北京市';
            con2 = new Contact();
            con2.Firstname = 'ZZ2';
            con2.LastName = '取引先責任者2';
            con2.RecordTypeId = '01210000000QfWd';
            con2.AccountId = accDep.Id;
        //        con2.State__c = '北京市';
            con3 = new Contact();
            con3.Firstname = 'ZZ3';
            con3.LastName = '取引先責任者3';
            con3.RecordTypeId = '01210000000QfWd';
            con3.AccountId = accDep.Id;
        //        con3.State__c = '北京市';
            con4 = new Contact();
            con4.Firstname = 'ZZ4';
            con4.LastName = '取引先責任者4';
            con4.RecordTypeId = '01210000000QfWd';
            con4.AccountId = accDep.Id;
        //        con4.State__c = '北京市';
            con5 = new Contact();
            con5.Firstname = 'ZZ5';
            con5.LastName = '取引先責任者5';
            con5.RecordTypeId = '01210000000QfWd';
            con5.AccountId = accDep.Id;
        //        con5.State__c = '北京市';
            conList.add(con1);
            conList.add(con2);
            conList.add(con3);
            conList.add(con4);
            conList.add(con5);
            insert conList;
            System.Test.stopTest();
            List<Opportunity> oppList = new List<Opportunity>();
            opp1 = new Opportunity();
            opp1.Name = '引合1';
            opp1.AccountId = accDep.Id;
            opp1.Opportunity_Category__c = 'ENT';
            opp1.Trade__c = '外貿';
            opp1.StageName = '引合';
            opp1.CurrencyIsoCode = 'CNY';
            opp1.Close_Forecasted_Date__c = date.today().addMonths(1);
            opp1.CloseDate = date.today().addMonths(1);
            opp1.Opportunity_stage__c = '确定了对手参数';
            opp1.Competitor__c = 'E';
            opp1.Sales_Root__c = 'OCM直接販売';
            opp1.Hospital__c = accHP.id;
            opp1.Department_Class__c = accDepClass.id;
            opp1.StageName = '引合';
            opp2 = new Opportunity();
            opp2.Name = '引合2';
            opp2.AccountId = accDep.Id;
            opp2.Opportunity_Category__c = 'ENT';
            opp2.Trade__c = '外貿';
            opp2.StageName = '引合';
            opp2.Opportunity_stage__c = '确定了对手参数';
            opp2.CurrencyIsoCode = 'CNY';
            opp2.Close_Forecasted_Date__c = date.today().addMonths(1);
            opp2.CloseDate = date.today().addMonths(1);
            opp2.Competitor__c = 'E';
            opp2.Sales_Root__c = 'OCM直接販売';
            opp2.Hospital__c = accHP.id;
            opp2.Department_Class__c = accDepClass.id;
            opp2.StageName = '引合';
            opp3 = new Opportunity();
            opp3.Name = '引合3';
            opp3.AccountId = accDep.Id;
            opp3.Opportunity_Category__c = 'ENT';
            opp3.Trade__c = '外貿';
            opp3.StageName = '引合';
            opp3.Opportunity_stage__c = '确定了对手参数';
            opp3.CurrencyIsoCode = 'CNY';
            opp3.Close_Forecasted_Date__c = date.today().addMonths(1);
            opp3.CloseDate = date.today().addMonths(1);
            opp3.Competitor__c = 'E';
            opp3.Sales_Root__c = 'OCM直接販売';
            opp3.Hospital__c = accHP.id;
            opp3.Department_Class__c = accDepClass.id;
            opp3.StageName = '引合';
            opp4 = new Opportunity();
            opp4.Name = '引合4';
            opp4.AccountId = accDep.Id;
            opp4.Opportunity_Category__c = 'ENT';
            opp4.Trade__c = '外貿';
            opp4.StageName = '引合';
            opp4.CurrencyIsoCode = 'CNY';
            opp4.Opportunity_stage__c = '确定了对手参数';
            opp4.Close_Forecasted_Date__c = date.today().addMonths(1);
            opp4.CloseDate = date.today().addMonths(1);
            opp4.Competitor__c = 'E';
            opp4.Sales_Root__c = 'OCM直接販売';
            opp4.Hospital__c = accHP.id;
            opp4.Department_Class__c = accDepClass.id;
            opp4.StageName = '引合';
            opp5 = new Opportunity();
            opp5.Name = '引合5';
            opp5.AccountId = accDep.Id;
            opp5.Opportunity_Category__c = 'ENT';
            opp5.Trade__c = '外貿';
            opp5.StageName = '引合';
            opp5.CurrencyIsoCode = 'CNY';
            opp5.Close_Forecasted_Date__c = date.today().addMonths(1);
            opp5.CloseDate = date.today().addMonths(1);
            opp5.Competitor__c = 'E';
            opp5.Sales_Root__c = 'OCM直接販売';
            opp5.Opportunity_stage__c = '确定了对手参数';
            opp5.Hospital__c = accHP.id;
            opp5.Department_Class__c = accDepClass.id;
            opp5.StageName = '引合';
            oppList.add(opp1);
            oppList.add(opp2);
            oppList.add(opp3);
            oppList.add(opp4);
            oppList.add(opp5);
            insert oppList;
            System.debug('opp1.Name:' + opp1.Name);
 
            accompanying_report__c ar = new accompanying_report__c();
            ar.Name = 'システム管理者';
            ar.Profile_ID_1__c = pid;
            //Database.insert(ar, false);
            insert ar;
 
            report_report__c rr = new report_report__c();
            rr.Name = 'システム管理者';
            rr.Profile_ID_1__c = pid;
            //Database.insert(rr, false);
            insert rr;
    }
    // static testMethod void testMethod1() {
    //     init();
    //      List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
    //     if (rectCo.size() == 0) {
    //         return;
    //     }
    //     List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
    //     if (rectSct.size() == 0) {
    //         return;
    //     }
    //     List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
    //     if (rectDpt.size() == 0) {
    //         return;
    //     }
    //     Account company = new Account();
    //     company.RecordTypeId = rectCo[0].Id;
    //     company.Name         = 'NFM007TestCompany';
    //     upsert company;
    //     Account section = new Account();
    //     section.RecordTypeId = rectSct[0].Id;
    //     section.Name         = '*';
    //     section.Department_Class_Label__c = '消化科';
    //     section.ParentId                  = company.Id;
    //     section.Hospital_Department_Class__c = company.Id;
    //     upsert section;
    //     // System.Test.startTest();
    //     Account depart = new Account();
    //     depart.RecordTypeId = rectDpt[0].Id;
    //     depart.Name         = '*';
    //     depart.Department_Name__c  = 'NFM007TestDepart';
    //     depart.ParentId            = section.Id;
    //     depart.Department_Class__c = section.Id;
    //     depart.Hospital__c         = company.Id;
    //     upsert depart;
 
    //     Opportunity opp1 = new Opportunity();
    //     opp1.AccountId           = depart.Id;
    //     opp1.Department_Class__c = section.Id;
    //     opp1.Hospital__c         = company.Id;
    //     opp1.SAP_Send_OK__c      = false;
    //     opp1.Name                = 'GZ-SP-NFM007_1';
    //     opp1.Trade__c            = '内貿';
    //     opp1.StageName           = '引合';
    //     opp1.CloseDate           = date.newinstance(2022, 11, 30);
    //     opp1.Stock_apply_status__c = '申请中';
    //     opp1.IsNextMonthOfVisit__c = true;
    //     insert opp1;
        
        
    //     Daily_Report__c dr = new Daily_Report__c();
    //     dr.Reported_Date__c = Date.newInstance(2020, 5, 1);
    //     dr.Status__c = '作成中';
    //     dr.Reporter__c = u1.Id;
    //     dr.OwnerId = u1.Id;
    //     insert dr;
 
    //     Event__c ec = new Event__c(
    //         Subject__c = 'test',
    //         StartDateTime__c = Datetime.newInstance(2020, 5, 1, 1, 0, 0),
    //         DurationInMinutes__c = 60,
    //         EndDateTime__c = Datetime.newInstance(2020, 5, 1, 2, 0, 0),
    //         ActivityDate__c = Date.today(),
    //         Daily_Report__c = dr.Id
    //     );
    //     insert ec;
 
    //     Event e = new Event();
    //     e.ActivityDateTime = Datetime.newInstance(2020, 5, 1, 1, 0, 0);
    //     e.ActivityDate =  Date.newInstance(2020, 5, 1);
    //     e.DurationInMinutes = 0;
    //     e.OwnerId = u1.id;
    //     e.IsScheduled__c = true;
    //     e.whatid__c = accDep.Id;
    //     e.NextEventC_ID__c = ec.Id;
    //     e.Related_Opportunity1_ID__c  =opp1.Id;
    //     insert e;
        
 
    //     Database.executeBatch(new NextMonthVisitTwoBatch(), 1);
    //     // System.Test.stopTest();
    // }
 
   
    static testMethod void testMethod2() {
        init();
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            return;
        }
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM007TestCompany';
        upsert company;
        Account section = new Account();
        section.RecordTypeId = rectSct[0].Id;
        section.Name         = '*';
        section.Department_Class_Label__c = '消化科';
        section.ParentId                  = company.Id;
        section.Hospital_Department_Class__c = company.Id;
        upsert section;
        // System.Test.startTest();
        Account depart = new Account();
        depart.RecordTypeId = rectDpt[0].Id;
        depart.Name         = '*';
        depart.Department_Name__c  = 'NFM007TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        Opportunity opp1 = new Opportunity();
        opp1.AccountId           = depart.Id;
        opp1.Department_Class__c = section.Id;
        opp1.Hospital__c         = company.Id;
        opp1.SAP_Send_OK__c      = false;
        opp1.Name                = 'GZ-SP-NFM007_1';
        opp1.Trade__c            = '内貿';
        opp1.StageName           = '引合';
        opp1.CloseDate           = date.newinstance(2022, 11, 30);
        opp1.Stock_apply_status__c = '申请中';
        opp1.IsNextMonthOfVisit__c = true;
        insert opp1;
 
        Daily_Report__c dr = new Daily_Report__c();
        dr.Reported_Date__c = Date.newInstance(2020, 5, 1);
        dr.Status__c = '作成中';
        dr.Reporter__c = u1.Id;
        dr.OwnerId = u1.Id;
        insert dr;
 
        Event__c ec = new Event__c(
            Subject__c = 'test',
            StartDateTime__c = Datetime.newInstance(2020, 5, 1, 1, 0, 0),
            DurationInMinutes__c = 60,
            EndDateTime__c = Datetime.newInstance(2020, 5, 1, 2, 0, 0),
            ActivityDate__c = Date.today(),
            Daily_Report__c = dr.Id
        );
        insert ec;
 
        Event e = new Event();
        Date today  = date.today();
        e.ActivityDateTime = today.addMonths(1).toStartOfMonth();
        e.ActivityDate =  today.addMonths(1).toStartOfMonth();
        e.DurationInMinutes = 0;
        e.OwnerId = u1.id;
        e.IsScheduled__c = true;
        e.whatid__c = accDep.Id;
        e.NextEventC_ID__c = ec.Id;
        e.Related_Opportunity1_ID__c  =opp1.Id;
        e.Related_Opportunity2_ID__c  =opp2.Id;
        e.Related_Opportunity3_ID__c  =opp3.Id;
        e.Related_Opportunity4_ID__c  =opp4.Id;
        e.Related_Opportunity5_ID__c  =opp5.Id;
        insert e;
        
 
        Database.executeBatch(new NextMonthVisitTwoBatch(), 20);
        // System.Test.stopTest();
    }
 
    static testMethod void testMethod3() {
        init();
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            return;
        }
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM007TestCompany';
        upsert company;
        Account section = new Account();
        section.RecordTypeId = rectSct[0].Id;
        section.Name         = '*';
        section.Department_Class_Label__c = '消化科';
        section.ParentId                  = company.Id;
        section.Hospital_Department_Class__c = company.Id;
        upsert section;
        // System.Test.startTest();
        Account depart = new Account();
        depart.RecordTypeId = rectDpt[0].Id;
        depart.Name         = '*';
        depart.Department_Name__c  = 'NFM007TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        Opportunity opp1 = new Opportunity();
        opp1.AccountId           = depart.Id;
        opp1.Department_Class__c = section.Id;
        opp1.Hospital__c         = company.Id;
        opp1.SAP_Send_OK__c      = false;
        opp1.Name                = 'GZ-SP-NFM007_1';
        opp1.Trade__c            = '内貿';
        opp1.StageName           = '引合';
        opp1.CloseDate           = date.newinstance(2022, 11, 30);
        opp1.Stock_apply_status__c = '申请中';
        opp1.IsNextMonthOfVisit__c = true;
        insert opp1;
 
        Daily_Report__c dr = new Daily_Report__c();
        dr.Reported_Date__c = Date.newInstance(2020, 5, 1);
        dr.Status__c = '作成中';
        dr.Reporter__c = u1.Id;
        dr.OwnerId = u1.Id;
        insert dr;
 
        Event__c ec = new Event__c(
            Subject__c = 'test',
            StartDateTime__c = Datetime.newInstance(2020, 5, 1, 1, 0, 0),
            DurationInMinutes__c = 60,
            EndDateTime__c = Datetime.newInstance(2020, 5, 1, 2, 0, 0),
            ActivityDate__c = Date.today(),
            Daily_Report__c = dr.Id
        );
        insert ec;
 
        Event e = new Event();
        Date today  = date.today();
        e.ActivityDateTime = today;
        e.ActivityDate =  today;
        e.DurationInMinutes = 0;
        e.OwnerId = u1.id;
        e.IsScheduled__c = true;
        e.whatid__c = accDep.Id;
        e.NextEventC_ID__c = ec.Id;
        e.Related_Opportunity1_ID__c  =opp1.Id;
        e.Related_Opportunity2_ID__c  =opp2.Id;
        e.Related_Opportunity3_ID__c  =opp3.Id;
        e.Related_Opportunity4_ID__c  =opp4.Id;
        e.Related_Opportunity5_ID__c  =opp5.Id;
        insert e;
        
 
        Database.executeBatch(new NextMonthVisitTwoBatch(true), 20);
        // System.Test.stopTest();
    }
}