@isTest private class buttonAssetCtlTest { static testMethod void testMethod1() { 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; 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 = '妇科用硬性镜'; // prd1.Category5__c = '260SL系列'; prd1.Asset_Model_No__c = '1001'; prd1.Important_product__c = true; prd1.Important_Rroduct_1GI__c = true; insert prd1; Asset report = new Asset(); report.AssetMark__c = '耗材'; report.Asset_Owner__c = '病院資産'; report.InstallDate = Date.today(); report.Posting_Date__c = Date.today(); report.Asset_day__c = Date.today(); report.SerialNumber = '09K(IOSJA)'; report.Order_No__c = 'BJ-ET-203044-7'; report.Name = 'FD-410LR:一次性高频止血'; report.AccountId = dep.Id; report.Department_Class__c = strategicDep[0].Id; report.Hospital__c = hospital.Id; report.Product2Id = prd1.Id; insert report; buttonAssetCtl.init(report.id); } static testMethod void testMethod2() { User user3 = new User(); user3.ProfileId = UserInfo.getProfileId(); // user3.FirstName = 'ユーザー3'; user3.LastName = 'テスト3'; user3.Email = 'test_user3@example.com'; user3.emailencodingkey='UTF-8'; user3.languagelocalekey='zh_CN'; user3.localesidkey='ja_JP'; user3.timezonesidkey='Asia/Shanghai'; user3.Username = 'test_user3@example.com' + System.now().millisecond(); user3.Alias = 'テユ4'; user3.CommunityNickname = 'tu3' + System.now().millisecond(); insert user3; buttonAssetCtl.initUserName(user3.id); } static testMethod void testMethod3() { Product2 user1 = new Product2(); user1.name ='Asia/Shanghai'; user1.Can_Repair__c ='可'; insert user1; buttonAssetCtl.selecctProduct2ById(user1.id); } static testMethod void testMethod4() { Oly_TriggerHandler.bypass('QISTrigger'); 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; Asset asset = new Asset(); asset.Name = 'テスト機器'; asset.AccountId = dep.Id; asset.Department_Class__c = strategicDep[0].Id; asset.Hospital__c = hospital.Id; asset.SerialNumber = 'testserial'; insert asset; Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //医院所有人 User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'com',Alias = 'com', CommunityNickname = 'comOwner', Email = 'olympus_comowner@sunbridge.com', Username = 'olympus_comowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert comOwner; Date toDate = Date.today(); String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId(); System.debug(RecordTypeId); QIS_Report__c qis = new QIS_Report__c(); qis.RecordTypeId = RecordTypeId; qis.Name = 'Test'; qis.QIS_Status__c='OSH检测中'; qis.OwnerId = comOwner.id; qis.CDS_date__c=Date.today(); qis.OCSMAdministrativeReportDate__c=Date.today(); qis.Aware_date__c=Date.today(); qis.QIS_Submit_day__c=Date.today().addMonths(6); qis.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis.OCSMAdministrativeReportStatus__c='无需报告'; qis.isAE_Profile__c='YES'; qis.isPAE_Profile__c='YES'; qis.next_action__c='无偿维修'; // QIS_SC_Report__c qsc = new QIS_SC_Report__c(); // qsc.Status__c = '已提交'; // insert qsc; // qis.QIS_SC_Report__c = qsc.id; qis.nonyushohin__c=asset.id; qis.IsSendQIS__c=false; insert qis; buttonAssetCtl.selecctQISReportByFomatToday(asset.id,toDate); buttonAssetCtl.selecctQISReportrByFomatToday(asset.id,toDate); } static testMethod void testMethod5() { buttonAssetCtl.selectCASE('病院資産'); buttonAssetCtl.selectCASE('购买'); buttonAssetCtl.selectCASE('Olympus'); buttonAssetCtl.selectCASE('备品'); buttonAssetCtl.selectCASE('リース会社'); buttonAssetCtl.selectCASE('其他'); buttonAssetCtl.selectCASE('经销商资产'); buttonAssetCtl.selectCASE('资产'); buttonAssetCtl.selectNullvalue('资产','',''); buttonAssetCtl.selectNullvalue('','资产',''); buttonAssetCtl.selectNullvalue('','','资产'); } static testMethod void testMethod6() { 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; Date toDate = Date.today(); Asset report = new Asset(); report.AssetMark__c = '耗材'; report.Asset_Owner__c = '病院資産'; report.InstallDate = Date.today(); report.Posting_Date__c = Date.today(); report.Asset_day__c = Date.today(); report.SerialNumber = '09K(IOSJA)'; report.Order_No__c = 'BJ-ET-203044-7'; report.Name = 'FD-410LR:一次性高频止血'; report.AccountId = dep.Id; report.Department_Class__c = strategicDep[0].Id; report.Hospital__c = hospital.Id; insert report; Repair__c repair1 = new Repair__c(); repair1.Service_Repair_No__c = 'repair1'; repair1.Account__c = dep.Id; repair1.Department_Class__c = strategicDep[0].Id; repair1.Hospital__c = hospital.Id; // repair1.Delivered_Product__c = ast1.Id; repair1.Repair_List_Price__c = 100; repair1.Delivered_Product__c = report.id; repair1.Billing_Amount__c = 10; repair1.Paid_Amount__c = 1; repair1.FSE_ApplyForRepair_time__c = Date.today().addMonths(6); 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); repair1.AWS_Data_Id__c = '123'; insert repair1; buttonAssetCtl.selecctRepairByFomatToday(report.id,toDate); } static testMethod void testMethod7() { Date toDate = Date.today(); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; Account acc = new Account(); acc.RecordTypeId = rectCo.Id; acc.Name = 'HP test1'; acc.Assume_Change__c = true; insert acc; buttonAssetCtl.selecctAccountByAccountId(acc.id); buttonAssetCtl.selecctAccountBySegmentId(acc.id); buttonAssetCtl.accSendEmailFW('1111',acc.id,'1','黑名单',null,null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'2','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'3','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'4','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'5','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'6','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'7','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'8','警示名单','1111',null,null); buttonAssetCtl.accSendEmailFW('1111',acc.id,'9','警示名单','1111',null,null); } }