| @isTest | 
| private class NFM703ControllerTest { | 
|   | 
|      | 
|     // @testSetup | 
|     // static void makeTestRepair() { | 
|          | 
|         /*RecordType rectCam = | 
|             [select Id from RecordType | 
|              where SobjectType = 'Campaign' | 
|                               and DeveloperName = 'ServiceEngineerTraining']; | 
|         // Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; | 
|         // User hpOwner = new User(Test_staff__c = true, LastName = 'hp',Work_Location__c = '北京' , FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); | 
|   | 
|   | 
|         Account account1 = new Account(); | 
|         Account account2 = new Account(); | 
|         Contact contact2 = new Contact(); | 
|         // User user = new User(); | 
|         Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c(); | 
|         // 取引先 | 
|         account1.Name = 'test1医院'; | 
|         account1.RecordTypeId = '01210000000QemG'; | 
|         insert account1; | 
|   | 
|         account2.Name = 'test1经销商'; | 
|         account2.RecordTypeId = '01210000000Qem1'; | 
|         insert account2; | 
|         List<Account> acc2list=[select RecordTypeId, Name from Account]; | 
|         System.assertEquals(10,acc2list.size()); | 
|         // 取引先責任者 | 
|         contact2.AccountId = account2.Id; | 
|         contact2.FirstName = '責任者'; | 
|         contact2.LastName = 'test1经销商'; | 
|         insert contact2; | 
|          | 
|         List<Contact> contact2list=[select Id, FirstName from Contact]; | 
|         System.assertEquals('責任者',contact2list[0].FirstName); | 
|         // ユーザー用户 | 
|         // Profile p = [select Id from Profile where Name = '901_经销商社区普通权限_2重验证(ET)']; | 
|         // user.ProfileId = p.Id; | 
|         // user.ContactId = contact2.Id; | 
|         // user.FirstName = 'ユーザー'; | 
|         // user.LastName = 'テスト'; | 
|         // user.Email = 'test_user@example.com'; | 
|         // user.emailencodingkey='UTF-8'; | 
|         // user.languagelocalekey='zh_CN'; | 
|         // user.localesidkey='ja_JP'; | 
|         // user.timezonesidkey='Asia/Shanghai'; | 
|         // user.Username = 'test_user@example.com'; | 
|         // user.Work_Location__c = '北京'; | 
|         // user.Alias = 'テユ'; | 
|         // user.Dept__c = '外科事业本部'; | 
|         // user.responsibility__c = '华北营业一部'; | 
|         // user.OCM_Management_Province__c = '北京'; | 
|         // user.CommunityNickname = 'テストユーザー'; | 
|         // insert user; | 
|   | 
|         Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; | 
|   | 
|         User local = new User(Test_staff__c = true,Employee_No__c ='ocm99999', LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); | 
|         insert local; | 
|   | 
|         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.CommunityNickname = 'う'; | 
|         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.Dept__c = '能量事业本部'; | 
|         user.Work_Location__c = '北京'; | 
|         user.Job_Category__c = '销售推广'; | 
|         user.OCM_Management_Province__c = '北京'; | 
|         user.Province__c = '上海市'; | 
|         user.Use_Start_Date__c = Date.today().addMonths(-6); | 
|         user.Employee_No__c = '0000022174'; | 
|         user.Stay_or_not__c = '在职'; | 
|         insert user; | 
|         Long nowTimeLong = System.now().getTime(); | 
|   | 
|         User u1 = new User(Test_staff__c = true); | 
|         u1.LastName = '_サンブリッジ'; | 
|         // u1.FirstName = 'あ'; | 
|         u1.Batch_User__c = true; | 
|         u1.Alias = 'あ'; | 
|         u1.Email = 'olympusTest01@sunbridge.com'; | 
|         u1.Username = 'olympusTest10@sunbridge.com' + nowTimeLong; | 
|         u1.CommunityNickname = 'あ'; | 
|         u1.Work_Location__c = '北京'; | 
|         u1.IsActive = true; | 
|         u1.EmailEncodingKey = 'ISO-2022-JP'; | 
|         u1.TimeZoneSidKey = 'Asia/Tokyo'; | 
|         u1.LocaleSidKey = 'ja_JP'; | 
|         u1.LanguageLocaleKey = 'ja'; | 
|         u1.ProfileId = System.Label.ProfileId_SystemAdmin; | 
|         u1.Job_Category__c = '销售服务'; | 
|         u1.Province__c = '東京'; | 
|         insert u1; | 
|   | 
|   | 
|         User u2 = new User(Test_staff__c = true); | 
|         u2.LastName = '_サンブリッジ'; | 
|         u2.FirstName = 'い'; | 
|         u2.Batch_User__c = true; | 
|         u2.Alias = 'い'; | 
|         u2.Email = 'olympusTest02@sunbridge.com'; | 
|         u2.Username = 'olympusTest02@sunbridge.com' + nowTimeLong; | 
|         u2.CommunityNickname = 'い'; | 
|         u2.Work_Location__c = '北京'; | 
|         u2.IsActive = true; | 
|         u2.EmailEncodingKey = 'ISO-2022-JP'; | 
|         u2.TimeZoneSidKey = 'Asia/Tokyo'; | 
|         u2.LocaleSidKey = 'ja_JP'; | 
|         u2.LanguageLocaleKey = 'ja'; | 
|         u2.ProfileId = System.Label.ProfileId_SystemAdmin; | 
|         u2.Job_Category__c = '销售推广'; | 
|         u2.Province__c = '東京'; | 
|         insert u2; | 
|         Campaign cam = new Campaign(); | 
|         cam.Name = 'cam'; | 
|         cam.Name2__c = '1234'; | 
|         cam.Meeting_Type__c = '赞助会'; | 
|         cam.Implementation_Purpose__c = '产品推广'; | 
|         cam.WorkshopPlace__c = '测试地址'; | 
|         cam.Workshop_category__c = '普通学会/会议'; | 
|         cam.Society_Type__c = '全国'; | 
|         cam.Open_scope__c = '全国'; | 
|         cam.Sponsor_Ones_Post__c = '消化呼吸本部'; | 
|         cam.Is_LendProduct__c = '是'; | 
|         cam.HostName__c = '测试主办方'; | 
|         cam.cooperatorCompany__c = '测试承办方'; | 
|         cam.OCM_MP_Admin_assistant__c = user.Id; | 
|         cam.OwnerId = user.Id; | 
|         cam.Num__c = 'MT-GI-202201-5793'; | 
|         cam.RecordTypeId = rectCam.Id; | 
|         cam.StartDate = Date.today().addDays(-15); | 
|         cam.EndDate = Date.today().addDays(18); | 
|         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; | 
|         upsert cam;*/ | 
| // ---------------------------------------------------------------------- | 
| //         String flag='NG2'; | 
| //         String d1='产品试用'; | 
| //         String dept='医疗华北营业本部'; | 
| //         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.CommunityNickname = 'う'; | 
| //         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 = dept; | 
| //         user.Use_Start_Date__c = Date.today().addMonths(-6); | 
| //         insert user; | 
| //         // System.runAs(new User(Id = Userinfo.getUserId())) { | 
| //         //     insert user; | 
| //         // } | 
| // ---------------------------------------------------------------------- | 
|   | 
|          // 省 | 
|          // Address_Level__c al = new Address_Level__c(); | 
|          // al.Name = '東京'; | 
|          // al.Level1_Code__c = 'CN-99'; | 
|          // al.Level1_Sys_No__c = '999999'; | 
|          // insert al; | 
|          // // 市 | 
|          // Address_Level2__c al2 = new Address_Level2__c(); | 
|          // al2.Level1_Code__c = 'CN-99'; | 
|          // al2.Level1_Sys_No__c = '999999'; | 
|          // al2.Level1_Name__c = '東京'; | 
|          // al2.Name = '渋谷区'; | 
|          // al2.Level2_Code__c = 'CN-9999'; | 
|          // al2.Level2_Sys_No__c = '9999999'; | 
|          // al2.Address_Level__c = al.id; | 
|          // insert al2; | 
|          // 病院を作る | 
|          // Account hospital = new Account(); | 
|          // // hospital.recordtypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); | 
|          // hospital.Name = 'test hospital'; | 
|          // hospital.Is_Active__c = '有効'; | 
|          // hospital.Attribute_Type__c = '卫生部'; | 
|          // hospital.Speciality_Type__c = '综合医院'; | 
|          // hospital.Grade__c = '一级'; | 
|          // hospital.OCM_Category__c = 'SLTV'; | 
|          // hospital.Is_Medical__c = '医疗机构'; | 
|          // // hospital.State_Master__c = al.id; | 
|          // // hospital.City_Master__c = al2.id; | 
|          // hospital.Town__c = '东京'; | 
|          // insert hospital;    | 
|          // Account[] strategicDep = [SELECT ID, Name FROM Account WHERE recordType.DeveloperName = 'Department_Class_OTH']; | 
|          // 診療科を作る | 
|          | 
| // ================================================================================================== | 
| //         OCM_Management_Province__c mp1 = new OCM_Management_Province__c(); | 
| //         mp1.Name = '其他'; | 
| //         mp1.Province__c = '北京市'; | 
| //         mp1.Window1__c = user.Id; | 
| //         insert mp1; | 
|   | 
| //         StaticParameter.EscapeCampain =false; | 
| //         StaticParameter.shareToOSCMFlag = false;  | 
| //         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 = System.label.RecordType_CampaignService; | 
| //         cam.OwnerId = user.Id; | 
| //         insert cam; | 
| // ================================================================================================== | 
|   | 
|         // Campaign cam1 = new Campaign(); | 
|         // cam1.Name = 'test campaign'; | 
|         // cam1.StartDate = Date.today().addDays(15); | 
|         // cam1.EndDate = Date.today().addDays(18); | 
|         // cam1.Name2__c = '1234'; | 
|         // cam1.Status = '申请中'; | 
|         // cam1.Mailflg_after45__c = true; | 
|         // cam1.Mailflg_cancel__c = true; | 
|         // cam1.Mailflg_before15__c = true; | 
|         // cam1.Mailflg_before7__c = true; | 
|         // cam1.Mailflg_after3__c = true; | 
|         // cam1.HostName__c = '1'; | 
|         // cam1.cooperatorCompany__c = '1'; | 
|         // insert cam1; | 
|   | 
|   | 
|   | 
|         // BatchIF_Log__c iflog = new BatchIF_Log__c(); | 
|         // iflog.Log__c = '{"GeDatas":{"GeData":[{"WorkshopPlace":"上海红塔豪华精选酒店上海市 东方路889号","StateMaster":null,"StartDate":"20210422","OfficeCategory":null,"Num":"MT-GI-202104-5512","Name":"第十四届中国高端医疗产业发展论坛 (2021/04/22 - 2021/04/23)","MeetingType":"赞助会","HostName":null,"ExpectedOlympusAttendance":null,"ExpectedHcpAttendance":null,"EndDate":"20210423","CooperatorCompany":null,"CityMaster":null,"BudgetType":"产品推广","ActivityTypeName":null}]}}'; | 
|         // iflog.Type__c = '703test'; | 
|         // insert iflog; | 
|     // } | 
|     private static User getUser() { | 
|         String flag='NG2'; | 
|         String d1='产品试用'; | 
|         String dept='医疗华北营业本部'; | 
|         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.CommunityNickname = 'う'; | 
|         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 = dept; | 
|         user.Use_Start_Date__c = Date.today().addMonths(-6); | 
|         // insert user; | 
|          System.runAs(new User(Id = Userinfo.getUserId())) { | 
|             insert user; | 
|         } | 
|         return user; | 
|     } | 
|     @isTest | 
|     static void testCallOut1() { | 
|         OCM_Management_Province__c mp1 = new OCM_Management_Province__c(); | 
|         mp1.Name = '其他'; | 
|         mp1.Province__c = '北京市'; | 
|         mp1.Window1__c = getUser().Id; | 
|         insert mp1; | 
|   | 
|         StaticParameter.EscapeCampain =false; | 
|         StaticParameter.shareToOSCMFlag = false;  | 
|         Campaign cam = new Campaign(); | 
|         cam.Name = 'test011111 (2021/12/15 - 2021/12/20)'; | 
|         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.IF_Approved__c = true; | 
|         cam.cooperatorCompany__c = '2222'; | 
|         cam.RecordTypeId = System.label.RecordType_CampaignService; | 
|         // cam.OwnerId = getUser().Id; | 
|         cam.Num__c = 'MT-GI-202112-5772'; | 
| // StartDate | 
| // EndDate | 
|         cam.Implementation_Purpose__c = '新产品上市'; | 
|         cam.OfficeCategory__c = null; | 
|         cam.Meeting_Type__c = '主办会'; | 
|         cam.Activity_Type_Name__c = null; | 
|         cam.State_Master__r = null; | 
|         cam.City_Master__r = null; | 
|         cam.WorkshopPlace__c = '北京'; | 
|         cam.Expected_Olympus_Attendance__c = null; | 
|         cam.Expected_Hcp_Attendance__c = null; | 
|         insert cam; | 
|          | 
|         List < Campaign > camList = [select Id,IF_Approved__c from Campaign]; | 
|         // System.assertEquals(camList.size(),1); | 
|         System.assertEquals(camList[0].IF_Approved__c,true); | 
|   | 
|         Test.startTest(); | 
|   | 
|         List < Id > idList = new List < Id > (); | 
|         for (Campaign cam1: camList) { | 
|             idList.add(cam1.Id); | 
|         } | 
|   | 
|         BatchIF_Log__c iflog = new BatchIF_Log__c(); | 
|         iflog.Log__c = '{"Monitoring":{"TransmissionDateTime":"20220209150125","Text":"","Tag":"MSGH","Sender":"SFDC","Receiver":"OBPM","NumberOfRecord":"1","MessageType":"NFM703","MessageGroupNumber":"20220209150125"},"GeData":[{"WorkshopPlace":"北京","StateMaster":null,"StartDate":"2021-12-15","OfficeCategory":null,"Num":"MT-GI-202112-5772","Name":"test011111 (2021/12/15 - 2021/12/20)","MeetingType":"主办会","HostName":"1","ExpectedOlympusAttendance":null,"ExpectedHcpAttendance":null,"EndDate":"2021-12-20","CooperatorCompany":"2222","CityMaster":null,"BudgetType":"新产品上市","ActivityTypeName":null}]}'; | 
|         iflog.Type__c = 'NFM703'; | 
|         // insert iflog; | 
|         // BatchIF_Log__c iflog = new BatchIF_Log__c(); | 
|         iflog.Log__c += 'test start \n'; | 
|         insert iflog; | 
|          | 
|         // System.assertEquals(iflog.retry_cnt__c,0); | 
|         NFM703Controller.executeNotFuture(iflog.Id, idList); | 
|   | 
|         // List<BatchIF_Log__c> rowbl = [Select Id, Log__c, | 
|   //                                     ErrorLog__c | 
|   //                                     from BatchIF_Log__c]; | 
|   //       System.assertEquals(1, rowbl.size()); | 
|   | 
|   //       rowbl[0].retry_cnt__c = 1; | 
|   //       update rowbl; | 
|   | 
|   //       NFM703Controller.execute(rowbl[0],iflog); | 
|   | 
|   //       List<BatchIF_Log__c> bl = [Select Id, Is_Error__c, | 
|   //                                  Type__c, Log__c, ErrorLog__c, retry_cnt__c | 
|   //                                  from BatchIF_Log__c | 
|   //                                  where Id = :rowbl[0].id]; | 
|   //       System.assertEquals(1, bl.size()); | 
|   //       System.assertEquals(0, bl[0].retry_cnt__c); | 
|         Test.stopTest(); | 
|     } | 
| } |