@isTest
private class NFM706RestTest {

    @isTest static void test_method_one(){

        NFM706Rest.GeDatas GeDatas = new NFM706Rest.GeDatas();
        NFM706Rest.GeData GeData = new NFM706Rest.GeData();
        GeDatas.GeData = new NFM706Rest.GeData[]{GeData};
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        GeDatas.Monitoring = new NFMUtil.Monitoring();
        GeDatas.Monitoring.MessageGroupNumber = nowStr + '01' ;

        GeData.MeetingApprovedNo = 'TEST99793';
        GeData.Num = 'MT-HB-202112-5773';
        GeData.ProcessState = 110 ;

        NFMUtil.Monitoring Monitoring = GeDatas.Monitoring;
        BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'NFM706', GeDatas.GeData);
        NFM706Rest.executefuture(rowData.id);

    }

    @isTest static void test_method_two(){
        List<RecordType> rectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'Society'];
        System.runAs(new User(Id = Userinfo.getUserId())) {
            User user = new User(Test_staff__c = true);
            user.LastName = '_サンブリッジ';
            user.FirstName = 'う';
            user.Alias = 'う';
            user.Email = 'olympusTest03@sunbridge.com';
            user.Username = 'olympusTest03@sunbridge.com';
            user.IsActive = true;
            user.EmailEncodingKey = 'ISO-2022-JP';
            user.TimeZoneSidKey = 'Asia/Tokyo';
            user.LocaleSidKey = 'ja_JP';
            user.LanguageLocaleKey = 'ja';
            user.ProfileId = System.Label.ProfileId_SystemAdmin;
            user.Province__c = '北京';
            user.Dept__c = '医疗华北营业本部';
            user.Use_Start_Date__c = Date.today().addMonths(-6);
            insert user;
            
            Application_for_Conference_Adjudication__c afca = new Application_for_Conference_Adjudication__c();
            afca.Name = 'hahaha';
            afca.MeetingApprovedNo__c = 'TEST99793';
            afca.Num__c = 'MT-HB-202112-5773';
            afca.ProcessState__c =  '审批中';
            insert afca;

            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';
            cam.RecordTypeId = rectCo[0].Id;
            cam.OwnerId = user.Id;
            cam.Meeting_Approved_No__c = afca.id;
            insert cam;
            system.debug('cam.Num__c'+cam.Num__c);



        }
        

        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();

        String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"202112311320","Text":"","Tag":"","Sender":"OBPM","Receiver":"SFDC","NumberOfRecord":"1","MessageType":"NFM706","MessageGroupNumber":""},"GeData":[{"MeetingApprovedNo":"TEST99793","Num":"MT-HB-202112-5773","ProcessState":110}]}';
        req.requestURI = 'services/apexrest/NFM706/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueOf(JsonMsg);

        RestContext.request = req;
        RestContext.response = res;
        
        NFM706Rest.doPost();

       
    }
}