From c376deadef754aa59c002386c2f3c98904be37f8 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期四, 15 六月 2023 09:49:06 +0800
Subject: [PATCH] 测试类代码覆盖率优化

---
 force-app/main/default/classes/NewQuoteEntryControllerTest.cls |   34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/force-app/main/default/classes/NewQuoteEntryControllerTest.cls b/force-app/main/default/classes/NewQuoteEntryControllerTest.cls
index f51a78c..004f214 100644
--- a/force-app/main/default/classes/NewQuoteEntryControllerTest.cls
+++ b/force-app/main/default/classes/NewQuoteEntryControllerTest.cls
@@ -78,6 +78,7 @@
     private static String agentName = 'test agent name';
 
     static testMethod void TestInit01() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         system.debug('---------------------------------------Start initTest-----');
         NewQuoteEntryController QuotePage = new NewQuoteEntryController();
         //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
@@ -142,6 +143,7 @@
     }
 
     static testMethod void testInit02() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         system.debug('---------------------------------------Start initTest-----');
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
@@ -203,6 +205,7 @@
     }
 
     static testMethod void testInit02_01() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
         system.runAs(MacOwner) {
@@ -322,6 +325,7 @@
 //     }
 
     static testMethod void testInit02_2_01() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         system.debug('---------------------------------------Start initTest-----');
         NewQuoteEntryController QuotePage = new NewQuoteEntryController();
         //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
@@ -437,6 +441,8 @@
 //     }
 
     static testMethod void testInit04() {
+        ControllerUtil.EscapeNFM001Trigger = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
         system.runAs(MacOwner) {
@@ -504,6 +510,7 @@
         }
     }
     static testMethod void testInit04_01() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
         system.runAs(MacOwner) {
@@ -561,6 +568,7 @@
     }
 
     static testMethod void testInit04_2() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
         system.runAs(MacOwner) {
@@ -629,6 +637,7 @@
     }
 
     static testMethod void testInit04_2_01() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         NewQuoteEntryController QuotePage = new NewQuoteEntryController();
         String userId = UserInfo.getUserId();
         User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
@@ -676,10 +685,11 @@
         //瑕嬬銉囥兗銈挎绱�
         opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
 
-        //test7( opp, quote , QuotePage);
+        test7( opp, quote , QuotePage);
         System.Test.stopTest();
     }
     static testMethod void TestInit05() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         system.debug('---------------------------------------Start initTest-----');
         NewQuoteEntryController QuotePage = new NewQuoteEntryController();
         //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
@@ -901,7 +911,7 @@
 
         delete quote;
 
-        Product2 product1 = new Product2( Name = '銉嗐偣銉堝晢鍝�');
+        Product2 product1 = new Product2( Name = '銉嗐偣銉堝晢鍝�', ProductCode = 'TST1000001', Asset_Model_No__c = 'TST1000001');
         insert product1;
         system.debug('##product.Id=[' + product1.Id + ']' );
 
@@ -978,7 +988,7 @@
 
 //        delete quote;
 
-            Product2 product1 = new Product2( Name = '銉嗐偣銉堝晢鍝�');
+            Product2 product1 = new Product2( Name = '銉嗐偣銉堝晢鍝�', ProductCode = 'TST1101101', Asset_Model_No__c = 'TST1101101', LastbuyProductFLG__c = true);
             insert product1;
             system.debug('##product.Id=[' + product1.Id + ']' );
 
@@ -1005,6 +1015,7 @@
         }
     }
     static testMethod void check_QuoteEntryController001() {
+        StaticParameter.EscapeOppandStaTrigger = true;
 
         RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
         Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
@@ -1161,6 +1172,9 @@
             controller.quoId = null;
             controller.enableSales = false;
             controller.init();
+            product2.Name = '11122';
+            update product2;
+            controller.init();
             controller.quo.MultiYearWarrantyTotalPrice__c = 1000;
             controller.dataCheck();
             controller.select_index = 0;
@@ -1242,6 +1256,7 @@
     }
     //娴嬭瘯绋嬪簭 娴嬪璐� 绮剧悽鎶�鏈� wql 2021/02/20 start
     static testMethod void check_QuoteEntryController002() {
+        StaticParameter.EscapeOppandStaTrigger = true;
 
         RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
         Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
@@ -1269,7 +1284,7 @@
         system.runAs(MacOwner) {
             Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
             opp.Trade__c = '澶栬部';
-            opp.CurrencyIsoCode = CurrencyIso;
+            opp.CurrencyIsoCode = 'USD';
             opp.Sales_Root__c = '璨╁2搴�';
             opp.StageName = '寮曞悎';
             opp.owner_not_automatically_update__c = true;
@@ -1476,10 +1491,11 @@
             Apexpages.currentPage().getParameters().put('oppid', opp.id);
             NewQuoteEntryController controller = new NewQuoteEntryController();
             //Apexpages.currentPage().getParameters().put('id', quote.id);
-            controller.oppId = null;
-            controller.quoId = null;
+            controller.oppId = opp.id;
+            controller.quoId = quote.id;
             controller.enableSales = false;
             controller.init();
+            controller.ReservedProductVerification();
             controller.quo.MultiYearWarrantyTotalPrice__c = 1000;
             controller.dataCheck();
             controller.select_index = 0;
@@ -1577,6 +1593,7 @@
     }
 
     static testMethod void dataEntryTest() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
         system.runAs(MacOwner) {
@@ -1836,6 +1853,7 @@
 
        //娴嬭瘯闃胯タ璧涘 娴嬭瘯绋嬪簭 绮剧悽鎶�鏈� wql 2021/02/20 start
     static testMethod void check_QuoteEntryController003() {
+        StaticParameter.EscapeOppandStaTrigger = true;
 
         RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
         Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
@@ -2104,6 +2122,7 @@
 
     //20211015 lt start
     static testMethod void check_QuoteEntryController004() {
+        StaticParameter.EscapeOppandStaTrigger = true;
 
         RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
         Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
@@ -2405,6 +2424,7 @@
     }
 
     static testMethod void dataEntryTest1() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
         User MacOwner = new User(Test_staff__c = true, Batch_User__c  = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
         system.runAs(MacOwner) {
@@ -2639,6 +2659,7 @@
             //controller.dataEntry();
             //controller.dataCheck();
             controller.QuoteDecision();
+            controller.quoId = quote.id;
             controller.Print();
 
             actList = new List<NewQuoteEntryController.QELine>();
@@ -2676,6 +2697,7 @@
     }
     //20211015 lt end
     static testMethod void dataEntryTest2() {
+        StaticParameter.EscapeOppandStaTrigger = true;
         RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
         Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
         hospital.RecordTypeId = recByoin.id;

--
Gitblit v1.9.1