@isTest private class buttonQISReportCtlTest { static testMethod void testMethod1() { Oly_TriggerHandler.bypass('ContactTrigger'); Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('AssetTrigger'); Oly_TriggerHandler.bypass('UserAfter'); Oly_TriggerHandler.bypass('MaintenanceContractTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate'); Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete'); Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd'); Oly_TriggerHandler.bypass('NFM106Controller'); Oly_TriggerHandler.bypass('NFM106Trigger'); Oly_TriggerHandler.bypass('AssetRecordTypeUpd'); Oly_TriggerHandler.bypass('NFM101Controller'); Oly_TriggerHandler.bypass('NFM001Controller'); Oly_TriggerHandler.bypass('RepairHandler'); FixtureUtil.SkipTrigger = true; StaticParameter.EscapeVMCTrigger = true; 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; Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //医院所有人 User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'comOwner', 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; QIS_Report__c qis2 = new QIS_Report__c(); qis2.RecordTypeId = RecordTypeId; qis2.Name = 'Test'; qis2.QIS_Status__c='OSH检测中'; qis2.OwnerId = comOwner.id; qis2.CDS_date__c=Date.today(); qis2.OCSMAdministrativeReportDate__c=Date.today(); qis2.Aware_date__c=Date.today(); qis2.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis2.OCSMAdministrativeReportStatus__c='无需报告'; qis2.isAE_Profile__c='YES'; qis2.isPAE_Profile__c='YES'; qis2.next_action__c='无偿维修'; // qis2.QIS_SC_Report__c='a3w10000000U6frAAC'; qis2.IsSendQIS__c=false; insert qis2; User user3 = new User(); user3.ProfileId = UserInfo.getProfileId(); // user3.FirstName = ''; user3.LastName = 'テスト3 ユーザー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; 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); insert repair1; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); buttonQISReportCtl.init(qis.id); buttonQISReportCtl.init(''); buttonQISReportCtl.initUserName(user3.id); buttonQISReportCtl.initUserName(''); buttonQISReportCtl.selectQISReportC(qis.id); buttonQISReportCtl.selectQISReportC(''); buttonQISReportCtl.initSelectProfile(UserInfo.getProfileId()); buttonQISReportCtl.initSelectProfile(''); buttonQISReportCtl.updateQisForRCRecieved(qis.id,user3.id); buttonQISReportCtl.updateOSHNogoods(qis.id,'754543560@qq.com',user3.id); buttonQISReportCtl.updateQISReportC(qis.id,user3.id); buttonQISReportCtl.selecctAccountByAccountId(dep.id); buttonQISReportCtl.selecctAccountByAccountId(''); Test.stopTest(); } static testMethod void testMethod2() { FixtureUtil.SkipTrigger = true; Oly_TriggerHandler.bypass('ContactTrigger'); StaticParameter.EscapeVMCTrigger = true; Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('AssetTrigger'); Oly_TriggerHandler.bypass('UserAfter'); Oly_TriggerHandler.bypass('MaintenanceContractTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate'); Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete'); Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd'); Oly_TriggerHandler.bypass('NFM106Controller'); Oly_TriggerHandler.bypass('NFM106Trigger'); Oly_TriggerHandler.bypass('AssetRecordTypeUpd'); Oly_TriggerHandler.bypass('NFM101Controller'); Oly_TriggerHandler.bypass('NFM001Controller'); Oly_TriggerHandler.bypass('RepairHandler'); 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; Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //医院所有人 User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'comOwner', 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; QIS_Report__c qis2 = new QIS_Report__c(); qis2.RecordTypeId = RecordTypeId; qis2.Name = 'Test'; qis2.QIS_Status__c='OSH检测中'; qis2.OwnerId = comOwner.id; qis2.CDS_date__c=Date.today(); qis2.OCSMAdministrativeReportDate__c=Date.today(); qis2.Aware_date__c=Date.today(); qis2.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis2.OCSMAdministrativeReportStatus__c='无需报告'; qis2.isAE_Profile__c='YES'; qis2.isPAE_Profile__c='YES'; qis2.next_action__c='无偿维修'; // qis2.QIS_SC_Report__c='a3w10000000U6frAAC'; qis2.IsSendQIS__c=false; insert qis2; User user3 = new User(); user3.ProfileId = UserInfo.getProfileId(); // user3.FirstName = ''; user3.LastName = 'テスト3 ユーザー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; 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); insert repair1; List repairIds = new List(); List repairIds2 = new List(); repairIds.add(qis.id); repairIds2.add(repair1.id); BatchIF_Log__c iflog = new BatchIF_Log__c(); iflog.Type__c = 'sendToETQ'; iflog.ErrorLog__c = ''; iflog.Log__c = 'NFM401WebService start--'; iflog.Log__c += '\n修理:'+' 更新成功'; iflog.Log__c = '\nNFM401WebService end--'; insert iflog; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); buttonQISReportCtl.sendToETQ('123456',iflog,repairIds,'2'); Test.stopTest(); } static testMethod void testMethod3() { StaticParameter.EscapeVMCTrigger = true; FixtureUtil.SkipTrigger = true; Oly_TriggerHandler.bypass('ContactTrigger'); Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('AssetTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate'); Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete'); Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd'); Oly_TriggerHandler.bypass('NFM106Controller'); Oly_TriggerHandler.bypass('UserAfter'); Oly_TriggerHandler.bypass('NFM106Trigger'); Oly_TriggerHandler.bypass('AssetRecordTypeUpd'); Oly_TriggerHandler.bypass('NFM101Controller'); Oly_TriggerHandler.bypass('NFM001Controller'); Oly_TriggerHandler.bypass('RepairHandler'); 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; Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //医院所有人 User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'comOwner', 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; QIS_Report__c qis2 = new QIS_Report__c(); qis2.RecordTypeId = RecordTypeId; qis2.Name = 'Test'; qis2.QIS_Status__c='OSH检测中'; qis2.OwnerId = comOwner.id; qis2.CDS_date__c=Date.today(); qis2.OCSMAdministrativeReportDate__c=Date.today(); qis2.Aware_date__c=Date.today(); qis2.OCSMAdministrativeReportNumber__c='00510000001R56KAAS'; qis2.OCSMAdministrativeReportStatus__c='无需报告'; qis2.isAE_Profile__c='YES'; qis2.isPAE_Profile__c='YES'; qis2.next_action__c='无偿维修'; // qis2.QIS_SC_Report__c='a3w10000000U6frAAC'; qis2.IsSendQIS__c=false; insert qis2; User user3 = new User(); user3.ProfileId = UserInfo.getProfileId(); // user3.FirstName = ''; user3.LastName = 'テスト3 ユーザー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; 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); insert repair1; // Id qisssId = [SELECT id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id; Test.StartTest(); List repairIds = new List(); List repairIds2 = new List(); repairIds.add(qis.id); repairIds2.add(repair1.id); BatchIF_Log__c iflog = new BatchIF_Log__c(); iflog.Type__c = 'sendToETQ'; iflog.ErrorLog__c = ''; iflog.Log__c = 'NFM401WebService start--'; iflog.Log__c += '\n修理:'+' 更新成功'; iflog.Log__c = '\nNFM401WebService end--'; insert iflog; buttonQISReportCtl.sendToETQ('123456',iflog,repairIds2,'2'); Test.stopTest(); } }