@isTest private class NFM620RestBatchTest { static testMethod void testMethod1() { // 省 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 = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; 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 parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account dep = new Account(); dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; dep.Name = 'test dep'; dep.AgentCode_Ext__c = '9999998'; dep.ParentId = strategicDep[0].Id; dep.Department_Class__c = strategicDep[0].Id; dep.Hospital__c = hospital.Id; insert dep; //客户人员を作る Contact contact2 = new Contact(); contact2.UnifiedI_Contact_ID__c = '001'; contact2.AccountId = dep.Id; contact2.FirstName = '张'; contact2.LastName = '小花'; insert contact2; Contact contact = [select ID,UnifiedI_Contact_ID__c from Contact limit 1]; //学会を作る List recordTypeIds = new List(); recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId()); //学会/会议 Campaign campaign01 = new Campaign(); campaign01.RecordTypeId = recordTypeIds.get(0); campaign01.StartDate = Date.today(); campaign01.Name = 'mzyTest01'; campaign01.EndDate = Date.today().addDays(1); campaign01.Status = '公开中'; campaign01.Is_LendProduct__c = '是'; campaign01.Internal_in_charge_province__c = al.id; //备品出借省 campaign01.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期 campaign01.LoadNum__c = '3D主机*2; BF-290镜子*4; CV-170*1; CV-190*6;'; //计划出借备品信息 campaign01.HostName__c = '主办方'; campaign01.cooperatorCompany__c = '1'; insert campaign01; //商品咨询单を作る Inquiry_form__c inquiryform = new Inquiry_form__c(); inquiryform.Status__c ='未跟进'; inquiryform.Company__c ='北京某某某测试公司'; inquiryform.Family_Name__c ='靳'; inquiryform.Opportunity_Division__c = '询价'; inquiryform.Reasons_options__c ='客户不存在'; inquiryform.Phone__c = '13844756322'; inquiryform.Product1__c = '超声'; inquiryform.Request1__c = '需要报价'; inquiryform.Campaign__c = campaign01.Id; inquiryform.ContactId__c = contact.UnifiedI_Contact_ID__c; insert inquiryform; Id execBTId = Database.executeBatch(new NFM620RestBatch(),1); } }