@isTest private class LightningUtilTest { 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_Report_Header__c agency_report_header = new Agency_Report_Header__c(); // 经销商活动周报导入 update by vivek start public static ProductTypes__c product_types1 = new ProductTypes__c(); public static ProductTypes__c product_types2 = new ProductTypes__c(); public static ProductTypes__c product_types3 = new ProductTypes__c(); // 经销商活动周报导入 update by vivek end public static Agency_Opportunity__c agency_opportunity = new Agency_Opportunity__c(); public static Agency_Opportunity__c agency_opportunity2 = new Agency_Opportunity__c(); public static OlympusCalendar__c olympus_calendar = new OlympusCalendar__c(); public static String report_id; public static String report_header_id; @testSetup static void setUp(){ TestDataUtility.CreatePIPolicyConfigurations( new string[]{'Agency_Contact__c','Contact'}); } /** * @description AgencyOpportunityHandlerテスト */ // static testMethod void unitTestAgencyOpportunityHandler() { // Oly_TriggerHandler.bypass('AgencyReportHeaderHandler'); // Oly_TriggerHandler.bypass('AgencyHospitalHandler'); // // StaticParameter.EscapeAccountTrigger = true; // // StaticParameter.EscapeNFM007Trigger = true; // // StaticParameter.EscapeOpportunityBefUpdTrigger = true; // // StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; // // StaticParameter.EscapeSyncOpportunityTrigger = true; // // StaticParameter.EventOpportunityPileUpExeFlg = true; // // StaticParameter.EscapeNFM001AgencyContractTrigger = true; // // StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; // // StaticParameter.EscapeLeadTrigger = true; // // StaticParameter.EscapeOpportunityownerUpdate = true; // // ControllerUtil.EscapeNFM001Trigger = true; // // ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true; // // StaticParameter.EscapeNFM001Trigger = true; // // StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; // // 取引先 // account1.Name = 'test1医院'; // account1.RecordTypeId = '01210000000QemG'; // insert account1; // List < Account > acclist = [select RecordTypeId, Name // from Account // ]; // account2.Name = 'test1经销商'; // account2.RecordTypeId = '01210000000Qem1'; // insert account2; // List < Account > acc2list = [select RecordTypeId, Name // from Account // ]; // // System.assertEquals(2, acc2list.size()); // // 取引先責任者 // contact1.AccountId = account1.Id; // contact1.FirstName = '責任者'; // contact1.LastName = 'test1医院'; // insert contact1; // List < Contact > contactlist = [select Id, FirstName // from Contact // ]; // System.assertEquals('責任者', contactlist[0].FirstName); // 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_经销商周报']; // 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' + System.now().millisecond(); // user.Alias = 'テユ'; // user.CommunityNickname = 'tu' + System.now().millisecond(); // user.SalesManager__c = UserInfo.getUserId(); // insert user; // List < user > users = [select Id, Name, LastName, FirstName from User where LastName = 'テスト']; // System.assertEquals('ユーザー', users[0].FirstName); // System.runAs(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; // agency_hospital_link.Agency_Campaign_Obj__c = true; // insert agency_hospital_link; // List < Agency_Hospital_Link__c > agencylist = [select Id, Name from Agency_Hospital_Link__c where Id = : agency_hospital_link.Id]; // System.assertEquals('test1医院', agencylist[0].Name); // Id rtId = Schema.SObjectType.Agency_Opportunity__c.getRecordTypeInfosByDeveloperName().get('Opportunity').getRecordTypeId(); // agency_opportunity.Agency_Person__c = contactlist[0].id; // agency_opportunity.RecordTypeId = rtId; // agency_opportunity.Name = '引合'; // 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 = '批准'; // agency_opportunity.Department_Cateogy__c = 'ET'; // agency_opportunity.Sales_Manager__c = user.Id; // insert agency_opportunity; // List < Agency_Opportunity__c > opportunitylist = [select Id, Name from Agency_Opportunity__c]; // System.assertEquals(1, opportunitylist.size()); // rtId = Schema.SObjectType.Agency_Opportunity__c.getRecordTypeInfosByDeveloperName().get('Opportunity').getRecordTypeId(); // agency_opportunity2.Agency_Person__c = contact2list[0].id; // agency_opportunity2.RecordTypeId = rtId; // agency_opportunity2.Name = '引合2'; // agency_opportunity2.Hospital_Target__c = account1.Id; // agency_opportunity2.Agency__c = account2.Id; // // agency_opportunity2.OwnerId = user.Id; // agency_opportunity2.NewOpportunity_Agency_Apply_Status__c = '草案中'; // agency_opportunity2.Department_Cateogy__c = 'GS'; // agency_opportunity2.Sales_Manager__c = UserInfo.getUserId(); // insert agency_opportunity2; // System.debug(agency_opportunity2.Name); // List < Agency_Opportunity__c > opportunitylist2 = [select Id, Name from Agency_Opportunity__c]; // System.assertEquals(2, opportunitylist2.size()); // olympus_calendar.Date__c = Date.valueOf('2017-04-10'); // // olympus_calendar.OwnerId = user.Id; // insert olympus_calendar; // List < OlympusCalendar__c > olympusCalendarlist = [select Id, Name, Date__c from OlympusCalendar__c]; // System.assertEquals(Date.valueOf('2017-04-10'), olympusCalendarlist[0].Date__c); // List < Agency_Opportunity__c > opportunity_data = WeeklyReportCmp.selectOpportunityByIdAndHospitalLinkId(agency_opportunity.Id, agency_hospital_link.Id); // List < Agency_Opportunity__c > agencyopportunity = [select Id, Name, Agency__c, Agency_ID__c, Owner_Agency_ID__c, // Agency_Hospital_All__c, Agency_Hospital__c, Agency_Hospital_Target__c // from Agency_Opportunity__c // ]; // System.assertEquals('::' + agency_opportunity.Name, agencyopportunity[0].Name); // System.assertEquals(agency_opportunity.Agency__c, agencyopportunity[0].Owner_Agency_ID__c); // System.assertEquals(agency_opportunity.Agency_Hospital_All__c, agencyopportunity[0].Agency_Hospital_Target__c); // } // } /** * @description AgencyReportHandlerテスト */ // static testMethod void unitTestAgencyReportHandler() { // LightningUtil.ControllerUtil(); // // 取引先 // 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; // Date sDate = Date.newInstance(2017, 4, 10); // //String cc = [select Id,Country__c from User where Id = :Userinfo.getUserId()].Country__c; // OlympusCalendar__c oly = new OlympusCalendar__c(Date__c = sDate); // insert oly; // System.runAs(user) { // // 週報ヘッダー作成 // String name = 'テスト ユーザー'; // String s_date = '2017-04-10'; // String s_agency = contact2.Id; // String head_key = contact2.Id + ':20170410'; // report_header_id = WeeklyReportCmp.createReportHeader(name, s_date, s_agency, head_key); // Agency_Report_Header__c data = [select Id, Name, Agency__c, Owner_Agency_ID__c, Agency_ID__c, Week__c, Agency_Person2__c, HeaderInputKey__c, OlympusDate__r.Date__c from Agency_Report_Header__c where HeaderInputKey__c = : head_key]; // LightningUtil.upsertAgencyReportHeader(data); // System.assertEquals(data.Agency__c, data.Owner_Agency_ID__c); // System.assertEquals(data.Agency_ID__c, String.valueOf(data.Owner_Agency_ID__c).substring(0, 15)); // } // } /** * @description unitTestAgencyAccountCmp1-2はAgencyAccountCmpテストです */ // static testMethod void unitTestAgencyAccountCmp1() { // testInit(); // // Implement test code // System.runAs(user) { // List < Agency_Contact__c > res = AgencyAccountCmp.getAccounts(); // System.assertEquals(2, res.size()); // } // } // static testMethod void unitTestAgencyAccountCmp2() { // // Implement test code // testInit(); // // Implement test code // System.runAs(user) { // List < Agency_Contact__c > res = AgencyAccountCmp.searchAccounts('', 'test1'); // System.assertEquals(1, res.size()); // } // } /** * @description unitTestWeeklyReportCmp1-3はWeeklyReportCmpテストです */ // static testMethod void unitTestWeeklyReportCmp1() { // // StaticParameter.EscapeOpportunityBefUpdTrigger = true; // // StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; // // StaticParameter.EscapeSyncOpportunityTrigger = true; // // StaticParameter.EscapeNFM001Trigger = true; // Oly_TriggerHandler.bypass('UserToContact'); // Oly_TriggerHandler.bypass('Oly_TriggerHandler'); // Oly_TriggerHandler.bypass('UserProfileHandler'); // saveAgencyReportTest(); // System.runAs(user) { // String date_str = '2017-04-10'; // String person_str = ''; // WeeklyReportCmp reports = WeeklyReportCmp.getReports(date_str, person_str); // List < Agency_Report__c > report = WeeklyReportCmp.getReportsById(report_id); // system.assertEquals(report_id, report[0].Id); // } // } // static testMethod void unitTestWeeklyReportCmp2() { // Oly_TriggerHandler.bypass('UserToContact'); // Oly_TriggerHandler.bypass('Oly_TriggerHandler'); // Oly_TriggerHandler.bypass('UserProfileHandler'); // saveAgencyReportTest(); // System.runAs(user) { // String Department_Cateogy = ''; // String Purpose_Type = ''; // String Agency_Report_Header = ''; // String Agency_Hospital = ''; // String Person_In_Charge2 = ''; // String doctor = ''; // String Submit_date = ''; // String Product_Category = ''; // String Result = ''; // String Opportunity = ''; // //fy 20220505 // String SupportNeedsc =''; // Department_Cateogy = 'GI'; // Purpose_Type = '询价挖掘-会议对应'; // Agency_Report_Header = report_header_id; // Agency_Hospital = agency_hospital_link.Id; // Person_In_Charge2 = contact2.Id; // doctor = agency_contact.Id; // Submit_date = '2017-04-10'; // Product_Category = product_types.Id; // Result = 'result_test'; // Opportunity = agency_opportunity.Id; // //fy 20220505 // SupportNeedsc ='维修备品'; // Test.startTest(); // // 週報編集 // Department_Cateogy = 'BF'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // Agency_Report__c data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // Department_Cateogy = 'GYN'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // Department_Cateogy = 'GS'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // Department_Cateogy = 'URO'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // Department_Cateogy = 'ENT'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // Department_Cateogy = 'ET'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // Department_Cateogy = 'OTH'; // report_id = WeeklyReportCmp.editAgencyReport(report_id, Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // } // } // static testMethod void unitTestWeeklyReportCmp3() { // testInit001(); // System.runAs(user) { // // 病院リスト取得 // WeeklyReportCmp test = WeeklyReportCmp.getalldata(); // System.assertNotEquals(test, null); // } // } static testMethod void unitTestWeeklyReportCmp4() { // 省 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.AccountId = dep.Id; contact2.FirstName = '責任者'; contact2.LastName = 'test1经销商'; insert contact2; Set setStr = new Set(); String str = String.valueOf(hospital.recordtypeId); setStr.add(str); LightningUtil.selectContact(contact2.Id); LightningUtil.getDeptListByRecordType(hospital.Id,setStr); // Test.startTest(); // WeeklyReportCmpTest.processData(); // Test.stopTest(); } private static void testInit() { StaticParameter.EscapeNFM007Trigger = true; ControllerUtil.EscapeNFM001Trigger = true; // 取引先 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 = account1.Id; contact2.FirstName = '責任者'; contact2.LastName = 'test2医院'; 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__c ac1 = new Agency_Contact__c(); ac1.Name = 'test1のび太'; ac1.Agency_Hospital__c = agency_hospital_link.Id; insert ac1; List < Account > depts = [select Id from Account where Hospital_Department_Class__c = : account1.Id]; Account dept = depts[0]; Agency_Contact__c ac2 = new Agency_Contact__c(); ac2.Name = 'test2のび太'; ac2.Department_Class__c = dept.Id; insert ac2; } // @isTest static void saveAgencyReportTest() { // Oly_TriggerHandler.bypass('UserToContact'); // Oly_TriggerHandler.bypass('Oly_TriggerHandler'); // Oly_TriggerHandler.bypass('UserProfileHandler'); // testInit001(); // System.runAs(user) { // String name = 'テスト ユーザー'; // String s_date = '2017-04-10'; // String s_agency = contact2.Id; // String head_key = contact2.Id + ':20170410'; // report_header_id = WeeklyReportCmp.createReportHeader(name, s_date, s_agency, head_key); // // 週報作成 // String Department_Cateogy = ''; // String Purpose_Type = ''; // String Agency_Report_Header = ''; // String Agency_Hospital = ''; // String Person_In_Charge2 = ''; // String doctor = ''; // String Submit_date = ''; // String Product_Category = ''; // String Result = ''; // String Opportunity = ''; // String SupportNeedsc = ''; // Department_Cateogy = 'GI'; // Purpose_Type = '询价挖掘-会议对应'; // Agency_Report_Header = report_header_id; // Agency_Hospital = agency_hospital_link.Id; // Person_In_Charge2 = contact2.Id; // doctor = agency_contact.Id; // Submit_date = '2017-04-10'; // Product_Category = product_types.Id; // Result = '一般'; // Opportunity = agency_opportunity.Id; // //fy 20220505 // SupportNeedsc = '维修备品'; // report_id = WeeklyReportCmp.saveAgencyReport(Department_Cateogy, Purpose_Type,SupportNeedsc, Agency_Report_Header, Agency_Hospital, Person_In_Charge2, doctor, Submit_date, Product_Category, '', '', Result, Opportunity, '', '', '', '', Submit_date); // Agency_Report__c data = [select Id, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__c, // Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, Opportunity__c from Agency_Report__c where Id = : report_id // ]; // System.assertEquals(Department_Cateogy, data.Department_Cateogy__c); // System.assertEquals(Purpose_Type, data.Purpose_Type__c); // System.assertEquals(Agency_Report_Header, data.Agency_Report_Header__c); // System.assertEquals(Agency_Hospital, data.Agency_Hospital__c); // System.assertEquals(Person_In_Charge2, data.Person_In_Charge2__c); // System.assertEquals(doctor, data.doctor2__c); // System.assertEquals(Date.valueOf(Submit_date), data.Submit_date__c); // //System.assertEquals(Product_Category, data.Product_Category__c); // System.assertEquals(Result, data.Result__c); // System.assertEquals(Opportunity, data.Opportunity__c); // } // } private static void testInit001() { // 取引先 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; agency_hospital_link.Agency_Campaign_Obj__c = true; 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; // 经销商活动周报导入 update by vivek start // agency_contact.Hospital_ID18__c = agency_hospital_link.Id; // 经销商活动周报导入 update by vivek end 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; // 经销商活动周报导入 update by vivek start product_types1.OwnerId = user.Id; product_types1.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT'; product_types1.Name = '170系统'; product_types1.OPD_Flg__c = true; insert product_types1; product_types2.OwnerId = user.Id; product_types2.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT'; product_types2.Name = 'EUS系统'; product_types2.SIS_Flg__c = true; insert product_types2; product_types3.OwnerId = user.Id; product_types3.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT'; product_types3.Name = 'CHF胆道镜'; insert product_types3; // 经销商活动周报导入 update by vivek end // 引合 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; // オリンパスカレンダー olympus_calendar.Date__c = Date.valueOf('2017-04-10'); olympus_calendar.OwnerId = user.Id; insert olympus_calendar; } // } @isTest private static void test01(){ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; system.runAs(thisUser){ testInit(); LightningUtil.ControllerUtil(); User loginUser = LightningUtil.loginUserId(); LightningUtil util = new LightningUtil(); Set hospitalSet = new Set(); Set ahospitalSet = new Set(); String hosStr = ''; String conStr = ''; LightningUtil.selectAgencyPerson(); LightningUtil.selectAgencyPerson01(); LightningUtil.selectAgencyPerson02(); LightningUtil.selectAgencyPerson03(); LightningUtil.selectOCMAgencyContact(hospitalSet,ahospitalSet); Date today = Date.today(); LightningUtil.getRecordTypeId('GI'); LightningUtil.getRecordTypeId('BF'); LightningUtil.getRecordTypeId('GYN'); LightningUtil.getRecordTypeId('GS'); LightningUtil.getRecordTypeId('URO'); LightningUtil.getRecordTypeId('ENT'); LightningUtil.getRecordTypeId('ET'); LightningUtil.getRecordTypeId('OTH'); List conStr1 = new List(); String testStrin = 'Ab'; LightningUtil.searchOCMAgencyContact(hospitalSet,ahospitalSet,hosStr,''); LightningUtil.searchOCMAgencyContact(hospitalSet,ahospitalSet,hosStr,conStr1); conStr1.add(testStrin); LightningUtil.searchOCMAgencyContact(hospitalSet,ahospitalSet,hosStr,conStr1); Agency_Contact__c data = null; LightningUtil.insertAgencyContact(data); LightningUtil.selectAgencyReportById01('123'); List conMList = new List(); LightningUtil.selectMAgencyReport01(today,today,conMList); LightningUtil.selectMAgencyReport(today,today,conMList); LightningUtil.selectAgencyReportById('123'); LightningUtil.selectAgencyReport(today,''); LightningUtil.selectAgencyReport(today,'123'); LightningUtil.selectAgencyReport01(today,''); LightningUtil.selectAgencyReport01(today,'123'); LightningUtil.updateAccMaxActivityDate(agency_hospital_link.Id,today); LightningUtil.getAccRecordType (new string[]{'Agency_Contact__c','Contact'}); // LightningUtil.selectAgencyContactList('a2T100000016PttEAE'); // String ids =String.valueof(contact1.Id); // String key =ids+':20170410'; // String aa =RetrospectiveWeeklyReportController.createReportHeader('','2017-04-10',ids,key); // RetrospectiveWeeklyReportController.editAgencyReport('','消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',aa,String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','1','1','1','2017-04-10'); } } @IsTest private static void test04(){ Agency_Contact__c ac1= new Agency_Contact__c(); ac1.id = 'a2R100000007rZYEAY'; LightningUtil.insertAgencyContact(ac1); LightningUtil.insertAgencyContact(agency_contact); agency_opportunity.Name = '123'; LightningUtil.insertAgencyContact(agency_contact); LightningUtil.updateAgencyOpportunity(agency_opportunity); LightningUtil.selectOpportunityByIdAndHospitalLinkId(agency_opportunity.Id,agency_hospital_link.Id); } }