@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);
        }
    }

}