From 900c50a247705d6fe8833e84d31b5d51616b7c26 Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 15 四月 2022 14:08:05 +0800 Subject: [PATCH] 20220415 --- force-app/main/default/classes/OpportunityWebServiceTest.cls | 1220 ++++------------------------------------------------------ 1 files changed, 84 insertions(+), 1,136 deletions(-) diff --git a/force-app/main/default/classes/OpportunityWebServiceTest.cls b/force-app/main/default/classes/OpportunityWebServiceTest.cls index 6d1ca04..cca142b 100644 --- a/force-app/main/default/classes/OpportunityWebServiceTest.cls +++ b/force-app/main/default/classes/OpportunityWebServiceTest.cls @@ -1,1151 +1,99 @@ @isTest -private class OpportunityWebServiceTest -{ - private static Id pricebookId = ControllerUtil.getStandardPricebook().Id; - - @isTest static void test_method_one() { - Opportunity opp = new Opportunity( - Name='Opp', - StageName='寮曞悎', - CloseDate=Date.today(), - CurrencyIsoCode = 'CNY' +private class OpportunityWebServiceTest { + + static testMethod void myUnitTest() { + List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + List<RecordType> rectOpp = [select Id from RecordType where IsActive = true and SobjectType = 'Opportunity' and Name = 'SSBD']; + Account acc1 = new Account( + name = '*', + RecordTypeId = rectIE[0].Id, + OwnerId = UserInfo.getUserId(), + DivisionName__c = 'Customer IE', + FacilityName__c = 'abc', + PostCode__c='000000' ); - insert opp; + insert acc1; - Quote q = new Quote( - Name = 'quote', - OpportunityId = opp.Id + Opportunity opp1 = new Opportunity( + name = 'test opp1', + RecordTypeId = rectOpp[0].Id, + OwnerId = UserInfo.getUserId(), + AccountId = acc1.Id, + StageName = 'Prospect Created', + SalesChannel__c = 'direct', + CloseDate = Date.valueof('1900-01-01') ); - insert q; - - OpportunityWebService.changeTrade(opp.id); - } - - @isTest - static void test_method_one1() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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; - product.SFDA_Status__c = '涓嶈'; - update product; - Product2 pro = [select id,SFDA_Status__c,Estimation_Entry_Possibility__c from Product2 where id = :product.Id]; - System.assertEquals('涓嶈', pro.SFDA_Status__c); - System.assertEquals('鈼�', pro.Estimation_Entry_Possibility__c); - Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�1'); - 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 = '111111'; - product1.ProductCode = 'OTV-SP1H-NA-12E1'; - insert product1; - PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); - entry.UnitPrice = 0; - entry.IsActive = true; - entry.UseStandardPrice = false; - entry.CurrencyIsoCode = 'CNY'; - insert entry; + insert opp1; - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; + String rs = ''; + rs = OpportunityWebService.UpdateStageName(opp1.Id, 'Phase1'); + System.assertEquals('1', rs); - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; - - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; - - - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '6815;6822;6823;6825', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //update linc; - - //浜у搧娉ㄥ唽璇� - 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_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc.Id - ); - insert prlc; - pro = [select id,SFDA_Status__c,Estimation_Entry_Possibility__c from Product2 where id = :product.Id]; - System.assertEquals('涓嶈', pro.SFDA_Status__c); - System.assertEquals('鈼�', pro.Estimation_Entry_Possibility__c); - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - System.Test.startTest(); - OpportunityWebService.updReg(opp.Id); - OpportunityWebService.oppCheck(opp.Id,'1'); - System.Test.stopTest(); - - } - - @isTest - static void test_method_four() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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; - Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�1'); - 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 = '111111'; - product1.ProductCode = 'OTV-SP1H-NA-12E1'; - insert product1; - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; - - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; - - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; - - - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '6815;6822;6823;6825', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //update linc; - - //linc = [select Id,Name,ScopeKey__c from License_Information__c where BusinessLicense__c = '20180522']; - //System.assertEquals('123',linc.ScopeKey__c); - //浜у搧娉ㄥ唽璇� - //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__c prc1 = new Product_Register__c(Name = '鍥芥娉ㄨ繘2016222021', - MedPrdClass__c = '2', - ValidFrom__c = date.newinstance(2018, 07, 22), - ValidTo__c = date.newinstance(2028, 07, 22), - RegisterNoClass_Old__c = '6833', - RegisterNoClass_New__c = '6833', - RegisterNoStatus__c = '鏈夋晥' - ); - insert prc1; - //鏂版棫鍏崇郴瀵圭収琛� - Product_Register_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc1.Id - ); - insert prlc; - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - - OpportunityWebService.oppCheck(opp.Id,'1'); - + List<Opportunity> oppList = [select Id, StageName from Opportunity where Id = :opp1.Id]; + System.assertEquals('Phase1', oppList[0].StageName); } - - @isTest - static void test_method_two() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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; - - Product2 product12 = new Product2( Name='銉嗐偣銉堝晢鍝�12'); - product12.SFDA_Status__c = '鏈夊姽'; - product12.Intra_Trade_List_RMB_1__c = 100; - product12.Intra_Trade_List_RMB_Date1__c = date.today(); - product12.Intra_Trade_Cost_RMB_1__c = 200; - product12.Intra_Trade_Cost_RMB_Date1__c = date.today(); - product12.Manual_Entry__c = false; - product12.Asset_Model_No__c = '1111112'; - product12.ProductCode = 'OTV-SP1H-NA-12E12'; - insert product12; - - Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�1'); - 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-12E1'; - insert product1; + + static testMethod void myUnitTest2() { + List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + List<RecordType> rectOpp = [select Id from RecordType where IsActive = true and SobjectType = 'Opportunity' and Name = 'SSBD']; + Account acc1 = new Account( + name = '*', + RecordTypeId = rectIE[0].Id, + OwnerId = UserInfo.getUserId(), + DivisionName__c = 'Customer IE', + FacilityName__c = 'abc', + PostCode__c='000000' + ); + insert acc1; - PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); - entry.UnitPrice = 0; - entry.IsActive = true; - entry.UseStandardPrice = false; - entry.CurrencyIsoCode = 'CNY'; - insert entry; + Opportunity opp1 = new Opportunity( + name = 'test opp1', + RecordTypeId = rectOpp[0].Id, + OwnerId = UserInfo.getUserId(), + AccountId = acc1.Id, + StageName = 'Prospect Created', + SalesChannel__c = 'direct', + CloseDate = Date.valueof('1900-01-01') + ); + insert opp1; - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; + User user = new User(); + user.LastName = 'test'; + user.FirstName = 'test'; + user.Alias = 'test'; + user.Email = 'test@test.com'; + user.Username = 'test111@test222.com'; + user.CommunityNickname = 'test'; + user.IsActive = true; + user.EmailEncodingKey = 'ISO-2022-JP'; + user.TimeZoneSidKey = 'Asia/Tokyo'; + user.LocaleSidKey = 'ja_JP'; + user.LanguageLocaleKey = 'ja'; + user.ProfileId = System.Label.SystemAdmin; + insert user; - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; + OpportunityTeamMember otm = new OpportunityTeamMember( + opportunityId = opp1.Id, + userId = user.Id, + teamMemberRole = 'Sales Manager' + ); + insert otm; - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; + String rs = ''; + rs = OpportunityWebService.UpdateShare(opp1.Id, user.Id); + System.assertEquals('1', rs); + + List<OpportunityTeamMember> otmList = [select Id, OpportunityAccessLevel from OpportunityTeamMember where Id = :otm.Id]; + System.assertEquals('Edit', otmList[0].OpportunityAccessLevel); + Quote quo = new Quote( + Name = 'quo', + OpportunityId = opp1.Id + ); + insert quo; - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '6822;6823;6825;6815A', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //浜у搧娉ㄥ唽璇� - Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210', - MedPrdClass__c = '2', - ValidFrom__c = date.newinstance(2018, 07, 22), - ValidTo__c = date.newinstance(2018, 08, 22), - RegisterNoClass_Old__c = '6833', - RegisterNoClass_New__c = '6833' - //RegisterNoStatus__c = '鏈夋晥' - ); - insert prc; - //鏂版棫鍏崇郴瀵圭収琛� - Product_Register_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc.Id - ); - insert prlc; - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - - OpportunityWebService.oppCheck(opp.Id,'1'); - + rs = ''; + rs = OpportunityWebService.Upload2Sap(opp1.Id, quo.Name, quo.Id); + System.assertEquals('1', rs); } - - @isTest - static void test_method_three() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; - - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; - - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; - - - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '6815;6822;6823;6825', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //System.assertEquals('123',linc.ScopeKey__c); - //浜у搧娉ㄥ唽璇� - 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_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc.Id - ); - insert prlc; - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - - OpportunityWebService.oppCheck(opp.Id,'2'); - - } - - - @isTest - static void test_method_five() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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; - Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�1'); - 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 = '111111'; - product1.ProductCode = 'OTV-SP1H-NA-12E1'; - insert product1; - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; - - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; - - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; - - - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '314;6822;6823;6825', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //update linc; - - //linc = [select Id,Name,ScopeKey__c from License_Information__c where BusinessLicense__c = '20180522']; - //System.assertEquals('123',linc.ScopeKey__c); - //浜у搧娉ㄥ唽璇� - 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_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc.Id - ); - insert prlc; - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - OpportunityWebService.updReg(opp.Id); - OpportunityWebService.oppCheck(opp.Id,'1'); - - } - - @isTest - static void test_method_six() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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; - Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�1'); - 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 = '111111'; - product1.ProductCode = 'OTV-SP1H-NA-12E1'; - insert product1; - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; - - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; - - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; - - - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '6815', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //update linc; - - //linc = [select Id,Name,ScopeKey__c from License_Information__c where BusinessLicense__c = '20180522']; - //System.assertEquals('123',linc.ScopeKey__c); - //浜у搧娉ㄥ唽璇� - Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210', - MedPrdClass__c = '2', - ValidFrom__c = date.newinstance(2018, 07, 22), - ValidTo__c = date.newinstance(2028, 07, 22), - RegisterNoClass_Old__c = '314', - RegisterNoClass_New__c = '314', - RegisterNoStatus__c = '鏈夋晥' - ); - insert prc; - - //鏂版棫鍏崇郴瀵圭収琛� - Product_Register_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc.Id - ); - insert prlc; - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - OpportunityWebService.updReg(opp.Id); - OpportunityWebService.oppCheck(opp.Id,'1'); - - } - @isTest - static void test_method_seven() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; - if (rectCo.size() == 0) { - return; - } - - //缁忛攢鍟嗐�佽仈绯讳汉銆佺敤鎴蜂俊鎭� - Account myAccount1 = new Account(name='Testaccount001', - Dealer_discount__c =20, - Ban_On_Use_Date__c = Date.today().addDays(1), - Business_Paper_Expiration_Date__c = Date.today().addDays(1), - Tax_Practice_Expiration_Date__c = Date.today().addDays(1), - Medical_Equipment_Expiration_Date__c = Date.today().addDays(1), - RecordTypeId = rectCo[0].Id); - insert myAccount1; - Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id]; - System.assertEquals('鏈夋晥', acc1.Is_Active_Formula__c); - Contact core1 = new Contact(email='test@salesforce.com', - firstname='test', - lastname='001', - accountid=myAccount1.Id); - insert core1; - - Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; - - 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; - Product2 product1 = new Product2( Name='銉嗐偣銉堝晢鍝�1'); - 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 = '111111'; - product1.ProductCode = 'OTV-SP1H-NA-12E1'; - insert product1; - 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'; - opp.Agency1__c = myAccount1.Id; - insert opp; - - OpportunityLineItem oppli = new OpportunityLineItem(); - oppli.OpportunityId = opp.Id; - oppli.Id__c = '110'; - oppli.SFDA_Status__c = '鏈夊姽'; - oppli.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗�'; - 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; - - OpportunityLineItem oppli2 = new OpportunityLineItem(); - oppli2.OpportunityId = opp.Id; - oppli2.Id__c = '110'; - oppli2.SFDA_Status__c = '鏈夊姽'; - oppli2.Name__c = '涓�浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲鍏竷鍏節鍗佷竴浜屼笁鍥涗簲'; - oppli2.ListPrice__c = 112; - oppli2.Quantity = 113; - oppli2.UnitPrice = 114; - oppli2.UnitPrice__c = 115; - oppli2.Qty_Unit__c = '116'; - oppli2.Cost__c = 117; - oppli2.BSS_Category__c = 'G&R'; - oppli2.Item_Order__c = 1; - oppli2.PricebookEntryId = entry.Id; - insert oppli2; - - - //鍖荤枟鍣ㄦ缁忚惀璁稿彲璇� - License_Information__c linc = new License_Information__c( name='Test20181204', - LicenseType__c = '鍖荤枟鍣ㄦ缁忚惀璁稿彲璇�', - BusinessLicense__c = '20180522', - ValidFrom__c = date.newinstance(2018, 05, 22), - ValidTo__c = date.newinstance(2088, 05, 22), - Scope3__c = '6815', - LicenseAndAccount__c = myAccount1.Id - ); - insert linc; - //update linc; - - //linc = [select Id,Name,ScopeKey__c from License_Information__c where BusinessLicense__c = '20180522']; - //System.assertEquals('123',linc.ScopeKey__c); - //浜у搧娉ㄥ唽璇� - Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210', - MedPrdClass__c = '2', - ValidFrom__c = date.newinstance(2018, 07, 22), - ValidTo__c = date.newinstance(2028, 07, 22), - RegisterNoClass_Old__c = '314', - RegisterNoClass_New__c = '314', - RegisterNoStatus__c = '鏈夋晥' - ); - insert prc; - - //鏂版棫鍏崇郴瀵圭収琛� - Product_Register_contrast__c prcc = new Product_Register_contrast__c( - Name = 'Test20181204', - Register_new__c = '314', - Register_old__c = '36815' - ); - insert prcc; - //浜у搧-浜у搧娉ㄥ唽璇佸叧绯� - Product_Register_Link__c prlc = new Product_Register_Link__c( - Product2__c = product.Id, - Product_Register__c = prc.Id - ); - insert prlc; - user MyUser_Test1 = New User(ContactId = core1.Id, - Alias = 'newUser1', - Email='newuser1@testorg.com', - EmailEncodingKey='UTF-8', - LastName='TestUser1', - LanguageLocaleKey='zh_CN', - LocaleSidKey='zh_CN', - Province__c = '鍖椾含甯�', - ProfileId = prof.Id, - TimeZoneSidKey='Asia/Shanghai', - UserName='testUser1@testorg.com'); - insert MyUser_Test1; - - OpportunityWebService.updReg(opp.Id); - OpportunityWebService.oppCheck(opp.Id,'1'); - //娴嬭瘯闃胯タ璧涘鏂规硶check - OpportunityWebService.checkDangerItem(acc1.Id); - - } - } \ No newline at end of file -- Gitblit v1.9.1