| | |
| | | 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) { |
| | | // 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); |
| | | // 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); |
| | | } |
| | | } |
| | | // 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'; |
| | |
| | | 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 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(); |