@isTest private class RequestTednerDocHandlerTest { static testMethod void testMethod1() { 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; RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='販売店' limit 1]; Account sellerA = new Account(Name = '販売店'); sellerA.RecordTypeId = recHanbaiten.id; sellerA.Ban_On_Use_Date__c = Date.today().addDays(20); insert sellerA; 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.today() + 1; opp.Stock_apply_status__c = '申请中'; insert opp; Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin]; User u3 = new User(Test_staff__c = true); u3.LastName = '_サンブリッジ'; u3.Batch_User__c = true; u3.FirstName = 'う'; u3.Alias = 'う'; u3.Email = 'olympusTest03@sunbridge.com'; u3.Username = 'olympusTest03@sunbridge.com'; u3.CommunityNickname = 'う'; u3.IsActive = true; u3.EmailEncodingKey = 'ISO-2022-JP'; u3.TimeZoneSidKey = 'Asia/Tokyo'; u3.LocaleSidKey = 'ja_JP'; u3.LanguageLocaleKey = 'ja'; u3.ProfileId = p.id; u3.Job_Category__c = '支援'; insert u3; Request_tedner_doc__c rtd = new Request_tedner_doc__c(); rtd.Request_target__c = u3.Id; rtd.Bid_distributor__c = sellerA.Id; rtd.Tender_No__c = '12345'; rtd.Tender_request_reason__c = 'reason'; rtd.Product_discription__c = 'aa'; insert rtd; rtd.Status__c = '已提交'; update rtd; rtd.Status__c = '草案中'; update rtd; } }