From 0c67f7b596da5f6473ac68ea8376cad060971a0a Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期二, 20 六月 2023 17:50:07 +0800
Subject: [PATCH] 提高代码覆盖率
---
force-app/main/default/classes/UpdateTenderInformationBatchTest.cls | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 233 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/UpdateTenderInformationBatchTest.cls b/force-app/main/default/classes/UpdateTenderInformationBatchTest.cls
index ac65da7..84f3017 100644
--- a/force-app/main/default/classes/UpdateTenderInformationBatchTest.cls
+++ b/force-app/main/default/classes/UpdateTenderInformationBatchTest.cls
@@ -897,4 +897,237 @@
Test.stopTest();
}
+ static testMethod void testMethod07() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ StaticParameter.EscapeNFM001Trigger = true;
+ StaticParameter.EscapeNFM001AgencyContractTrigger = true;
+ StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+
+ RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
+ List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
+
+ Account acc = new Account();
+ acc.RecordTypeId = rectCo.Id;
+ acc.Name = 'HP test1';
+ acc.Assume_Change__c = true;
+ insert acc;
+
+ List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('娑堝寲绉�', '鍛煎惛绉�') order by Department_Class_Label__c];
+
+ Account depart1 = new Account();
+ depart1.RecordTypeId = rectDpt[0].Id;
+ depart1.Name = '*';
+ depart1.Department_Name__c = 'Gastoro Intestin Test';
+ depart1.ParentId = dept[0].Id;
+ depart1.Department_Class__c = dept[0].Id;
+ depart1.Hospital__c = acc.Id;
+
+ Account depart2 = new Account();
+ depart2.RecordTypeId = rectDpt[1].Id;
+ depart2.Name = '*';
+ depart2.Department_Name__c = '瑷虹檪绉�2';
+ depart2.ParentId = dept[1].Id;
+ depart2.Department_Class__c = dept[1].Id;
+ depart2.Hospital__c = acc.Id;
+ insert new Account[] {depart1, depart2};
+
+ RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
+
+ //鎷涙爣椤圭洰
+ Tender_information__c te1 = new Tender_information__c();
+ te1.Name = 'TestZhaoBiao1';
+ te1.IsReactionOpp__c = false;
+ te1.Hospital__c = acc.Id;
+ insert te1;
+
+ Tender_information__c te2 = new Tender_information__c();
+ te1.IsReactionOpp__c = false;
+ te2.Name = 'TestZhaoBiao2';
+ insert te2;
+ //璇环
+ // Opportunity opp1 = new Opportunity(
+ // Name = 'test opp1',
+ // StageName = '鏁楁垿',
+ // CurrencyIsoCode = 'USD',
+ // CloseDate = Date.today(),
+ // AccountId = depart1.Id,
+ // RecordTypeId = oppVND.Id,
+ // Closing_Bid_Date__c = Date.today().addDays(-5),
+ // Hospital__c = acc.Id,
+ // Competitor__c = 'A'
+ // );
+ // Opportunity opp2 = new Opportunity(
+ // Name = 'test opp2',
+ // StageName = '鏁楁垿',
+ // CurrencyIsoCode = 'USD',
+ // CloseDate = Date.today(),
+ // AccountId = depart2.Id,
+ // RecordTypeId = oppVND.Id,
+ // Closing_Bid_Date__c = Date.today().addDays(-5),
+ // Hospital__c = acc.Id,
+ // Competitor__c = 'B',
+ // Bidding_Project_Name_Bid__c = te1.Id
+ // );
+ // Opportunity opp3 = new Opportunity(
+ // Name = 'test opp3',
+ // StageName = '鏁楁垿',
+ // CurrencyIsoCode = 'USD',
+ // CloseDate = Date.today(),
+ // AccountId = depart2.Id,
+ // RecordTypeId = oppVND.Id,
+ // Closing_Bid_Date__c = Date.today().addDays(-5),
+ // Hospital__c = acc.Id,
+ // Competitor__c = 'C',
+ // Bidding_Project_Name_Bid__c = te2.Id
+ // );
+ // insert new Opportunity[] {opp1, opp2,opp3};
+
+ // opp1.Bidding_Project_Name_Bid__c = te1.Id;
+ // opp2.Bidding_Project_Name_Bid__c = te2.Id;
+ // opp3.Bidding_Project_Name_Bid__c = null;
+
+ // update opp1;
+ // update opp2;
+ // update opp3;
+
+ List<String> tempList = new List<String>();
+ tempList.add(te1.Id);
+ tempList.add(te2.Id);
+ System.Test.StartTest();
+ UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch('',false);
+ Id execBTId = Database.executeBatch(batch);
+ System.Test.StopTest();
+ }
+
+ static testMethod void testMethod08() {
+ ControllerUtil.EscapeNFM001Trigger = true;
+ ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ StaticParameter.EscapeNFM001Trigger = true;
+ StaticParameter.EscapeNFM001AgencyContractTrigger = true;
+ StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+
+ RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
+ List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
+
+ Account acc = new Account();
+ acc.RecordTypeId = rectCo.Id;
+ acc.Name = 'HP test1';
+ insert acc;
+
+ List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('娑堝寲绉�', '鍛煎惛绉�') order by Department_Class_Label__c];
+
+ Account depart1 = new Account();
+ depart1.RecordTypeId = rectDpt[0].Id;
+ depart1.Name = '*';
+ depart1.Department_Name__c = 'Gastoro Intestin Test';
+ depart1.ParentId = dept[0].Id;
+ depart1.Department_Class__c = dept[0].Id;
+ depart1.Hospital__c = acc.Id;
+
+ Account depart2 = new Account();
+ depart2.RecordTypeId = rectDpt[1].Id;
+ depart2.Name = '*';
+ depart2.Department_Name__c = '瑷虹檪绉�2';
+ depart2.ParentId = dept[1].Id;
+ depart2.Department_Class__c = dept[1].Id;
+ depart2.Hospital__c = acc.Id;
+ insert new Account[] {depart1, depart2};
+
+ RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
+
+ //鎷涙爣椤圭洰
+ Tender_information__c te1 = new Tender_information__c();
+ te1.Name = 'TestZhaoBiao1';
+ insert te1;
+
+ Tender_information__c te2 = new Tender_information__c();
+ te2.Name = 'TestZhaoBiao2';
+ insert te2;
+ //璇环
+ Opportunity opp1 = new Opportunity(
+ Name = 'test opp1',
+ StageName = '鏁楁垿',
+ CurrencyIsoCode = 'USD',
+ CloseDate = Date.today(),
+ AccountId = depart1.Id,
+ RecordTypeId = oppVND.Id,
+ Closing_Bid_Date__c = Date.today().addDays(-5),
+ Hospital__c = acc.Id,
+ Competitor__c = 'A'
+ );
+ Opportunity opp2 = new Opportunity(
+ Name = 'test opp2',
+ StageName = '鏁楁垿',
+ CurrencyIsoCode = 'USD',
+ CloseDate = Date.today(),
+ AccountId = depart2.Id,
+ RecordTypeId = oppVND.Id,
+ Closing_Bid_Date__c = Date.today().addDays(-5),
+ Hospital__c = acc.Id,
+ Competitor__c = 'B',
+ Bidding_Project_Name_Bid__c = te1.Id
+ );
+ Opportunity opp3 = new Opportunity(
+ Name = 'test opp3',
+ StageName = '鏁楁垿',
+ CurrencyIsoCode = 'USD',
+ CloseDate = Date.today(),
+ AccountId = depart2.Id,
+ RecordTypeId = oppVND.Id,
+ Closing_Bid_Date__c = Date.today().addDays(-5),
+ Hospital__c = acc.Id,
+ Competitor__c = 'C',
+ Bidding_Project_Name_Bid__c = te2.Id
+ );
+ insert new Opportunity[] {opp1, opp2,opp3};
+
+ opp1.Bidding_Project_Name_Bid__c = te1.Id;
+ opp2.Bidding_Project_Name_Bid__c = te2.Id;
+ opp3.Bidding_Project_Name_Bid__c = null;
+
+ update opp1;
+ update opp2;
+ update opp3;
+
+ List<String> tempList = new List<String>();
+ tempList.add(te1.Id);
+ tempList.add(te2.Id);
+ System.Test.StartTest();
+ UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch(opp1.Id,false,tempList);
+ Id execBTId = Database.executeBatch(batch);
+ System.Test.StopTest();
+ }
+
+ static testMethod void testMethod09() {
+ Tender_information__c te1 = new Tender_information__c();
+ te1.Name = 'TestZhaoBiao1';
+ insert te1;
+
+ Tender_information__c te2 = new Tender_information__c();
+ te2.Name = 'TestZhaoBiao2';
+ insert te2;
+ System.Test.StartTest();
+ UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch(te1.Id);
+ System.Test.StopTest();
+ }
+
+
+ static testMethod void testMethod10() {
+ Tender_information__c te1 = new Tender_information__c();
+ te1.Name = 'TestZhaoBiao1';
+ insert te1;
+
+ Tender_information__c te2 = new Tender_information__c();
+ te2.Name = 'TestZhaoBiao2';
+ insert te2;
+ List<String> tempList = new List<String>();
+ tempList.add(te1.Id);
+ tempList.add(te2.Id);
+ System.Test.StartTest();
+ UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch(tempList);
+ System.Test.StopTest();
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1