From 5fb60d0de53f40f1d519a23f8c071954dd599d8f Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期一, 26 六月 2023 17:13:01 +0800
Subject: [PATCH] 提高代码覆盖率

---
 force-app/main/default/classes/SI_NewQuoteEntryControllerTest.cls |  266 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 265 insertions(+), 1 deletions(-)

diff --git a/force-app/main/default/classes/SI_NewQuoteEntryControllerTest.cls b/force-app/main/default/classes/SI_NewQuoteEntryControllerTest.cls
index aa3e8d7..03bebfa 100644
--- a/force-app/main/default/classes/SI_NewQuoteEntryControllerTest.cls
+++ b/force-app/main/default/classes/SI_NewQuoteEntryControllerTest.cls
@@ -61,7 +61,7 @@
     private static String quoteNo = 'textQutote01';
     public static String trade = '鍐呰部';
     public static String CurrencyIso = 'CNY';
-
+    public static String USDIso = 'USD';
     private static Boolean isUnitPrice = true;
     private static Boolean isOfferAmount = true;
     private static Boolean isTotalPrice = true;
@@ -1242,6 +1242,8 @@
             Product2 product1 = new Product2( Name = '11111');
             product1.SFDA_Status__c = '涓嶈';
             product1.Intra_Trade_List_RMB_1__c = 100;
+            product1.Intra_Trade_Cost_RMB_End_Date1__c = Date.today().addDays(5);
+            product1.Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(5);
             product1.Intra_Trade_List_RMB_Date1__c = date.today();
             product1.Intra_Trade_Cost_RMB_1__c = 200;
             product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
@@ -1540,4 +1542,266 @@
         SI_NewQuoteEntryController.QELine actList12 = new SI_NewQuoteEntryController.QELine(10,true,'aaa',Date.today(),'bbb',pE2.Id,'ddd','eee','fff','ggg','hhh','iii','jjj','kkk',10,1.1,2.2,3.3,4.0,5.5,6.6,'lll',7.7,8.8);
         system.debug('xxxxxxxxxxxxxxxxxxxxxxxx++++++++++++++++++++++++');
     }
+
+
+    static testMethod void dataEntryTest3() {
+        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) {
+            StaticParameter.EscapeNFM001AgencyContractTrigger = true;
+            StaticParameter.EscapeAccountTrigger = true;
+            ControllerUtil.EscapeNFM001Trigger = true;
+            Oly_TriggerHandler.bypass('PowerBIBaseHandler');
+            StaticParameter.EscapeSyncOpportunityTrigger = true;
+            StaticParameter.EscapeNFM007Trigger = true;
+            StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
+            Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
+            StaticParameter.EscapeSyncOpportunityTrigger = true;
+            StaticParameter.EscapeSyncProduct2Trigger = true;
+            Oly_TriggerHandler.bypass('PowerBIBaseHandler');
+
+            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;
+            hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
+            hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
+            insert hospital;
+
+            RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
+            Account sellerA = new Account(Name = '璨╁2搴�');
+            sellerA.RecordTypeId = recHanbaiten.id;
+            sellerA.Hospital__c = hospital.id;
+            insert sellerA;
+
+            RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
+            Account contractA = new Account(Name = '*');
+            contractA.RecordTypeId = recKeiyaku.id;
+            contractA.Agent_Ref__c = sellerA.id;
+            contractA.ParentId = sellerA.id;
+            insert contractA;
+
+
+            Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
+            opp.Trade__c = '澶栬部';
+            opp.CurrencyIsoCode = USDIso;
+            opp.Sales_Root__c = '璨╁2搴�';
+            opp.StageName = '寮曞悎';
+            opp.Fixed_Check__c = false;
+            opp.owner_not_automatically_update__c = true;
+            opp.Pricebook2Id = pricebook.id;
+            opp.Purchase_Type__c = '涓�鑸紩鍚�';
+            opp.Promise_Class__c = '澶栬部';
+            opp.Fund_Basis__c = '鏀垮簻璩囬噾';
+            opp.AccountId = contractA.id;
+            opp.Hospital__c = contractA.id;
+            opp.Agency1__c = sellerA.id;
+            opp.Agency2__c = sellerA.id;
+            opp.Wholesale_Price__c = 9000;
+            opp.Stock_Confrim_Date__c = Date.today();
+            insert opp;
+
+            Product2 product1 = new Product2( Name = '11111');
+            product1.SFDA_Status__c = '涓嶈';
+            product1.Manual_Entry__c = false;
+            product1.Foreign_Trade_List_US_1__c = 100;
+            product1.Foreign_Trade_Cost_US_End_Date1__c = Date.today().addDays(5);
+            product1.Foreign_Trade_List_US_End_Date1__c = Date.today().addDays(5);
+            product1.Foreign_Trade_List_US_Date1__c = date.today();
+            product1.Foreign_Trade_Cost_US_1__c = 200;
+            product1.Foreign_Trade_Cost_US_Date1__c = date.today();
+            product1.Asset_Model_No__c = '11111';
+            product1.ProductCode = 'OTV-SP1H-NA-12E';
+            insert product1;
+            system.debug('##product.Id=[' + product1.Id + ']' );
+
+            Product2 product2 = new Product2( Name = '11112');
+            product2.SFDA_Status__c = '涓嶈';
+            product2.Intra_Trade_List_RMB_1__c = 100;
+            product2.Intra_Trade_List_RMB_Date1__c = date.today();
+            product2.Intra_Trade_Cost_RMB_1__c = 200;
+            product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
+            product2.Manual_Entry__c = false;
+            product2.Asset_Model_No__c = '11112';
+            //        product2.ProductCode = 'OTV-SP1H-NA-12E';
+            insert product2;
+            system.debug('##product1.Id=[' + product1.Id + ']' );
+            system.debug('##product2.Id=[' + product2.Id + ']' );
+
+            PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
+
+            pE.UnitPrice = 0;
+            pE.IsActive = true;
+            pE.UseStandardPrice = false;
+            pE.CurrencyIsoCode = USDIso;
+            //pE.
+            insert pE;
+
+            PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
+
+            pE2.UnitPrice = 0;
+            pE2.IsActive = true;
+            pE2.UseStandardPrice = false;
+            pE2.CurrencyIsoCode = USDIso;
+            //pE.
+            insert pE2;
+
+            OpportunityLineItem oli = new OpportunityLineItem();
+            //target.QuoteId = input.Id;
+            oli.Quantity = 1;
+            //    target.TotalPrice = 100;
+            oli.UnitPrice = 10;
+            oli.PricebookEntryId = pE.Id;
+            oli.OpportunityId = opp.id;
+            oli.Cost__c = 100;
+            //oli.op
+            insert oli;
+
+            Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
+            quote.OpportunityId = opp.Id;
+            quote.Pricebook2Id = pricebook.id;
+            quote.Quote_No__c = quoteNo;
+            quote.Unit_Price__c = isUnitPrice;
+            quote.Offer_Amount__c = isOfferAmount;
+            quote.TOTAL__c = isTotalPrice;
+            quote.Discount__c = isDiscountRate;
+            quote.Pricing__c = isDiscountAmount;
+            quote.Preferential_Trading_Price__c = isTradingPrice;
+            quote.Contract__c = isContractDetail;
+            quote.Quote_Comment__c = offerComment;
+            quote.QuoteName__c = '銉嗐偣銉堣绌�';
+            quote.Dealer_Final_Price__c = 100;
+            quote.Quote_Adjust_Calculate__c = 10;
+            quote.Quote_Adjust_Amount__c = 10;
+            quote.OCM_Agent1_Price__c = 10;
+            quote.Agent1_Agent2_Price__c = 10;
+
+            insert quote;
+
+            // 銈汇儍銉堝搧
+            Product_Set__c ps1 = new Product_Set__c();
+            ps1.Name = '銈汇儍銉堝搧锛�';
+            ps1.Product_Set_CD__c = '111111';
+            ps1.Description__c = '瑾槑';
+            ps1.Qty__c = 10;
+            //ps1.Valid__c = true;
+            ps1.Valid_Date__c = date.today().addDays(-5);
+            insert ps1;
+
+            Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
+            psd1.Product_Set__c = ps1.id;
+            psd1.Price__c = 100;
+            psd1.Quantity__c = 10;
+            psd1.Product__c = product1.id;
+
+            insert psd1;
+
+            System.Test.startTest();
+            // 20211013 lt add 娉ㄩ噴鎺�
+            //SI_NewQuoteEntryController.QELine sqline = new SI_NewQuoteEntryController.QELine(2, true ,'String VenderName','String ProductSetName', pE.id, 'String Asset_Model', 'String StorageStatus', ' String ProductCode', 'String Id_c', 'String SFDA_Status_c', 'String Sales_Possibility_c', 'String Name_c', 'String BSS_Category_c', 2, 123, 21, 312, 123, 1.1, 1.1, '', 1.1,0);
+
+            //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
+            PageReference page = new PageReference('/apex/NewQuoteEntry');
+            System.Test.setCurrentPage(page);
+
+            Apexpages.currentPage().getParameters().put('oppid', opp.id);
+            SI_NewQuoteEntryController controller = new SI_NewQuoteEntryController();
+            //Apexpages.currentPage().getParameters().put('id', quote.id);
+            controller.oppId = null;
+            controller.quoId = null;
+            controller.enableSales = false;
+            controller.init();
+            controller.dataCheck();
+            controller.select_index = 0;
+            controller.Product_text = product1.id;
+            controller.setProduct_text = ps1.id;
+            controller.setProductEntry();
+            //        controller.settingProduct2();
+            controller.OppReflection();
+            controller.activities[0].Asset_Model = 'test';
+            controller.PriceStatusUpdate();
+            controller.SalesId1 = sellerA.id;
+            controller.SalesId2 = sellerA.id;
+            controller.getSalesId1();
+            controller.getSalesId2();
+            controller.cancel();
+
+            Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
+                                      Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
+                                      QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
+                                      OCM_Agent1_Price__c, Agent1_Agent2_Price__c
+                                      FROM Quote WHERE Id = :quote.id];
+            system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
+
+            controller.enableSales = false;
+            controller.opp.Agency1__c = null;
+            controller.quo.OCM_Agent1_Price__c = null;
+            controller.opp.Agency2__c = null;
+            controller.quo.Agent1_Agent2_Price__c = null;
+            controller.quo.QuoteName__c = 'aaa';
+            controller.quo.Dealer_Final_Price_Page__c = 100;
+            controller.quo.Dealer_Final_Price__c = 100;
+            controller.qb.Quote_Adjust_Calculate = 100;
+            controller.quo.Quote_Adjust_Calculate__c = 100;
+            controller.quo.Quote_Adjust_Amount_Page__c = 10;
+            controller.quo.Quote_Adjust_Amount__c = 10;
+            controller.quo.Quote_Expiration_Date__c = date.today();
+            controller.oppId = opp.id;
+            //        controller.PricebookId = pricebook.id;
+            SI_NewQuoteEntryController.QELine act = new SI_NewQuoteEntryController.QELine(oli, 0);
+
+            act.Asset_Model = '11111';
+
+            act.pageObject.Quantity__c = 10;
+            act.pageObject.UnitPrice_Page__c = 100;
+            act.pageObject.UnitPrice = 100;
+            act.pageObject.Subtotal__c = 1000;
+            act.pageObject.PricebookEntryId = pE2.id;
+            act.pageObject.Id__c = product2.id;
+            List<SI_NewQuoteEntryController.QELine> actList = new List<SI_NewQuoteEntryController.QELine>();
+            actList.add(act);
+            controller.activities = actList;
+            controller.save();
+            controller.dataEntry();
+            controller.dataCheck();
+            controller.QuoteDecision();
+            controller.Print();
+
+            actList = new List<SI_NewQuoteEntryController.QELine>();
+            actList.add(act);
+            controller.activities = actList;
+            controller.excel_text = 'OTV-SP1H-NA-12E\t1';
+            controller.excelImport();
+            Add_Report.getProduct2(product2.id);
+
+            //   QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
+            actList = new List<SI_NewQuoteEntryController.QELine>();
+            act.Asset_Model = null;
+            actList.add(act);
+            controller.activities = actList;
+            controller.excel_text = 'OTV-SP1H-NA-12E\t1';
+            controller.excelImport();
+            Add_Report.getProduct2(product2.id);
+
+            //  dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
+            controller.enableSales = true;
+
+            IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c();
+            ISOhead.name = '*';
+            ISOhead.Opportunity_ID__c = opp.id;
+            ISOhead.Approval_Date__c = Date.today();
+            ISOhead.Public_Hospital_TF__c = true;
+            ISOhead.Preparation_Stage_TF__c = true;
+            ISOhead.Data_Check_TF__c = true;
+            ISOhead.Operating_Room_Plane_Graph_TF__c = true;
+            ISOhead.Demonstration_Area_Plane_Graph_TF__c = true;
+            insert ISOhead;
+
+            controller.QuoteDecision = false;
+            controller.QuoteDecision();
+            controller.Print();
+            //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
+
+            System.Test.stopTest();
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1