@isTest private class NewDBPaymentPlanLoadControllerTets { private static Account dep = null; private static Account hospital = null; private static List strategicDep = null; static testMethod void test_method_one(){ Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; // 病院を作る hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; insert hospital; // 戦略科室を得る strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI']; // 診療科を作る dep = new Account(); dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id; dep.Name = 'test dep'; dep.ParentId = strategicDep[0].Id; dep.Department_Class__c = strategicDep[0].Id; dep.Hospital__c = hospital.Id; insert dep; List UserList = new List(); User MacOwner = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com',Job_Category__c = '销售服务', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); UserList.add(MacOwner); User MacOwner1 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner2', Alias = 'hp', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com',Job_Category__c = '销售服务', Username = 'olympus_hpowner@sunbridge.com2', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); UserList.add(MacOwner1); User MacOwner2 = new User(Test_staff__c = true, LastName = 'hp3', FirstName = 'owner3', Alias = 'hp', CommunityNickname = 'hpOwner3', Email = 'olympus_hpowner@sunbridge.com',Job_Category__c = '销售服务', Username = 'olympus_hpowner@sunbridge.com3', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); UserList.add(MacOwner2); User MacOwner3 = new User(Test_staff__c = true, LastName = 'hp4', FirstName = 'owner4', Alias = 'hp', CommunityNickname = 'hpOwner4', Email = 'olympus_hpowner@sunbridge.com',Job_Category__c = '销售服务', Username = 'olympus_hpowner@sunbridge.com4', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); UserList.add(MacOwner3); User MacOwner4 = new User(Test_staff__c = true, LastName = 'hp5', FirstName = 'owner5', Alias = 'hp', CommunityNickname = 'hpOwner5', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com5',Job_Category__c = '销售服务', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); UserList.add(MacOwner4); User MacOwner5 = new User(Test_staff__c = true, LastName = 'hp5', FirstName = 'owner6', Alias = 'hp', CommunityNickname = 'hpOwner6', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com6',Job_Category__c = '销售服务', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); UserList.add(MacOwner5); insert UserList; MaintanceContractPack__c target01 = new MaintanceContractPack__c(); target01.Name = 'TestDBMC'; target01.SalesOfficeCode_selection__c = '北京RC'; target01.Contract_Type__c = '上限合同'; target01.Is_Standard_Contract__c = '是'; target01.Inspection_Time__c = '1'; target01.Total_Payment_Time__c = '1'; target01.Term_Of_Payment__c = '多次付款'; target01.Contract_Start_Date__c = Date.today(); target01.Contract_End_Date__c = Date.today().addMonths(+12); target01.URF_Contract__c = false; target01.Contract_Range__c = Decimal.valueOf('12'); insert target01; Maintenance_Contract__c target02 = new Maintenance_Contract__c(); target02.Department__c = dep.Id; target02.Name = 'TestMAC'; target02.Contract_Start_Date__c = Date.today(); target02.Contract_End_Date__c = Date.today().addMonths(+12); target02.Service_Contract_Staff__c = MacOwner.id; target02.Is_Standard_Contract__c = '是'; target02.Inspection_Time__c = '1'; target02.Total_Payment_Time__c = '1'; target02.Term_Of_Payment__c = '多次付款'; target02.MaintanceContractPack__c = target01.Id; target02.Payment_Plan_Sum_First__c = 50; target02.Payment_Plan_Sum_Second__c = 50; target02.Payment_Plan_Sum_Third__c = 50; target02.Payment_Plan_Sum_Forth__c = 50; target02.Payment_Plan_Sum_Fifth__c = 50; target02.Payment_Plan_Sum_Sixth__c = 50; target02.Contract_Amount__c = 300; target02.Contract_Range__c = Decimal.valueOf('12'); insert target02; PageReference page = new PageReference('apex/NewDBPaymentPlanLoad?id=' + target01.Id ); System.Test.setCurrentPage(page); NewDBPaymentPlanLoadController DBppc = new NewDBPaymentPlanLoadController(); DBppc.init(); DBppc.save(); DBppc.init(); DBppc.PageMCEElement.Is_Standard_Contract__c = '是'; DBppc.PageMCEElement.Term_Of_Payment__c = '多次付款'; DBppc.PageMCEElement.Payment_Plan_Sum_First__c = 2000; DBppc.PageMCEElement.Payment_Plan_Date_First__c = Date.today(); target01.one_off_payment_agreed_period__c = '15'; DBppc.print(); DBppc.save(); DBppc.init(); DBppc.PageMCEElement.Is_Standard_Contract__c = '是'; DBppc.PageMCEElement.Term_Of_Payment__c = '多次付款'; DBppc.PageMCEElement.Small_Repair_Time__c = '5'; DBppc.PageMCEElement.Engineer_Name__c = '77777'; DBppc.PageMCEElement.Big_Repair_Time__c = '7'; DBppc.PageMCEElement.Live_Technical_Support_Time__c = '24'; DBppc.PageMCEElement.Tour_Check__c='0'; DBppc.PageMCEElement.Dedust__c = '1'; DBppc.PageMCEElement.First_Party_Contract_Number__c = '3'; DBppc.PageMCEElement.Second_Party_Contract_Number__c ='1'; DBppc.PageMCEElement.Phone_Number__c='1231231312'; DBppc.PageMCEElement.Negotiate_Mean__c = '1'; DBppc.PageMCEElement.Inspection_Time__c ='1'; DBppc.PageMCEElement.Payment_Plan_Sum_First__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Second__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Third__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Forth__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Fifth__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Sixth__c = 50; DBppc.PageMCEElement.FieldRequest_quotation_Amount__c = 300; // DBppc.PageMCEElement.Payment_Plan_Sum_First__c = 2000; DBppc.PageMCEElement.Payment_Plan_Date_First__c = Date.today(); DBppc.PageMCEElement.Payment_Plan_Date_Second__c = Date.today(); DBppc.PageMCEElement.Payment_Plan_Date_Third__c = Date.today(); DBppc.PageMCEElement.Payment_Plan_Date_Forth__c = Date.today(); DBppc.PageMCEElement.Payment_Plan_Date_Fifth__c = Date.today(); DBppc.PageMCEElement.Payment_Plan_Date_Sixth__c = Date.today(); DBppc.print(); DBppc.init(); DBppc.PageMCEElement.Is_Standard_Contract__c = '是'; DBppc.PageMCEElement.Term_Of_Payment__c = '多次付款'; DBppc.PageMCEElement.Small_Repair_Time__c = '5'; DBppc.PageMCEElement.Engineer_Name__c = '77777'; DBppc.PageMCEElement.Big_Repair_Time__c = '7'; DBppc.PageMCEElement.Live_Technical_Support_Time__c = '24'; DBppc.PageMCEElement.Tour_Check__c='0'; DBppc.PageMCEElement.Dedust__c = '1'; DBppc.PageMCEElement.First_Party_Contract_Number__c = '3'; DBppc.PageMCEElement.Second_Party_Contract_Number__c ='1'; DBppc.PageMCEElement.Phone_Number__c='1231231312'; DBppc.PageMCEElement.Negotiate_Mean__c = '1'; DBppc.PageMCEElement.Inspection_Time__c ='1'; DBppc.PageMCEElement.Payment_Plan_Sum_First__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Second__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Third__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Forth__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Fifth__c = 50; DBppc.PageMCEElement.Payment_Plan_Sum_Sixth__c = 50; DBppc.PageMCEElement.FieldRequest_quotation_Amount__c = 300; // DBppc.PageMCEElement.Payment_Plan_Sum_First__c = 2000; DBppc.PageMCEElement.Payment_Plan_Date_First__c = Date.today(); target01.one_off_payment_agreed_period__c = '15'; DBppc.save(); DBppc.init(); DBppc.PageMCEElement.Is_Standard_Contract__c = '是'; DBppc.PageMCEElement.Term_Of_Payment__c = '一次性付款'; target01.FieldRequest_quotation_Amount__c = 2000; target01.Payment_Plan_Sum_First__c = null; target01.Payment_Plan_Sum_Second__c = null; target01.Payment_Plan_Sum_Third__c = null; target01.Payment_Plan_Sum_Forth__c = null; target01.Payment_Plan_Sum_Fifth__c = null; target01.Payment_Plan_Sum_Sixth__c = null; target01.Payment_Plan_Date_First__c = null; target01.Payment_Plan_Date_Second__c = null; target01.Payment_Plan_Date_Third__c = null; target01.Payment_Plan_Date_Forth__c = null; target01.Payment_Plan_Date_Fifth__c = null; target01.Payment_Plan_Date_Sixth__c = null; update target01; DBppc.PageMCEElement.Payment_Plan_Date_First__c = Date.today(); target01.one_off_payment_agreed_period__c = '15'; DBppc.save(); DBppc.init(); DBppc.PageMCEElement.Is_Standard_Contract__c = '否'; DBppc.PageMCEElement.Term_Of_Payment__c = '一次性付款'; DBppc.print(); DBppc.save(); DBppc.getSmall_Repair_Time(); DBppc.getLive_Technical_Support_Time(); DBppc.getTour_Check(); DBppc.getTotal_Payment_Time(); DBppc.getTerm_Of_Payment(); DBppc.getFirst_Party_Contract_Number(); DBppc.getCheck_Of_Payment(); DBppc.getDedust(); DBppc.getNegotiate_Mean(); DBppc.getBig_Repair_Time(); DBppc.getone_off_payment_agreed_period(); DBppc.Dummy2(); DBppc.dummy(); DBppc.init(); DBppc.convertNumberToChinese('88,888'); } }