@isTest private class OpportunityLightingButtonControllerTest { @TestSetup static void makeData(){ List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; // if (rectCo.size() == 0) { // return; // } List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科']; // if (rectSct.size() == 0) { // return; // } List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // if (rectDpt.size() == 0) { // return; // } List rectAgency = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店']; // if (rectAgency.size() == 0) { // return; // } // テストデータ Account company = new Account(); company.RecordTypeId = rectCo[0].Id; company.Name = 'NFM206TestCompany'; insert company; Account section = new Account(); section.RecordTypeId = rectSct[0].Id; section.Name = '*'; section.Department_Class_Label__c = '消化科'; section.ParentId = company.Id; section.Hospital_Department_Class__c = company.Id; insert section; Account depart = new Account(); depart.RecordTypeId = rectDpt[0].Id; depart.Name = '*'; depart.Department_Name__c = 'NFM206TestDepart'; depart.ParentId = section.Id; depart.Department_Class__c = section.Id; depart.Hospital__c = company.Id; insert depart; Date today = Date.today(); Date lastDate1 = Date.today().addMonths(1); Date lastDate2 = Date.today().addMonths(2); Date lastDate3 = Date.today().addMonths(3); Account account2 = new Account(); account2.Name = 'test1经销商'; account2.RecordTypeId = rectAgency[0].id; insert account2; Opportunity opp = new Opportunity(); opp.AccountId = depart.Id; opp.Department_Class__c = section.Id; opp.Hospital__c = company.Id; opp.SAP_Send_OK__c = false; opp.Name = 'GZ-SP-NFM009_0'; opp.agency1__c = account2.Id; opp.Trade__c = '内貿'; opp.StageName = '出荷'; opp.CloseDate = lastDate1; opp.Close_Forecasted_Date__c = lastDate1; opp.Stock_apply_status__c = '申请中'; insert opp; } static testMethod void test1(){ List oppList = new List(); oppList = [select Id from Opportunity limit 1]; Test.startTest(); OpportunityLightingButtonController.queryForEditLostButton(oppList[0].Id); OpportunityLightingButtonController.initForPredictedDateChangeButton(oppList[0].Id); OpportunityLightingButtonController.initForAgencyAuthorizeButton(oppList[0].Id); OpportunityLightingButtonController.initForLoseBidButton(oppList[0].Id); OpportunityLightingButtonController.initForOLYwinBidButton(oppList[0].Id); OpportunityLightingButtonController.initForCreateEventButton(oppList[0].Id); OpportunityLightingButtonController.initForBeforeOPDPDFBtnButton(oppList[0].Id); OpportunityLightingButtonController.initFoBeforeOPDPDFBtnSISButton(oppList[0].Id); OpportunityLightingButtonController.initForRequestDBButton(oppList[0].Id); OpportunityLightingButtonController.initForCancelReportButton(oppList[0].Id); OpportunityLightingButtonController.initForLostReportButton(oppList[0].Id); OpportunityLightingButtonController.initForLexQuoteEntryNewbotton(oppList[0].Id); OpportunityLightingButtonController.initForQuotationRequestButton(oppList[0].Id); OpportunityLightingButtonController.initForStockApplyButton(oppList[0].Id); OpportunityLightingButtonController.initForQuotationProductNewButton(oppList[0].Id); OpportunityLightingButtonController.initForCopyWithAssetButton(oppList[0].Id); OpportunityLightingButtonController.initForNewOpportunityAgencyButton(oppList[0].Id); OpportunityLightingButtonController.initForOpporSpliteButton(oppList[0].Id); OpportunityLightingButtonController.initForCreateActivityButton(oppList[0].Id); OpportunityLightingButtonController.initForAssignTaskButtonButton(oppList[0].Id); OpportunityLightingButtonController.initForChangeContractTypeButton(oppList[0].Id); OpportunityLightingButtonController.initForSpecilaApplyCreateButton(oppList[0].Id); OpportunityLightingButtonController.initForSpecilaApplyCreateAchButton(oppList[0].Id); OpportunityLightingButtonController.initForNewOpportunityFileButton(oppList[0].Id); OpportunityLightingButtonController.updateForAgencyAuthorizeButton(oppList[0].Id); OpportunityLightingButtonController.updateForLoseBidButton(oppList[0].Id); OpportunityLightingButtonController.updateForOLYwinBidButton(oppList[0].Id); OpportunityLightingButtonController.updateForStockApplyButton(oppList[0].Id,true); OpportunityLightingButtonController.queryForPredictedDateChangeButton(oppList[0].Id); OpportunityLightingButtonController.queryForLoseBidButton(oppList[0].Id); OpportunityLightingButtonController.queryForOLYwinBidButton(oppList[0].Id); OpportunityLightingButtonController.queryForCancelReportButton(oppList[0].Id); OpportunityLightingButtonController.queryForQuotationRequestButton(oppList[0].Id); OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecords(oppList[0].Id,''); OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecords2(oppList[0].Id); OpportunityLightingButtonController.submitProcess(oppList[0].Id); OpportunityLightingButtonController.getUserIdByName(oppList[0].Id); OpportunityLightingButtonController.getProfileIdByName(oppList[0].Id); OpportunityLightingButtonController.queryForProfileId(); OpportunityLightingButtonController.initCopy(oppList[0].Id); OpportunityLightingButtonController.forma(oppList[0].Id); OpportunityLightingButtonController.changeTrade(oppList[0].Id); OpportunityLightingButtonController.queryQuote(''); OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecTypeList('Product','',true); Test.stopTest(); } static testMethod void test2(){ OCMManagementProvinceWebService.updateOpportunity(); } }