From 744f42c5496e656a1f9927740a3b37c0b97a6cba Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 14 七月 2023 14:34:12 +0800 Subject: [PATCH] lexcommunityupload0714 --- force-app/main/default/classes/LexInventoryListControllerTest.cls | 268 +++++++++++++++++++--------------------------------- 1 files changed, 99 insertions(+), 169 deletions(-) diff --git a/force-app/main/default/classes/LexInventoryListControllerTest.cls b/force-app/main/default/classes/LexInventoryListControllerTest.cls index 635926c..86c754d 100644 --- a/force-app/main/default/classes/LexInventoryListControllerTest.cls +++ b/force-app/main/default/classes/LexInventoryListControllerTest.cls @@ -1,172 +1,102 @@ @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 = '璨╁2搴�' - ]; - 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 = '璨╁2搴�']; + 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(); - } - } -} +} \ No newline at end of file -- Gitblit v1.9.1