@isTest private class OpportunityFileTriggerTest { //CHAN-BCNCRB XHL 尚未上线 @isTest static void test_method_one() { List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectCo.size() == 0) { return; } List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科']; if (rectSct.size() == 0) { return; } List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; if (rectDpt.size() == 0) { return; } StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; // テストデータ Account company = new Account(); company.RecordTypeId = rectCo[0].Id; company.Name = 'NFM007TestCompany'; upsert company; Account section = new Account(); section.RecordTypeId = rectSct[0].Id; section.Name = '*'; section.Department_Class_Label__c = '消化科'; section.ParentId = company.Id; section.Hospital_Department_Class__c = company.Id; upsert section; Account depart = new Account(); depart.RecordTypeId = rectDpt[0].Id; depart.Name = '*'; depart.Department_Name__c = 'NFM007TestDepart'; depart.ParentId = section.Id; depart.Department_Class__c = section.Id; depart.Hospital__c = company.Id; upsert depart; Opportunity opp = new Opportunity(); opp.AccountId = depart.Id; opp.Department_Class__c = section.Id; opp.Hospital__c = company.Id; opp.SAP_Send_OK__c = false; opp.Name = 'GZ-SP-NFM007_1'; opp.Trade__c = '内貿'; opp.StageName = '引合'; opp.CloseDate = date.newinstance(2022, 11, 30); opp.Stock_apply_status__c = '申请中'; insert opp; Opportunity_File__c ofile = new Opportunity_File__c(); ofile.Name = 'test file'; ofile.Opportunity__c = opp.Id; ofile.Oppor_File_Stage__c = 'G'; insert ofile; Attachment att1 = new Attachment( Name = 'test', ParentId = ofile.Id, Body = EncodingUtil.base64Decode('test') ); insert att1; delete ofile; } }