From 7560140a14a60e949e6130d98225297e84f0a198 Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期三, 06 四月 2022 17:22:30 +0800
Subject: [PATCH] class

---
 force-app/main/default/classes/NewQuoteEntryWebServiceTest.cls |  308 ++++++--------------------------------------------
 1 files changed, 39 insertions(+), 269 deletions(-)

diff --git a/force-app/main/default/classes/NewQuoteEntryWebServiceTest.cls b/force-app/main/default/classes/NewQuoteEntryWebServiceTest.cls
index 07f699a..72942a2 100644
--- a/force-app/main/default/classes/NewQuoteEntryWebServiceTest.cls
+++ b/force-app/main/default/classes/NewQuoteEntryWebServiceTest.cls
@@ -1,277 +1,47 @@
-/**
- * This class contains unit tests for validating the behavior of Apex classes
- * and triggers.
- *
- * Unit tests are class methods that verify whether a particular piece
- * of code is working properly. Unit test methods take no arguments,
- * commit no data to the database, and are flagged with the testMethod
- * keyword in the method definition.
- *
- * All test methods in an organization are executed whenever Apex code is deployed
- * to a production organization to confirm correctness, ensure code
- * coverage, and prevent regressions. All Apex classes are
- * required to have at least 75% code coverage in order to be deployed
- * to a production organization. In addition, all triggers must have some code coverage.
- * 
- * The @isTest class annotation indicates this class only contains test
- * methods. Classes defined with the @isTest annotation do not count against
- * the organization size limit for all Apex scripts.
- *
- * See the Apex Language Reference for more information about Testing and Code Coverage.
- */
 @isTest
 private class NewQuoteEntryWebServiceTest {
-    private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
-    static testMethod void myUnitTest() {
-        NewQuoteEntryWebService.getProduct2(new List<String>());
-        NewQuoteEntryWebService.getQuoteLineItem('12345');
-    }
-    
-    static testMethod void selectQuotationTest() {
-    	
-    	Product2 product = new Product2( Name='銉嗐偣銉堝晢鍝�');
-    	product.SFDA_Status__c = '鏈夊姽';
-        product.Intra_Trade_List_RMB_1__c = 100;
-        product.Intra_Trade_List_RMB_Date1__c = date.today();
-        product.Intra_Trade_Cost_RMB_1__c = 200;
-        product.Intra_Trade_Cost_RMB_Date1__c = date.today();
-        product.Manual_Entry__c = false;
-        product.Asset_Model_No__c = '11111';
-        product.ProductCode = 'OTV-SP1H-NA-12E';
-		insert product;
-		
-		PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id);
-		entry.UnitPrice = 0;
-		entry.IsActive = true;
-		entry.UseStandardPrice = false;
-		entry.CurrencyIsoCode = 'CNY';
-		insert entry;
-    	
-    	Opportunity opp = new Opportunity();
-        opp.Name='aiueo';
-        opp.StageName='contact';
-        opp.Trade__c = '鍐呰部';
-        opp.CloseDate=Date.today();
-        opp.CurrencyIsoCode = 'CNY';
-        opp.Estimation_List_Price__c = 100;
-        opp.Wholesale_Price__c = 101;
-        opp.Dealer_Final_Price__c = 102;
-        opp.OCM_Agent1_Price__c = 103;
-        opp.Stocking_Price__c = 104;
-        opp.Estimation_No__c = '105';
-        opp.Estimation_Name__c = '106';
-        opp.Estimation_Id__c = '107';
+
+	@isTest static void test_method_one() {
+		Account user = new Account(
+            Name = '*',
+            FacilityName__c = 'user',
+            PostCode__c = '123456'
+        );
+        insert user;
+
+        Opportunity opp = new Opportunity(
+            Name = 'test opp',
+            AccountId = user.Id,
+            StageName = 'Prospect Created',
+            CurrencyIsoCode = 'CNY',
+            ProductSegment__c = 'IE',
+            CloseDate = Date.today(),
+            NewInquiryDate__c = Date.today().addDays(-2),
+            ExpectedOrderDate__c = Date.today().addDays(2),
+            TradeType__c = 'Taxation',
+            SalesChannel__c = 'direct',
+            Machine_Parts__c = 'Machine'
+        );
         insert opp;
-        
-        OpportunityLineItem oppli = new OpportunityLineItem();
-        oppli.OpportunityId = opp.Id;
-        oppli.Id__c = '110';
-        oppli.SFDA_Status__c = '鏈夊姽';
-        oppli.Name__c = '111';
-        oppli.ListPrice__c = 112;
-        oppli.Quantity = 113;
-        oppli.UnitPrice = 114;
-        oppli.UnitPrice__c = 115;
-        oppli.Qty_Unit__c = '116';
-        oppli.Cost__c = 117;
-        oppli.BSS_Category__c = 'G&R';
-        oppli.Item_Order__c = 1;
-        oppli.PricebookEntryId = entry.Id;
-        insert oppli;
-        
-        Quote quo = new Quote();
-        quo.Name = '206';
-        quo.OpportunityId = opp.Id;
-        quo.Quote_No__c = '205';
-        quo.Estimation_List_Price__c = 200;
-        quo.Dealer_Final_Price__c = 202;
-        quo.Stocking_Price__c = 204;
-        quo.OCM_Sales_Forecast__c = 201;
-        quo.OCM_Agent1_Price__c = 203;
-        quo.Pricebook2Id = pricebookId;
+
+        Quote quo = new Quote(
+            Name = 'quo',
+            OpportunityId = opp.Id,
+            SetName1__c = 'setname01',
+            SetQty1__c = 1
+        );
         insert quo;
-        
-        QuoteLineItem qli = new QuoteLineItem();
-        qli.QuoteId = quo.Id;
-        qli.Id__c = '210';
-        qli.SFDA_Status__c = '鏈夊姽';
-        qli.Name__c = '211';
-        qli.ListPrice__c = 212;
-        qli.Quantity = 213;
-        qli.UnitPrice__c = 215;
-        qli.UnitPrice = 0;
-        qli.Qty_Unit__c = '216';
-        qli.Cost__c = 217;
-        qli.BSS_Category__c = 'ET';
-        qli.Subtotal__c = 218;
-        qli.PricebookEntryId = entry.Id;
-        insert qli;
-        
-        Opportunity[] opp1 = [select Estimation_List_Price__c,Wholesale_Price__c,Dealer_Final_Price__c,OCM_Agent1_Price__c,
-         							 Stocking_Price__c,Estimation_No__c,Estimation_Name__c,Estimation_Id__c
-								from Opportunity where id = :opp.Id];
-		System.assertEquals(100, opp1[0].Estimation_List_Price__c);
-		System.assertEquals(101, opp1[0].Wholesale_Price__c);
-		System.assertEquals(102, opp1[0].Dealer_Final_Price__c);
-		System.assertEquals(103, opp1[0].OCM_Agent1_Price__c);
-		System.assertEquals(104, opp1[0].Stocking_Price__c);
-		System.assertEquals('105', opp1[0].Estimation_No__c);
-		System.assertEquals('106', opp1[0].Estimation_Name__c);
-		System.assertEquals('107', opp1[0].Estimation_Id__c);
-		
-		OpportunityLineItem[] oppli1 = [select Id__c,SFDA_Status__c,Name__c,ListPrice__c,Quantity,UnitPrice,UnitPrice__c,Qty_Unit__c,
-											 Cost__c,BSS_Category__c,Item_Order__c
-										from OpportunityLineItem where OpportunityId = :opp.Id];
-		System.assertEquals('110', oppli1[0].Id__c);
-		System.assertEquals('鏈夊姽', oppli1[0].SFDA_Status__c);
-		System.assertEquals('111', oppli1[0].Name__c);
-		System.assertEquals(112, oppli1[0].ListPrice__c);
-		System.assertEquals(113, oppli1[0].Quantity);
-		System.assertEquals(114, oppli1[0].UnitPrice);
-		System.assertEquals(115, oppli1[0].UnitPrice__c);
-		System.assertEquals('116', oppli1[0].Qty_Unit__c);
-		System.assertEquals(117, oppli1[0].Cost__c);
-		System.assertEquals('G&R', oppli1[0].BSS_Category__c);
-		System.assertEquals(1, oppli1[0].Item_Order__c);
 
-        PowerBISyncDefine__c olPowerBISyncDefine = new PowerBISyncDefine__c();
-        olPowerBISyncDefine.Name = 'OpportunityLineItem';
-        olPowerBISyncDefine.To_Table__c = 'BI_OpportunityLineItem__c';
-        upsert olPowerBISyncDefine;
+        Quote quo2 = new Quote(
+            Name = 'quo',
+            OpportunityId = opp.Id,
+            SetName1__c = 'setname01',
+            SetQty1__c = 1,
+            Quote_Type__c = 'service'
+        );
+        insert quo2;
 
-		NewQuoteEntryWebService.selectQuotation(opp.Id, quo.Id);
-		
-		Opportunity[] opp2 = [select Estimation_List_Price__c,Wholesale_Price__c,Dealer_Final_Price__c,OCM_Agent1_Price__c,
-         							 Stocking_Price__c,Estimation_No__c,Estimation_Name__c,Estimation_Id__c
-								from Opportunity where id = :opp.Id];
-		System.assertEquals(200, opp2[0].Estimation_List_Price__c);
-		System.assertEquals(201, opp2[0].Wholesale_Price__c);
-		System.assertEquals(202, opp2[0].Dealer_Final_Price__c);
-		System.assertEquals(203, opp2[0].OCM_Agent1_Price__c);
-		System.assertEquals(204, opp2[0].Stocking_Price__c);
-		System.assertEquals('205', opp2[0].Estimation_No__c);
-		System.assertEquals('206', opp2[0].Estimation_Name__c);
-		System.assertEquals(quo.Id, opp2[0].Estimation_Id__c);
-		
-		OpportunityLineItem[] oppli2 = [select Id__c,SFDA_Status__c,Name__c,ListPrice__c,Quantity,UnitPrice,UnitPrice__c,Qty_Unit__c,
-											 Cost__c,BSS_Category__c,Item_Order__c
-										from OpportunityLineItem where OpportunityId = :opp.Id];
-		System.assertEquals('210', oppli2[0].Id__c);
-		System.assertEquals('鏈夊姽', oppli2[0].SFDA_Status__c);
-		System.assertEquals('211', oppli2[0].Name__c);
-		System.assertEquals(212, oppli2[0].ListPrice__c);
-		System.assertEquals(213, oppli2[0].Quantity);
-		System.assertEquals(0, oppli2[0].UnitPrice);
-		System.assertEquals(215, oppli2[0].UnitPrice__c);
-		System.assertEquals('216', oppli2[0].Qty_Unit__c);
-		System.assertEquals(217, oppli2[0].Cost__c);
-		System.assertEquals('ET', oppli2[0].BSS_Category__c);
-		System.assertEquals(1, oppli2[0].Item_Order__c);
-    }
-
-    static testMethod void selectQuotationTest2() {
-        
-        Product2 product = new Product2( Name='銉嗐偣銉堝晢鍝�');
-        product.SFDA_Status__c = '鍋滄';
-        product.Intra_Trade_List_RMB_1__c = 100;
-        product.Intra_Trade_List_RMB_Date1__c = date.today();
-        product.Intra_Trade_Cost_RMB_1__c = 200;
-        product.Intra_Trade_Cost_RMB_Date1__c = date.today();
-        product.Manual_Entry__c = false;
-        product.Asset_Model_No__c = '11111';
-        product.ProductCode = 'OTV-SP1H-NA-12E';
-        insert product;
-        
-        PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id);
-        entry.UnitPrice = 0;
-        entry.IsActive = true;
-        entry.UseStandardPrice = false;
-        entry.CurrencyIsoCode = 'CNY';
-        insert entry;
-
-        Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�');
-        product1.SFDA_Status__c = '鏈夊姽';
-        product1.Intra_Trade_List_RMB_1__c = 100;
-        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();
-        product1.Manual_Entry__c = false;
-        product1.Asset_Model_No__c = '111112';
-        product1.ProductCode = 'OTV-SP1H-NA-13E';
-        insert product1;
-        
-        PricebookEntry entry1 = new PricebookEntry(Pricebook2Id=pricebookId,Product2Id=product1.Id);
-        entry1.UnitPrice = 0;
-        entry1.IsActive = true;
-        entry1.UseStandardPrice = false;
-        entry1.CurrencyIsoCode = 'CNY';
-        insert entry1;
-
-        
-        Opportunity opp = new Opportunity();
-        opp.Name='aiueo';
-        opp.StageName='contact';
-        opp.Trade__c = '鍐呰部';
-        opp.CloseDate=Date.today();
-        opp.CurrencyIsoCode = 'CNY';
-        opp.Estimation_List_Price__c = 100;
-        opp.Wholesale_Price__c = 101;
-        opp.Dealer_Final_Price__c = 102;
-        opp.OCM_Agent1_Price__c = 103;
-        opp.Stocking_Price__c = 104;
-        opp.Estimation_No__c = '105';
-        opp.Estimation_Name__c = '106';
-        opp.Estimation_Id__c = '107';
-        insert opp;
-        
-        OpportunityLineItem oppli = new OpportunityLineItem();
-        oppli.OpportunityId = opp.Id;
-        oppli.Id__c = '110';
-        oppli.SFDA_Status__c = '鏈夊姽';
-        oppli.Name__c = '111';
-        oppli.ListPrice__c = 112;
-        oppli.Quantity = 113;
-        oppli.UnitPrice = 114;
-        oppli.UnitPrice__c = 115;
-        oppli.Qty_Unit__c = '116';
-        oppli.Cost__c = 117;
-        oppli.BSS_Category__c = 'G&R';
-        oppli.Item_Order__c = 1;
-        oppli.PricebookEntryId = entry.Id;
-        insert oppli;
-        
-        Quote quo = new Quote();
-        quo.Name = '206';
-        quo.OpportunityId = opp.Id;
-        quo.Quote_No__c = '205';
-        quo.Estimation_List_Price__c = 200;
-        quo.Dealer_Final_Price__c = 202;
-        quo.Stocking_Price__c = 204;
-        quo.OCM_Sales_Forecast__c = 201;
-        quo.OCM_Agent1_Price__c = 203;
-        quo.Pricebook2Id = pricebookId;
-        insert quo;
-        
-        QuoteLineItem qli = new QuoteLineItem();
-        qli.QuoteId = quo.Id;
-        qli.Id__c = '210';
-        qli.SFDA_Status__c = '鏈夊姽';
-        qli.Name__c = '211';
-        qli.ListPrice__c = 212;
-        qli.Quantity = 213;
-        qli.UnitPrice__c = 215;
-        qli.UnitPrice = 0;
-        qli.Qty_Unit__c = '216';
-        qli.Cost__c = 217;
-        qli.BSS_Category__c = 'ET';
-        qli.Subtotal__c = 218;
-        qli.PricebookEntryId = entry.Id;
-        insert qli;
-
-        NewQuoteEntryWebService.updateOTCode( quo.Id);
-        
-
-    }
-
+        NewQuoteEntryWebService.selectQuotation(opp.Id, quo.Id);
+	}
 
 }
\ No newline at end of file

--
Gitblit v1.9.1