/**
|
* 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';
|
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;
|
|
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;
|
|
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);
|
|
|
}
|
|
|
}
|