@isTest class OCM_Ctrl2_test { final static string ra1 = [select id , SobjectType, developername from recordtype where SobjectType='Rental_Apply__c' and developername='StandardRequest'][0].id; final static string acc1 = [select id , SobjectType, developername from recordtype where SobjectType='Account' and developername='HP'][0].id; @isTest static void rental_apply() { Account hp = new Account(RecordTypeId = acc1, Name = 'AccountTestHp1'); insert hp; Rental_Apply__c rentalApply = new Rental_Apply__c(); rentalApply.recordTypeId = ra1; rentalApply.CurrencyIsoCode = 'CNY'; rentalApply.applyUser__c = Userinfo.getUserId(); rentalApply.direct_send__c = '直送'; rentalApply.direct_shippment_address__c = 'test'; rentalApply.Request_return_day__c = Date.today() + 30; rentalApply.account__c = hp.id; insert rentalApply; PageReference pr = Page.AL_MobileApp_Land; pr.getParameters().put('pid', rentalApply.id); Test.setCurrentPage(pr); OCM_Ctrl2 c1 = new OCM_Ctrl2(); } @isTest static void asset() { Account hp = new Account(RecordTypeId = acc1, Name = 'AccountTestHp1'); insert hp; Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'Prd1'; prd1.ProductCode = 'Prd1'; prd1.Repair_Product_Code__c = 'Prd1_RP'; prd1.Name = 'Prd1'; prd1.Manual_Entry__c = false; prd1.Category2__c = '本体'; prd1.Category3__c = '纤维镜'; prd1.Category4__c = 'CV'; prd1.Category5__c = '260SL系列'; prd1.Asset_Model_No__c = '1001'; insert prd1; Asset ast1 = new Asset(); ast1.Name = '保有設備1'; ast1.Hospital__c = hp.Id; ast1.AccountId = hp.Id; ast1.Product2Id = prd1.Id; ast1.SerialNumber = 'SerialNumber1'; ast1.Guarantee_period_for_products__c = Date.today(); ast1.InstallDate = Date.today(); insert ast1; PageReference pr = Page.AL_MobileApp_Land; pr.getParameters().put('pid', ast1.id); Test.setCurrentPage(pr); OCM_Ctrl2 c1 = new OCM_Ctrl2(); } @isTest static void repair() { Account hp = new Account(RecordTypeId = acc1, Name = 'AccountTestHp1'); insert hp; Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'Prd1'; prd1.ProductCode = 'Prd1'; prd1.Repair_Product_Code__c = 'Prd1_RP'; prd1.Name = 'Prd1'; prd1.Manual_Entry__c = false; prd1.Category2__c = '本体'; prd1.Category3__c = '纤维镜'; prd1.Category4__c = 'CV'; prd1.Category5__c = '260SL系列'; prd1.Asset_Model_No__c = '1001'; insert prd1; Asset ast1 = new Asset(); ast1.Name = '保有設備1'; ast1.Hospital__c = hp.Id; ast1.AccountId = hp.Id; ast1.Product2Id = prd1.Id; ast1.SerialNumber = 'SerialNumber1'; ast1.Guarantee_period_for_products__c = Date.today(); ast1.InstallDate = Date.today(); insert ast1; final string acc2 = [select id , SobjectType, developername from recordtype where SobjectType='Account' and developername='Department_Class_BF'][0].id; //戦略科室分類 呼吸科 Account Department_Class_BF = new Account(RecordTypeId = acc2, Name = 'Department_Class_BF',ParentId=hp.id,Department_Class_Label__c='呼吸科'); insert Department_Class_BF; final string acc3 = [select id , SobjectType, developername from recordtype where SobjectType='Account' and developername='Department_BF'][0].id; //戦略科室分類 呼吸科 Account Department_BF = new Account(RecordTypeId = acc3, Name = 'Department_BF',ParentId=Department_Class_BF.id,Hospital__c=hp.id,Department_Class__c=Department_Class_BF.id); insert Department_BF; Repair__c repair1 = new Repair__c(); repair1.Service_Repair_No__c = 'repair1'; repair1.Hospital__c = hp.Id; repair1.Account__c = Department_BF.Id; repair1.Department_Class__c = Department_Class_BF.id; repair1.Delivered_Product__c = ast1.Id; repair1.Repair_List_Price__c = 100; repair1.Billing_Amount__c = 10; repair1.Paid_Amount__c = 1; repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1); repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3); repair1.Repair_Shipped_Date__c = Date.today().addDays(1); insert repair1; PageReference pr = Page.AL_MobileApp_Land; pr.getParameters().put('pid', repair1.id); Test.setCurrentPage(pr); OCM_Ctrl2 c1 = new OCM_Ctrl2(); } }