高章伟
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
@isTest
private class HistoryTaskBatchTest {
 
    static testMethod void myUnitTest() {
 
        Daily_Report__c dr1 = new Daily_Report__c();
        dr1.Reporter__c = UserInfo.getUserId();
        dr1.Reported_Date__c = date.today().addDays(-2);
        dr1.Status__c = '作成中';
        insert dr1;
 
        Event__c event = new Event__c();
        event.ActivityDate__c = date.today().addDays(-2);
        event.Daily_Report__c = dr1.Id;
        event.StartDateTime__c = Datetime.newInstance(2020, 8, 17, 12, 0, 0);
        event.EndDateTime__c = Datetime.newInstance(2020, 8, 17, 13, 0, 0);
        insert event;
 
        Event__c event2 = new Event__c();
        event2.ActivityDate__c = date.today().addDays(-2);
        event2.Daily_Report__c = dr1.Id;
        event2.StartDateTime__c = Datetime.newInstance(2020, 8, 17, 13, 0, 0);
        event2.EndDateTime__c = Datetime.newInstance(2020, 8, 17, 17, 0, 0);
        insert event2;
 
        List<task__c> tasks = new List<task__c>();
        task__c t1 = new task__c();
        t1.Name = 'test';
        t1.taskDifferent__c = '主动任务';
        t1.taskStatus__c = '02 接受';
        t1.assignee__c = Userinfo.getUserId();
        t1.Activity_Date__c = Date.newInstance(2020, 8, 17);
        t1.Event__c = event.Id;
        tasks.add(t1);
 
        task__c t2 = new task__c();
        t2.Name = 'test';
        t2.taskDifferent__c = '主动任务';
        t2.taskStatus__c = '02 接受';
        t2.assignee__c = Userinfo.getUserId();
        t2.Activity_Date__c = Date.newInstance(2020, 8, 17);
        t2.Event__c = event2.Id;
        tasks.add(t2);
 
        task__c t3 = new task__c();
        t3.Name = 'test3';
        t3.taskDifferent__c = '主动任务';
        t3.taskStatus__c = '02 接受';
        t3.assignee__c = Userinfo.getUserId();
        t3.Activity_Date__c = Date.newInstance(2020, 8, 17);
        tasks.add(t3);
        insert tasks;
 
        Event e = new Event();
        e.ActivityDate = date.today().addDays(-2);
        e.ActivityDateTime = Datetime.now()-48;
        e.Task_ID__c = t3.Id;
        e.DurationInMinutes = 0;
        insert e;
 
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new HistoryTaskBatch());
        System.Test.StopTest();
    }
    static testMethod void myUnitTest1() {
        Daily_Report__c dr1 = new Daily_Report__c();
        dr1.Reporter__c = UserInfo.getUserId();
        dr1.Reported_Date__c = date.today().addDays(2);
        dr1.Status__c = '作成中';
        insert dr1;
        
        task__c t3 = new task__c();
        t3.Name = 'test3';
        t3.taskDifferent__c = '主动任务';
        t3.taskStatus__c = '02 接受';
        t3.assignee__c = Userinfo.getUserId();
        t3.Activity_Date__c = Date.newInstance(2020, 8, 17);
        insert t3;
        
        Event__c event3 = new Event__c();
        event3.ActivityDate__c = date.today().addDays(2);
        event3.Daily_Report__c = dr1.Id;
        event3.StartDateTime__c = System.now();
        event3.EndDateTime__c = System.now();
        insert event3;
 
        Event e = new Event();
        e.ActivityDate = date.today().addDays(-2);
        e.ActivityDateTime = Datetime.now()-48;
        e.Task_ID__c = t3.Id;
        e.DurationInMinutes = 0;
        // e.EventC_ID__c = event3.Id;
        insert e;
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new HistoryTaskBatch());
        HistoryTaskBatch h = new HistoryTaskBatch();
        h.test();
        System.Test.StopTest();
    }
 
    
 
}