@isTest private class QISReportControllerTest { static Maintenance_Contract__c createMaintenanceContract( Account hospital, Account strategicDep, Account dep) { Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.status__c ='契約'; contract.Maintenance_Contract_No__c = 'Kami_Contract_No'; contract.Contract_Conclusion_Date__c = Date.today(); contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep.Id; contract.Department__c = dep.Id; contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前 contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後 contract.SalesOfficeCode_selection__c = '北京RC'; insert contract; return contract; } static Maintenance_Contract_Asset__c createMiddleTable( Asset asset, Maintenance_Contract__c contract) { // 中間テーブルを設ける Maintenance_Contract_Asset__c middleTable = new Maintenance_Contract_Asset__c(); middleTable.Asset__c = asset.Id; middleTable.Maintenance_Contract__c = contract.id; insert middleTable; return middleTable; } @isTest public static void testMethod1() { 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; 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.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis.OCSMAdministrativeReportStatus__c='无需报告'; qis.isAE_Profile__c='YES'; qis.isPAE_Profile__c='YES'; qis.next_action__c='无偿维修'; // qis.QIS_SC_Report__c='a3w10000000U6frAAC'; qis.IsSendQIS__c=false; insert qis; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.initForQisUniversalFailureCodeButton(qis.id); QISReportController.sqlForPAE(qis.id); QISReportController.initForlexQISIntakeuniversalcodeButton(qis.id); QISReportController.sqlForPAE1(qis.id); QISReportController.initForOSHRecievedButton(qis.id); QISReportController.updateQis(qis.id); QISReportController.updateQis1(qis.id); QISReportController.initForQisAgreeButton(qis.id); QISReportController.updateQisForQisAgree(qis.id); QISReportController.initForRCCDScompleteButton(qis.id); Test.stopTest(); } @isTest public static void testMethod1_1() { 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; 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.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis.OCSMAdministrativeReportStatus__c='无需报告'; qis.isAE_Profile__c='YES'; qis.isPAE_Profile__c='YES'; qis.next_action__c='无偿维修'; // qis.QIS_SC_Report__c='a3w10000000U6frAAC'; qis.IsSendQIS__c=false; insert qis; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.updateQisForRCCDScomplete(qis.id); QISReportController.initForlexOCSMNoToReportLightingButton(qis.id); QISReportController.updateQisForlexOCSMNoToReportLighting(qis.id); QISReportController.initForlexOCSMToReportLightingButton(qis.id); QISReportController.updateQisForlexOCSMToReportLighting(qis.id); QISReportController.initForlexSendQISButton(qis.id); QISReportController.updateQisForSendQIS(qis.id); QISReportController.initForlexRCRecievedButton(qis.id); QISReportController.updateQisForRCRecieved(qis.id); QISReportController.initForlexQISSCButton(qis.id); QISReportController.initForlexCreateRepairButton(qis.id); QISReportController.initForlexPDFQISrequestButton(qis.id); QISReportController.initForlexOCSMNogoodsButton(qis.id); // QISReportController.updatelexOCSMNogoods(qis.id); Test.stopTest(); } @isTest public static void testMethod2() { 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; 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.OSH_staff__c = '00510000006xTn0AAE'; qis.OSH_staff_email__c = '754543560@qq.com'; qis.Cancel_QIS_Reason__c = '取消'; qis.RC_inspection_date__c = Date.today(); qis.QIS_Reply_day__c = Date.today(); qis.OSHInspectionDate__c = Date.today(); qis.QIS_Submit_day__c = Date.today(); qis.RC_problem_not_found__c = false; insert qis; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.initForOSHSubmitButton(qis.id); QISReportController.initForRCSubmitButton(qis.id); QISReportController.initForOCMSubmitButton(qis.id); QISReportController.initForlexRCinspectioncompletedateButton(qis.id); QISReportController.updateQisForRCinspectioncompletedate(qis.id); QISReportController.updateQisForlexOSHInspect(qis.id); QISReportController.initForlexcopyQISButton(qis.id); Test.stopTest(); } @isTest public static void testMethod3() { 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.OSH_staff__c = '00510000006xTn0AAE'; qis.OSH_staff_email__c = '754543560@qq.com'; qis.Cancel_QIS_Reason__c = '取消'; qis.RC_inspection_date__c = Date.today(); qis.QIS_Reply_day__c = Date.today(); qis.RC_problem_not_found__c = true; qis.RC_FixedJudgement__c = false; qis.OCM_judgement__c = '现象未发现'; insert qis; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.updateQisWithRC(qis.id,'1','RC检测中'); QISReportController.updateQisWithRC(qis.id,'2','RC检测中'); QISReportController.updateQisWithOCM(qis.id); Test.stopTest(); } @isTest public static void testMethod4() { 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; 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.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis.OCSMAdministrativeReportStatus__c='无需报告'; qis.isAE_Profile__c='YES'; qis.isPAE_Profile__c='YES'; qis.next_action__c='无偿维修'; // qis.QIS_SC_Report__c='a3w10000000U6frAAC'; qis.IsSendQIS__c=false; insert qis; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.updatelexOCSMNogoods(qis.id); Test.stopTest(); } @isTest public static void testMethod5() { 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; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.initForlexCreateQISFromAssetButton(report.id); Test.stopTest(); } @isTest public static void testMethod6() { 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; 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.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis.OCSMAdministrativeReportStatus__c='无需报告'; qis.isAE_Profile__c='YES'; qis.isPAE_Profile__c='YES'; qis.next_action__c='无偿维修'; // qis.QIS_SC_Report__c='a3w10000000U6frAAC'; qis.IsSendQIS__c=false; insert qis; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); QISReportController.initForlexOSHInspectButton(qis.id); Test.stopTest(); } }