@isTest private class AgencyPersonCmpTest { public static Account account1 = new Account(); public static Account account2 = new Account(); public static Contact contact1 = new Contact(); public static Contact contact2 = new Contact(); public static User user = new User(); public static Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c(); public static Agency_Contact__c agency_contact = new Agency_Contact__c(); public static ProductTypes__c product_types = new ProductTypes__c(); public static Agency_Opportunity__c agency_opportunity = new Agency_Opportunity__c(); private static void testInit() { // 取引先 account1.Name = 'test1医院'; account1.RecordTypeId = '01210000000QemG'; insert account1; account2.Name = 'test1经销商'; account2.RecordTypeId = '01210000000Qem1'; insert account2; // 取引先責任者 contact1.AccountId = account1.Id; contact1.FirstName = '責任者'; contact1.LastName = 'test1医院'; insert contact1; contact2.AccountId = account2.Id; contact2.FirstName = '責任者'; contact2.LastName = 'test1经销商'; insert contact2; // ユーザー Profile p = [select Id from Profile where Name = '901_经销商周报']; 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.Alias = 'テユ'; user.CommunityNickname = 'テストユーザー'; insert user; // 代理店医院 agency_hospital_link.Name = 'test1代理店医院'; agency_hospital_link.Hospital__c = account1.Id; agency_hospital_link.Agency__c = account2.Id; agency_hospital_link.OwnerId = user.Id; insert agency_hospital_link; // 先生 agency_contact.Name = 'test1医院先生'; agency_contact.Doctor_Division1__c = '院长'; agency_contact.Type__c = '医生'; agency_contact.Agency_Hospital__c = agency_hospital_link.Id; agency_contact.OwnerId = user.Id; insert agency_contact; // 製品区分 product_types.Name = '製品区分1'; product_types.OwnerId = user.Id; product_types.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT'; insert product_types; // 引合 agency_opportunity.RecordTypeId = [select Id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id; agency_opportunity.Name = '引合1'; agency_opportunity.Hospital_Target__c = account1.Id; agency_opportunity.Agency__c = account2.Id; agency_opportunity.Agency_Hospital__c = agency_hospital_link.Id; agency_opportunity.StageName__c = '还没申请预算'; agency_opportunity.OwnerId = user.Id; agency_opportunity.NewOpportunity_Agency_Apply_Status__c = '批准'; insert agency_opportunity; } @isTest static void test_method_one() { testInit(); // 病院リスト取得 System.runAs(user) { AgencyPersonCmp.getcontactdata(agency_opportunity.id); string test = AgencyPersonCmp.saveagencyOppContact(agency_opportunity.id,contact1.id); } } //@isTest static void test_method_two() { // // Implement test code //} }