高章伟
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
@isTest
private class NFM622ControllerTest {
    public class Actives_element {
        public NFMUtil.Monitoring Monitoring;
        public Active_element[] GeData;
    }
    public class Active_element {
        public String Num;
        public String Name;
        public String Status;
        public String StartDate; 
        public String EndDate; 
    }
 
    static testMethod void testMethod1(){
        Campaign cam = new Campaign();
        cam.Name = 'test campaign';
        cam.StartDate = Date.today().addDays(15);
        cam.EndDate = Date.today().addDays(18);
        cam.Name2__c = '1234';
        cam.Status = '申请中';
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        cam.HostName__c = '1';
        cam.cooperatorCompany__c = '1';
        insert cam;
        List<String> qisIdList = new List<String>();
        qisIdList.add(cam.Id);
        if (qisIdList.size() > 0) {
            BatchIF_Log__c iflog = new BatchIF_Log__c();
            iflog.Type__c = 'NFM622';
            iflog.Log__c  = 'callout start\n';
            insert iflog;           
            NFM622Controller.callout(iflog.Id, qisIdList);
        }
    }
 
    static testMethod void testMethod2(){
        Campaign cam = new Campaign();
        cam.Name = 'test campaign';
        cam.StartDate = Date.today().addDays(15);
        cam.EndDate = Date.today().addDays(18);
        cam.Name2__c = '1234';
        cam.Status = '申请中';
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        cam.HostName__c = '1';
        cam.cooperatorCompany__c = '1';
        insert cam;
 
        Actives_element actives = new Actives_element();
        actives.Monitoring = new NFMUtil.Monitoring();
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        actives.Monitoring.TransmissionDateTime = nowStr;
        actives.Monitoring.Text                 = ''; 
        actives.Monitoring.Tag                  = 'MSGH';
        actives.Monitoring.Sender               = 'SFDC';
        actives.Monitoring.Receiver             = '智慧医疗';
        actives.Monitoring.MessageType          = 'NFM622';
 
        actives.GeData = new List<Active_element>();
        Active_element active = new Active_element();
        actives.GeData.add(active);
        active.Num = cam.Num__c;
        active.Name = cam.Name2__c;
        active.Status = cam.Status;
        active.StartDate = NFMUtil.formatDate2Str(cam.StartDate);
        active.EndDate = NFMUtil.formatDate2Str(cam.EndDate);
 
        NFMUtil.Monitoring Monitoring   = new NFMUtil.Monitoring();
        Monitoring.Tag                  = actives.Monitoring.Tag;
        Monitoring.Sender               = actives.Monitoring.Sender;
        Monitoring.Receiver             = actives.Monitoring.Receiver;
        Monitoring.MessageType          = actives.Monitoring.MessageType;
        Monitoring.MessageGroupNumber   = actives.Monitoring.MessageGroupNumber;
        Monitoring.NumberOfRecord       = actives.Monitoring.NumberOfRecord;
        Monitoring.TransmissionDateTime = actives.Monitoring.TransmissionDateTime;
        Monitoring.Text = '';
        BatchIF_Log__c rowData = NFMUtil.makeRowData(Monitoring, 'NFM622', actives);
 
        List<String> qisIdList = new List<String>();
        qisIdList.add(cam.Id);
        if (qisIdList.size() > 0) {
            BatchIF_Log__c iflog = null;           
            NFM622Controller.execute(rowData, null);
        }
    }
 
}