From 928399eceec50e3d37ea08669a12789a9410a9d2 Mon Sep 17 00:00:00 2001
From: 沙世明 <shashiming@prec-tech.com>
Date: 星期二, 22 十一月 2022 16:51:16 +0800
Subject: [PATCH] 111

---
 force-app/main/default/classes/NFM007TriggerTest.cls |   46 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/force-app/main/default/classes/NFM007TriggerTest.cls b/force-app/main/default/classes/NFM007TriggerTest.cls
index 6b44b8d..937b09f 100644
--- a/force-app/main/default/classes/NFM007TriggerTest.cls
+++ b/force-app/main/default/classes/NFM007TriggerTest.cls
@@ -8,6 +8,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -60,7 +61,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -78,6 +78,22 @@
         product.MDM_Model_No__c = 'test';
         product.CanNotCancelledGurantee__c=true;
         insert product;
+
+        Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210',
+            MedPrdClass__c = '3',
+            ValidFrom__c = date.newinstance(2018, 07, 22),
+            ValidTo__c = date.newinstance(2028, 07, 22),
+            RegisterNoClass_Old__c = '6815',
+            RegisterNoClass_New__c = '6815',
+            RegisterNoStatus__c = '鏈夋晥'
+            );
+        insert prc;
+
+        Product_Register_Link__c prlc = new Product_Register_Link__c(
+            Product2__c = product.Id,
+            Product_Register__c = prc.Id
+            );
+        insert prlc;
         
         PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id);
         entry.UnitPrice = 0;
@@ -90,7 +106,7 @@
         opp.AccountId           = depart.Id;
         opp.Department_Class__c = section.Id;
         opp.Hospital__c         = company.Id;
-        opp.SAP_Send_OK__c      = true;
+        opp.SAP_Send_OK__c      = false;
         opp.Gurantee_Period__c = '2';
         opp.Name                = 'GZ-SP-NFM007_1';
         opp.Trade__c            = '鍐呰部';
@@ -116,6 +132,8 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+
+        System.Test.startTest();
 
         //QuoteLineItem qli = new QuoteLineItem();
         //qli.QuoteId = quo.Id;
@@ -165,6 +183,7 @@
         oppli.PricebookEntryId = entry.Id;
         insert oppli;
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
@@ -180,6 +199,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -232,7 +252,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -269,6 +288,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -326,6 +346,7 @@
         oppli.PricebookEntryId = entry.Id;
         insert oppli;
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
@@ -337,7 +358,7 @@
         //Test.stopTest();
     }
 
-    //static testMethod void testUpdateHospital() {
+      //static testMethod void testUpdateHospital() {
     //    List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
     //    if (rectCo.size() == 0) {
     //        return;
@@ -865,6 +886,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -917,7 +939,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -954,6 +975,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -1044,6 +1066,7 @@
         oppli.PricebookEntryId = entry.Id;
         insert oppli;
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
@@ -1063,6 +1086,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -1115,7 +1139,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -1152,6 +1175,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -1216,6 +1240,7 @@
         insert oppli;
         
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
@@ -1232,6 +1257,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -1284,7 +1310,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -1322,6 +1347,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -1389,6 +1415,7 @@
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
+        StaticParameter.EscapeOppandStaTrigger = false;
         opp.SAP_Send_OK__c      = true;
         opp.Gurantee_Period__c = '2';
         opp.oldData_flg__c = true;
@@ -1396,4 +1423,9 @@
         update opp;  
         //Test.stopTest();
     }
+
+    static testMethod void test_00() {
+        NFM007Controller controller = new NFM007Controller();
+        controller.test();
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1