@isTest private class TenderDeleteLwcControllerTest { static testMethod void testMethod1() { ControllerUtil.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeOppandStaTrigger = true; List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院' Limit 1]; if (rectCo.size() == 0) { return; } List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科' Limit 1]; if (rectSct.size() == 0) { return; } List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科' Limit 1]; if (rectDpt.size() == 0) { return; } //List TenInfo = [Select Id, InfoId__c, Logical_delete__c, ProjectId__c, Retain_Tender__c From Tender_information__c Where id = : 'a4J1m0000009Tv5']; List rectDpts = [select Id from RecordType where IsActive = true and SobjectType = 'Tender_information__c' and Name = '手工录入' Limit 1]; if (rectDpts.size() == 0) { return; } Tender_information__c TenInfo = new Tender_information__c(); Tender_information__c TenInfo1 = new Tender_information__c(); TenInfo1.Name = 'QLMTEST08111057-02'; TenInfo1.RecordTypeId=rectDpts[0].Id; TenInfo1.InfoTitle__c = '招标项目1'; TenInfo1.subInfoType__c='1-1:意见征集'; // 20221018 ljh SWAG-CKB9NR add insert TenInfo1; TenInfo.Name = '2345'; TenInfo.InfoId__c = '1234'; TenInfo.Retain_Tender__c = TenInfo1.Id; TenInfo.RecordTypeId=rectDpts[0].Id; TenInfo.InfoTitle__c = '招标项目2'; TenInfo.TenderManageCode__c ='123'; TenInfo.subInfoType__c='1-1:意见征集'; // 20221018 ljh SWAG-CKB9NR add insert TenInfo; //List BlinksList = [select Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c = :BTen.Id]; 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(2025, 11, 30); opp.Stock_apply_status__c = '申请中'; opp.Whether_Bidding__c = '否'; insert opp; Tender_Opportunity_Link__c BlinksList = new Tender_Opportunity_Link__c(); BlinksList.Opportunity__c = opp.Id; BlinksList.CurrencyIsoCode = 'CNY'; BlinksList.Tender_information__c = TenInfo1.Id; // insert BlinksList; Tender_Opportunity_Link__c linksList = new Tender_Opportunity_Link__c(); linksList.Opportunity__c = opp.Id; linksList.CurrencyIsoCode = 'CNY'; linksList.Tender_information__c = TenInfo.Id; insert linksList; Tender_Opportunity_Link__c addlinksList = new Tender_Opportunity_Link__c(); addlinksList.Opportunity__c = opp.Id; addlinksList.CurrencyIsoCode = 'CNY'; addlinksList.Tender_information__c = TenInfo1.Id; // insert addlinksList; //Tender_information__c BTen = [select Id, InfoId__c From Tender_information__c Where Id = : TenInfo.Retain_Tender__c]; Tender_information__c BTen = new Tender_information__c(); BTen.InfoId__c = '1122'; TenInfo.Retain_Tender__c = BTen.Id; String BTenInfo = BTen.InfoId__c; BTen.InfoId__c = TenInfo.InfoId__c; TenInfo.InfoId__c = BTenInfo; TenInfo.Logical_delete__c = true; List updateTenInfoList = new List(); updateTenInfoList.add(TenInfo); updateTenInfoList.add(BTen); //Apexpages.currentPage().getParameters().put('id', TenInfo.Id); PageReference peg = new PageReference('/apex/TenderDeletePage?id=' + TenInfo.Id); System.Test.setCurrentPage(peg); // TenderDeleteLwcController tenderDeleteController = new TenderDeleteLwcController(); System.Test.StartTest(); String test =TenderDeleteLwcController.GetTenderinformationcData(TenInfo.Id); // Id,Name,InfoId__c,Logical_delete__c,ProjectId__c,Retain_Tender__c system.debug('test+++'+test); List TenInfos=(List)JSON.deserializeStrict(test,List.class); test =JSON.serialize(TenInfos[0]); TenderDeleteLwcController.searchTender(TenInfo1.TenderManageCode__c); TenderDeleteLwcController.saveData(test); System.Test.StopTest(); } }