| | |
| | | @isTest |
| | | private class LexInventoryListControllerTest { |
| | | static testMethod void myUnitTest() { |
| | | Oly_TriggerHandler.bypass('ConsumableAssetHander'); |
| | | Oly_TriggerHandler.bypass('Oly_TriggerHandler'); |
| | | User myUser_test; |
| | | Account myAccount2; |
| | | User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; |
| | | System.runAs(thisUser) { |
| | | List<RecordType> rectCo = [ |
| | | SELECT Id |
| | | FROM RecordType |
| | | WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店' |
| | | ]; |
| | | if (rectCo.size() == 0) { |
| | | return; |
| | | } |
| | | Profile prof = [ |
| | | SELECT Id |
| | | FROM Profile |
| | | WHERE Name = '901_经销商社区普通权限_2重验证(ET)' |
| | | ]; |
| | | myAccount2 = new Account( |
| | | name = 'Testaccount002', |
| | | Dealer_discount__c = 20, |
| | | RecordTypeId = rectCo[0].Id |
| | | ); |
| | | insert myAccount2; |
| | | Contact core = new Contact( |
| | | email = 'jplumber@salesforce.com', |
| | | firstname = 'Joe', |
| | | lastname = 'Plumber', |
| | | accountid = myAccount2.id |
| | | ); |
| | | insert core; |
| | | MyUser_Test = new User( |
| | | ContactId = core.id, |
| | | Alias = 'newUser', |
| | | Email = 'newuser@testorg.com', |
| | | EmailEncodingKey = 'UTF-8', |
| | | LastName = 'TestUser', |
| | | LanguageLocaleKey = 'zh_CN', |
| | | LocaleSidKey = 'zh_CN', |
| | | ProfileId = prof.Id, |
| | | TimeZoneSidKey = 'Asia/Shanghai', |
| | | UserName = 'testUser@testorg.com' |
| | | ); |
| | | insert MyUser_Test; |
| | | |
| | | static testMethod void myUnitTest() { |
| | | Oly_TriggerHandler.bypass('ConsumableAssetHander'); |
| | | Oly_TriggerHandler.bypass('Oly_TriggerHandler'); |
| | | User myUser_test; |
| | | Account myAccount2; |
| | | User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; |
| | | System.runAs(thisUser){ |
| | | List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店']; |
| | | if (rectCo.size() == 0) { |
| | | return; |
| | | } |
| | | Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)']; |
| | | myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id); |
| | | insert myAccount2; |
| | | Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id); |
| | | insert core; |
| | | MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com'); |
| | | insert MyUser_Test; |
| | | } |
| | | |
| | | System.runAs(MyUser_Test){ |
| | | Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Packing_list_manual__c=12,Dealer_special_Object__c = true,Manual_Entry__c = false); |
| | | Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Packing_list_manual__c=10,Dealer_special_Object__c = true,Manual_Entry__c = false); |
| | | Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',JANCODE__c = '04953170200313',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); |
| | | insert new Product2[]{prod01,prod02,prod03}; |
| | | Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); |
| | | Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); |
| | | Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id); |
| | | insert new Product2__c[] {pro1, pro2, pro3}; |
| | | |
| | | Consumable_order__c Order1 = new Consumable_order__c(); |
| | | Order1.Name = 'OCM_01_001'; |
| | | Order1.Order_status__c = '批准'; |
| | | Order1.Order_type__c = '盘点'; |
| | | Order1.RecordTypeid = System.Label.RT_ConOrder_Inventory; |
| | | insert Order1; |
| | | |
| | | Consumable_order__c Order2 = new Consumable_order__c(); |
| | | Order2.Name = 'OCM_01_002'; |
| | | Order2.Order_status__c = '批准'; |
| | | Order2.Order_type__c = '订单'; |
| | | Order2.RecordTypeid = System.Label.RT_ConOrder_Order; |
| | | insert Order2; |
| | | |
| | | Consumable_order__c Order3 = new Consumable_order__c(); |
| | | Order3.Name = 'OCM_01_004'; |
| | | Order3.Order_status__c = '批准'; |
| | | Order3.Order_type__c = '到货'; |
| | | Order3.RecordTypeid = '01210000000c9dqAAA'; |
| | | insert Order3; |
| | | |
| | | Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c(); |
| | | Orderdet1.Name = 'OCM_01_001001'; |
| | | Orderdet1.Consumable_order__c = Order1.Id; |
| | | Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory ; |
| | | |
| | | Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c(); |
| | | Orderdet2.Name = 'OCM_01_001002'; |
| | | Orderdet2.Consumable_order__c = Order1.Id; |
| | | Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory; |
| | | insert new Consumable_orderdetails__c[] {Orderdet1, Orderdet2}; |
| | | |
| | | List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c> (); |
| | | //产品类型不同 |
| | | Consumable_order_details2__c con = new Consumable_order_details2__c(); |
| | | con.Name = 'OCM_01_001001'; |
| | | con.Consumable_order_minor__c = Order1.Id; |
| | | con.Consumable_Product__c = pro2.Id; |
| | | con.Asset_Model_No__c = 'Test01'; |
| | | con.Arrive_date__c = Date.today(); |
| | | con.Bar_Code__c = '10011'; |
| | | con.Used_date__c = null; |
| | | con.Lose_Flag__c = false; |
| | | con.Return_date__c= null; |
| | | con.Send_Date__c= null; |
| | | con.Box_Piece__c = '盒'; |
| | | conList1.add(con); |
| | | insert conList1; |
| | | String eSetId = Order1.id; |
| | | System.Test.startTest(); |
| | | LexInventoryListController.init(eSetId); |
| | | |
| | | List<LexInventoryListController.ConsumableorderdetailsInfo> inList = LexInventoryListController.consumableorderdetailsRecords; |
| | | List<LexInventoryListController.ConsumableorderdetailsInfo> inList1 = new List<LexInventoryListController.ConsumableorderdetailsInfo>(); |
| | | for(LexInventoryListController.ConsumableorderdetailsInfo ass: inList){ |
| | | ass.orderdetails1= Orderdet1; |
| | | inList1.add(ass); |
| | | } |
| | | LexInventoryListController.ConsumableorderdetailsInfo c2 = new LexInventoryListController.ConsumableorderdetailsInfo(Orderdet1); |
| | | c2.orderdetails1 = Orderdet1; |
| | | c2.Prod = Orderdet1.Consumable_product__r; |
| | | LexInventoryListController.ConsumableorderdetailsInfo c1 = new LexInventoryListController.ConsumableorderdetailsInfo(con); |
| | | c1.orderdetails2 = con; |
| | | c1.Prod = con.Consumable_product__r; |
| | | c1.compareTo(c2); |
| | | System.Test.stopTest(); |
| | | } |
| | | } |
| | | |
| | | System.runAs(MyUser_Test) { |
| | | Product2 prod01 = new Product2( |
| | | Name = 'Test01', |
| | | ProductCode = 'Test01', |
| | | Asset_Model_No__c = 'Test01', |
| | | SFDA_Status__c = '有効', |
| | | JANCODE__c = '04953170200311', |
| | | Packing_list_manual__c = 12, |
| | | Dealer_special_Object__c = true, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod02 = new Product2( |
| | | Name = 'Test02', |
| | | ProductCode = 'Test02', |
| | | Asset_Model_No__c = 'Test02', |
| | | SFDA_Status__c = '有効', |
| | | JANCODE__c = '04953170200312', |
| | | Packing_list_manual__c = 10, |
| | | Dealer_special_Object__c = true, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod03 = new Product2( |
| | | Name = 'Test03', |
| | | ProductCode = 'Test03', |
| | | Asset_Model_No__c = 'Test03', |
| | | SFDA_Status__c = '有効', |
| | | JANCODE__c = '04953170200313', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 1, |
| | | Manual_Entry__c = false |
| | | ); |
| | | insert new List<Product2>{ prod01, prod02, prod03 }; |
| | | Product2__c pro1 = new Product2__c( |
| | | Name = 'Pro001', |
| | | OT_CODE_Text__c = 'Test001', |
| | | Product2__c = prod01.Id |
| | | ); |
| | | Product2__c pro2 = new Product2__c( |
| | | Name = 'Pro002', |
| | | OT_CODE_Text__c = 'Test002', |
| | | Product2__c = prod02.Id |
| | | ); |
| | | Product2__c pro3 = new Product2__c( |
| | | Name = 'Pro003', |
| | | OT_CODE_Text__c = 'Test003', |
| | | Product2__c = prod03.Id |
| | | ); |
| | | insert new List<Product2__c>{ pro1, pro2, pro3 }; |
| | | |
| | | Consumable_order__c Order1 = new Consumable_order__c(); |
| | | Order1.Name = 'OCM_01_001'; |
| | | Order1.Order_status__c = '批准'; |
| | | Order1.Order_type__c = '盘点'; |
| | | Order1.RecordTypeid = System.Label.RT_ConOrder_Inventory; |
| | | insert Order1; |
| | | |
| | | Consumable_order__c Order2 = new Consumable_order__c(); |
| | | Order2.Name = 'OCM_01_002'; |
| | | Order2.Order_status__c = '批准'; |
| | | Order2.Order_type__c = '订单'; |
| | | Order2.RecordTypeid = System.Label.RT_ConOrder_Order; |
| | | insert Order2; |
| | | |
| | | Consumable_order__c Order3 = new Consumable_order__c(); |
| | | Order3.Name = 'OCM_01_004'; |
| | | Order3.Order_status__c = '批准'; |
| | | Order3.Order_type__c = '到货'; |
| | | Order3.RecordTypeid = '01210000000c9dqAAA'; |
| | | insert Order3; |
| | | |
| | | Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c(); |
| | | Orderdet1.Name = 'OCM_01_001001'; |
| | | Orderdet1.Consumable_order__c = Order1.Id; |
| | | Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory; |
| | | |
| | | Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c(); |
| | | Orderdet2.Name = 'OCM_01_001002'; |
| | | Orderdet2.Consumable_order__c = Order1.Id; |
| | | Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory; |
| | | insert new List<Consumable_orderdetails__c>{ Orderdet1, Orderdet2 }; |
| | | |
| | | List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>(); |
| | | //产品类型不同 |
| | | Consumable_order_details2__c con = new Consumable_order_details2__c(); |
| | | con.Name = 'OCM_01_001001'; |
| | | con.Consumable_order_minor__c = Order1.Id; |
| | | con.Consumable_Product__c = pro2.Id; |
| | | con.Asset_Model_No__c = 'Test01'; |
| | | con.Arrive_date__c = Date.today(); |
| | | con.Bar_Code__c = '10011'; |
| | | con.Used_date__c = null; |
| | | con.Lose_Flag__c = false; |
| | | con.Return_date__c = null; |
| | | con.Send_Date__c = null; |
| | | con.Box_Piece__c = '盒'; |
| | | conList1.add(con); |
| | | insert conList1; |
| | | String eSetId = Order1.id; |
| | | System.Test.startTest(); |
| | | LexInventoryListController.init(eSetId); |
| | | |
| | | List<LexInventoryListController.ConsumableorderdetailsInfo> inList = LexInventoryListController.consumableorderdetailsRecords; |
| | | List<LexInventoryListController.ConsumableorderdetailsInfo> inList1 = new List<LexInventoryListController.ConsumableorderdetailsInfo>(); |
| | | for (LexInventoryListController.ConsumableorderdetailsInfo ass : inList) { |
| | | ass.orderdetails1 = Orderdet1; |
| | | inList1.add(ass); |
| | | } |
| | | LexInventoryListController.ConsumableorderdetailsInfo c2 = new LexInventoryListController.ConsumableorderdetailsInfo( |
| | | Orderdet1 |
| | | ); |
| | | c2.orderdetails1 = Orderdet1; |
| | | c2.Prod = Orderdet1.Consumable_product__r; |
| | | LexInventoryListController.ConsumableorderdetailsInfo c1 = new LexInventoryListController.ConsumableorderdetailsInfo( |
| | | con |
| | | ); |
| | | c1.orderdetails2 = con; |
| | | c1.Prod = con.Consumable_product__r; |
| | | c1.compareTo(c2); |
| | | System.Test.stopTest(); |
| | | } |
| | | } |
| | | } |
| | | } |