高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
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
@isTest
private class LogAutoSendScheduleTest {
 
    static testMethod void testExecute() {
        // This test runs a scheduled job at midnight Sept. 3rd. 2022
        String CRON_EXP = '0 0 0 3 9 ? 2030';
 
        System.Test.startTest();
        // Schedule the test job
        String jobId = system.schedule('LogAutoSendScheduleTest', CRON_EXP, new LogAutoSendSchedule());
        // Get the information from the CronTrigger API object
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
        // Verify the expressions are the same
        System.assertEquals(CRON_EXP, ct.CronExpression);
        // Verify the job has not run
        System.assertEquals(0, ct.TimesTriggered);
        // Verify the next time the job will run
        System.assertEquals('2030-09-03 00:00:00', String.valueOf(ct.NextFireTime));
        System.Test.StopTest();
    }
    static testMethod void testassignOneMinute() {
        LogAutoSendSchedule.assignOneMinute();
    }
 
    // 20230201 ljh start
    static testMethod void testExecute01() {
        String messageGroupNumber = '202302011619';
        String type  = 'NFM007';
        // This test runs a scheduled job at midnight Sept. 3rd. 2022
        String CRON_EXP = '0 0 0 3 9 ? 2030';
 
        System.Test.startTest();
        // Schedule the test job
        String jobId = system.schedule('LogAutoSendScheduleTest', CRON_EXP, new LogAutoSendSchedule(messageGroupNumber,type));
        // Get the information from the CronTrigger API object
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
        // Verify the expressions are the same
        System.assertEquals(CRON_EXP, ct.CronExpression);
        // Verify the job has not run
        System.assertEquals(0, ct.TimesTriggered);
        // Verify the next time the job will run
        System.assertEquals('2030-09-03 00:00:00', String.valueOf(ct.NextFireTime));
        System.Test.StopTest();
    }
    static testMethod void testassignOneMinute01() {
        String messageGroupNumber = '202302011619';
        String type  = 'NFM007';
        LogAutoSendSchedule.assignOneMinute(messageGroupNumber,type);
    }
    // 20230201 ljh start
}