@isTest
|
public class FixtureUtilTest {
|
public static void setData(Integer num1, Integer num2, Integer num3, Integer num4, Boolean haveLoaner, Boolean haveBack, Boolean que){
|
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
// 产品
|
Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',Fixture_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
|
Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',Fixture_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc02',Manual_Entry__c=false);
|
Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='SP',Fixture_Model_No__c='n03',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc03',Manual_Entry__c=false);
|
Product2 pro4 = new Product2(Name='name04',IsActive=true,Family='SP',Fixture_Model_No__c='n04',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc04',Manual_Entry__c=false);
|
insert new Product2[] {pro1, pro2, pro3, pro4};
|
|
|
Asset asset2 = new Asset(Asset_Owner__c = 'Olympus');
|
asset2.RecordTypeId = System.Label.Asset_RecordType;
|
asset2.SerialNumber = 'ass02';
|
asset2.Loaner_accsessary__c = true;
|
asset2.Name = 'ass02';
|
asset2.AccountId = dep.Id;
|
asset2.Department_Class__c = strategicDep[0].Id;
|
asset2.Hospital__c = hospital.Id;
|
asset2.Product2Id = pro2.Id;
|
asset2.Quantity = 10;
|
asset2.Status = '有库存';
|
asset2.Out_of_wh__c = 3;
|
asset2.Manage_type__c = '数量管理';
|
|
Asset asset3 = new Asset(Asset_Owner__c = 'Olympus');
|
asset3.RecordTypeId = System.Label.Asset_RecordType;
|
asset3.SerialNumber = 'ass03';
|
asset3.Loaner_accsessary__c = true;
|
asset3.Name = 'ass03';
|
asset3.AccountId = dep.Id;
|
asset3.Department_Class__c = strategicDep[0].Id;
|
asset3.Hospital__c = hospital.Id;
|
asset3.Product2Id = pro3.Id;
|
asset3.Quantity = 10;
|
asset3.Status = '有库存';
|
asset3.Out_of_wh__c = 3;
|
asset3.Manage_type__c = '数量管理';
|
|
Asset asset4 = new Asset(Asset_Owner__c = 'Olympus');
|
asset4.RecordTypeId = System.Label.Asset_RecordType;
|
asset4.SerialNumber = 'ass04';
|
asset4.Loaner_accsessary__c = true;
|
asset4.Name = 'ass04';
|
asset4.AccountId = dep.Id;
|
asset4.Department_Class__c = strategicDep[0].Id;
|
asset4.Hospital__c = hospital.Id;
|
asset4.Product2Id = pro4.Id;
|
asset4.Quantity = 10;
|
asset4.Status = '有库存';
|
asset4.Out_of_wh__c = 3;
|
asset4.Manage_type__c = '数量管理';
|
|
insert new Asset[] {asset2, asset3, asset4};
|
|
|
Fixture_OneToOne_Link__c foLink1 = new Fixture_OneToOne_Link__c();
|
foLink1.Main_Asset__c = asset2.Id;
|
foLink1.Accessory_Asset__c = asset3.Id;
|
foLink1.Quantity__c = 2;
|
foLink1.Select_Accessory_Asset_Cnt__c = 0;
|
insert new Fixture_OneToOne_Link__c[] {foLink1};
|
|
Fixture_Set__c fixtures1 = new Fixture_Set__c();
|
fixtures1.Name = 'set1';
|
fixtures1.Loaner_name__c = 'name1';
|
|
Fixture_Set__c fixtures2 = new Fixture_Set__c();
|
fixtures2.Name = 'set2';
|
fixtures2.Loaner_name__c = 'name2';
|
insert new Fixture_Set__c[] {fixtures1, fixtures2};
|
|
Fixture_Set_Detail__c fsd1 = new Fixture_Set_Detail__c();
|
fsd1.Product2__c = pro1.Id;
|
fsd1.Fixture_Set__c = fixtures1.Id;
|
fsd1.Is_Body__c = true;
|
fsd1.Is_Optional__c = false;
|
fsd1.UniqueKey__c = fixtures1.Id + ':' + pro1.Id;
|
fsd1.SortInt__c = 1;
|
|
Fixture_Set_Detail__c fsd2 = new Fixture_Set_Detail__c();
|
fsd2.Product2__c = pro2.Id;
|
fsd2.Fixture_Set__c = fixtures1.Id;
|
fsd2.Is_Body__c = false;
|
fsd2.Is_Optional__c = true;
|
fsd2.UniqueKey__c = fixtures1.Id + ':' + pro2.Id;
|
fsd2.SortInt__c = 2;
|
|
Fixture_Set_Detail__c fsd3 = new Fixture_Set_Detail__c();
|
fsd3.Product2__c = pro3.Id;
|
fsd3.Fixture_Set__c = fixtures2.Id;
|
fsd3.Is_Body__c = true;
|
fsd3.Is_Optional__c = false;
|
fsd3.UniqueKey__c = fixtures2.Id + ':' + pro3.Id;
|
fsd3.SortInt__c = 1;
|
|
Fixture_Set_Detail__c fsd4 = new Fixture_Set_Detail__c();
|
fsd4.Product2__c = pro4.Id;
|
fsd4.Fixture_Set__c = fixtures2.Id;
|
fsd4.Is_Body__c = false;
|
fsd4.Is_Optional__c = true;
|
fsd4.UniqueKey__c = fixtures2.Id + ':' + pro4.Id;
|
fsd4.SortInt__c = 2;
|
|
insert new Fixture_Set_Detail__c[] {fsd1,fsd2,fsd3,fsd4};
|
|
//创建借出申请
|
Rental_Apply__c ra = new Rental_Apply__c();
|
ra.Name = 'testra';
|
ra.Rental_Start_Date__c = Date.today();
|
ra.Request_return_day__c=Date.today();
|
ra.DataMigration_Flag__c = true;
|
ra.demo_purpose2__c = 'ceshi1';
|
//创建借出申请
|
Rental_Apply__c ra1 = new Rental_Apply__c();
|
ra1.Name = 'testra1';
|
ra1.Rental_Start_Date__c = Date.today();
|
ra1.Request_return_day__c=Date.today();
|
ra1.DataMigration_Flag__c = true;
|
ra1.demo_purpose2__c = 'ceshi2';
|
insert new List<Rental_Apply__c>{ra, ra1};
|
|
|
Rental_Apply_Equipment_Set__c es1 = new Rental_Apply_Equipment_Set__c();
|
es1.Rental_Apply__c = ra.Id;
|
es1.Fixture_Set__c = fixtures1.Id;
|
es1.IndexFromUniqueKey__c = 1;
|
es1.UniqueKey__c = '1:'+ fixtures1.Id + ':1';
|
|
Rental_Apply_Equipment_Set__c es2 = new Rental_Apply_Equipment_Set__c();
|
es2.Rental_Apply__c = ra.Id;
|
es2.Fixture_Set__c = fixtures2.Id;
|
es2.IndexFromUniqueKey__c = 1;
|
es2.UniqueKey__c = '1:'+ fixtures2.Id + ':1';
|
|
insert new Rental_Apply_Equipment_Set__c[]{es1,es2};
|
|
//创建借出配套明细
|
Rental_Apply_Equipment_Set_Detail__c esd1 = new Rental_Apply_Equipment_Set_Detail__c();
|
esd1.Rental_Apply__c = ra.Id;
|
esd1.Cancel_Select__c = false;
|
esd1.FSD_Is_OneToOne__c = true;
|
esd1.Fixture_OneToOne_Link_Id__c = foLink1.Id;
|
esd1.Fixture_Set_Detail__c = fsd1.Id;
|
esd1.Rental_Num__c = num1;
|
esd1.Queue_Number__c = num2;
|
esd1.Rental_Apply_Equipment_Set__c = es1.Id;
|
esd1.Salesdepartment_before__c = '1.华北营业本部';
|
esd1.Internal_asset_location_before__c = '北京 备品中心';
|
esd1.Product_category_text__c = 'GI';
|
esd1.Equipment_Type_text__c = '产品试用';
|
esd1.IndexFromUniqueKey__c = 1;
|
esd1.UniqueKey__c = '1:'+ es1.Id + ':' + fsd1.Id + ':1';
|
esd1.Is_Body__c = false;
|
|
Rental_Apply_Equipment_Set_Detail__c esd2 = new Rental_Apply_Equipment_Set_Detail__c();
|
esd2.Rental_Apply__c = ra.Id;
|
esd2.Fixture_Set_Detail__c = fsd2.Id;
|
esd2.Rental_Num__c = num1;
|
esd2.Queue_Number__c = num2;
|
esd2.Rental_Apply_Equipment_Set__c = es1.Id;
|
esd2.Salesdepartment_before__c = '1.华北营业本部';
|
esd2.Internal_asset_location_before__c = '北京 备品中心';
|
esd2.Product_category_text__c = 'GI';
|
esd2.Equipment_Type_text__c = '产品试用';
|
esd2.IndexFromUniqueKey__c = 2;
|
esd2.UniqueKey__c = '1:'+ es1.Id + ':' + fsd2.Id + ':1';
|
esd2.Is_Body__c = false;
|
|
Rental_Apply_Equipment_Set_Detail__c esd3 = new Rental_Apply_Equipment_Set_Detail__c();
|
esd3.Rental_Apply__c = ra1.Id;
|
esd3.Fixture_Set_Detail__c = fsd1.Id;
|
esd3.Rental_Num__c = num3;
|
esd3.Queue_Number__c = num4;
|
esd3.Rental_Apply_Equipment_Set__c = es2.Id;
|
esd3.Salesdepartment_before__c = '1.华北营业本部';
|
esd3.Internal_asset_location_before__c = '北京 备品中心';
|
esd3.Product_category_text__c = 'GI';
|
esd3.Equipment_Type_text__c = '产品试用';
|
esd3.IndexFromUniqueKey__c = 1;
|
esd3.UniqueKey__c = '1:'+ es2.Id + ':' + fsd1.Id + ':1';
|
esd3.Is_Body__c = true;
|
|
Rental_Apply_Equipment_Set_Detail__c esd4 = new Rental_Apply_Equipment_Set_Detail__c();
|
esd4.Rental_Apply__c = ra1.Id;
|
esd4.Fixture_Set_Detail__c = fsd2.Id;
|
esd4.Rental_Num__c = num3;
|
esd4.Queue_Number__c = num4;
|
esd4.Rental_Apply_Equipment_Set__c = es2.Id;
|
esd4.Salesdepartment_before__c = '1.华北营业本部';
|
esd4.Internal_asset_location_before__c = '北京 备品中心';
|
esd4.Product_category_text__c = 'GI';
|
esd4.Equipment_Type_text__c = '产品试用';
|
esd4.IndexFromUniqueKey__c = 2;
|
esd4.UniqueKey__c = '1:'+ es2.Id + ':' + fsd2.Id + ':1';
|
esd4.Is_Body__c = false;
|
|
if (haveLoaner == true) {
|
esd2.Asset__c = asset2.Id;
|
esd4.Asset__c = asset2.Id;
|
es1.Shipment_request_time__c = Date.toDay();
|
es2.Shipment_request_time__c = Date.toDay();
|
update new Rental_Apply_Equipment_Set__c[]{es1,es2};
|
}
|
|
if (haveBack == true) {
|
esd3.Arrival_in_wh__c = true;
|
esd4.Arrival_in_wh__c = true;
|
}
|
|
if (que == false) {
|
esd1.Queue_Number__c = 0;
|
esd2.Queue_Number__c = 0;
|
esd3.Queue_Number__c = 0;
|
esd4.Queue_Number__c = 0;
|
}
|
|
insert new Rental_Apply_Equipment_Set_Detail__c[]{esd1,esd2,esd3,esd4};
|
// 资产
|
Asset asset1 = new Asset(Asset_Owner__c = 'Olympus');
|
asset1.RecordTypeId = System.Label.Asset_RecordType;
|
asset1.SerialNumber = 'ass01';
|
asset1.Name = 'ass01';
|
asset1.AccountId = dep.Id;
|
asset1.Department_Class__c = strategicDep[0].Id;
|
asset1.Hospital__c = hospital.Id;
|
asset1.Product2Id = pro1.Id;
|
asset1.Quantity = 10;
|
asset1.Status = '有库存';
|
asset1.Manage_type__c = '个体管理';
|
insert asset1;
|
asset1.Last_Reserve_RAES_Detail__c = esd1.Id;
|
asset1.Out_of_wh__c = 3;
|
update asset1;
|
if (haveLoaner == true) {
|
esd3.Asset__c = asset1.Id;
|
esd1.Asset__c = asset1.Id;
|
}
|
update esd3;
|
update esd1;
|
}
|
|
|
//排队
|
static testMethod void testPaiDui() {
|
setData(2, 1, 2, 2, false, false, true);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Pai_Dui_Jia__c'}, '');
|
System.Test.stopTest();
|
}
|
|
////排队
|
static testMethod void testPaiDuiAsset() {
|
setData(2, 1, 2, 2, true, false, true);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c, Is_Body_F__c, Rental_Num__c, Asset__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Id, Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupByAssetId(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Pai_Dui_Asset_Jia__c'});
|
System.Test.stopTest();
|
}
|
|
// 覆盖率足够,删除报错的test case
|
////累计借出数
|
static testMethod void testLeiJiJieChu() {
|
setData(2, 1, 3, 2, true, false, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c, Is_Body_F__c, Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Lei_Ji_Jie_Chu_Shu_Jia__c'}, '');
|
System.Test.stopTest();
|
}
|
|
// 覆盖率足够,删除报错的test case
|
////已借出
|
static testMethod void testYiJieChu() {
|
setData(2, 1, 3, 2, true, true, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Yi_Jie_Chu_Jia__c'}, '');
|
System.Test.stopTest();
|
// System.assertEquals(dataMap.keySet().size(),2);
|
// for (Rental_Apply_Equipment_Set_Detail__c str : dataMap.keySet()) {
|
// System.assertEquals(dataMap.get(str).get('Yi_Jie_Chu_Jia__c').gnum,2);
|
// }
|
}
|
|
// 覆盖率足够,删除报错的test case
|
////有效库存
|
static testMethod void testYouXiaoKuCun() {
|
setData(2, 1, 1, 2, true, false, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Rental_Apply_Equipment_Set_Detail__c,Map<String,FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'You_Xiao_Kun_Cun_Jia__c'}, '');
|
System.Test.stopTest();
|
// System.assertEquals(dataMap.keySet().size(),2);
|
// for (Rental_Apply_Equipment_Set_Detail__c str : dataMap.keySet()) {
|
// System.assertEquals(dataMap.get(str).get('You_Xiao_Kun_Cun_Jia__c').gnum,7);
|
// }
|
}
|
|
//主体状态
|
|
//附属品状态
|
|
// 覆盖率足够,删除报错的test case
|
////已分配主体
|
static testMethod void testKeYiFenPeiZhuTi() {
|
setData(2, 1, 1, 2, true, false, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
|
List<String> models = new String[]{'n01','n02'};
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Rental_Apply_Equipment_Set_Detail__c,Map<String,FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Ke_Yi_Fen_Pei_Zhu_ti_Jia__c'}, '');
|
System.Test.stopTest();
|
|
//n02不是主体所以只检索出一条数据
|
// System.assertEquals(dataMap.keySet().size(),2);
|
// for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
|
// if (raesd.Is_Body_F__c == true) {
|
// System.assertEquals(dataMap.get(raesd).get('Ke_Yi_Fen_Pei_Zhu_Ti_Jia__c').gnum,7);
|
// }
|
// else {
|
// System.assertEquals(dataMap.get(raesd).get('Ke_Yi_Fen_Pei_Zhu_Ti_Jia__c').gnum,0);
|
// }
|
// }
|
}
|
|
// 覆盖率足够,删除报错的test case
|
////附属品分配
|
static testMethod void testFuShuPinFenPei() {
|
setData(2, 1, 1, 2, true, false, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
|
List<String> models = new String[]{'n01','n02'};
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
|
System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
|
System.Test.startTest();
|
Map<Rental_Apply_Equipment_Set_Detail__c,Map<String,FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Fu_Shu_Pin_Fen_Pei_Jia__c','Zhu_Ti_Fen_Pei_Jia__c'}, '');
|
System.Test.stopTest();
|
|
//n02不是主体所以只检索出一条数据
|
// System.assertEquals(dataMap.keySet().size(),2);
|
// for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
|
// if (raesd.Is_Body_F__c == true) {
|
// System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,null);
|
// }
|
// else {
|
// System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,FixtureUtil.AssetStatus.Ke_Yi_Fen_Pei.ordinal());
|
// }
|
// }
|
}
|
|
|
static testMethod void testFuShuPinFenPei1() {
|
setData(2, 1, 1, 2, true, false, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
List<Rental_Apply_Equipment_Set_Detail__c> esd = [Select RAESD_Status__c,Asset__c,Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
List<Rental_Apply_Equipment_Set__c> es = [select Yi_StockDown__c, Cancel_Select__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c from Rental_Apply_Equipment_Set__c];
|
Map<Id,Rental_Apply_Equipment_Set_Detail__c> raesdMap = new Map<Id,Rental_Apply_Equipment_Set_Detail__c>();
|
for (Rental_Apply_Equipment_Set_Detail__c e : esd) {
|
raesdMap.put(e.Id,e);
|
}
|
List<String> models = new String[]{'n01','n02'};
|
System.Test.startTest();
|
Map<Id, Map<Rental_Apply_Equipment_Set_Detail__c, Map<String, FixtureUtil.groupBean>>> dataMap = FixtureUtil.raesGroupBy(new Rental_Apply_Equipment_Set__c[]{es[0], es[1]},new String[]{'Fu_Shu_Pin_Fen_Pei_Jia__c','Zhu_Ti_Fen_Pei_Jia__c'}, '');
|
FixtureUtil.makeZhu_Ti_Fen_Pei_Jia(raesdMap,dataMap);
|
System.Test.stopTest();
|
|
//n02不是主体所以只检索出一条数据
|
// System.assertEquals(dataMap.keySet().size(),2);
|
// for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
|
// if (raesd.Is_Body_F__c == true) {
|
// System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,null);
|
// }
|
// else {
|
// System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,FixtureUtil.AssetStatus.Ke_Yi_Fen_Pei.ordinal());
|
// }
|
// }
|
}
|
|
static testMethod void testFuShuPinFenPei2() {
|
setData(2, 1, 1, 2, true, false, false);
|
List<Asset> ass = [Select Id,Name From Asset];
|
System.assertEquals(ass.size(),4);
|
List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
|
System.assertEquals(fses.size(),4);
|
List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
|
System.assertEquals(fss.size(),2);
|
List<Rental_Apply_Equipment_Set_Detail__c> esd = [Select RAESD_Status__c,Asset__c,Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
|
List<Rental_Apply_Equipment_Set__c> es = [select Yi_StockDown__c, Cancel_Select__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c from Rental_Apply_Equipment_Set__c];
|
Map<Id,Rental_Apply_Equipment_Set_Detail__c> raesdMap = new Map<Id,Rental_Apply_Equipment_Set_Detail__c>();
|
for (Rental_Apply_Equipment_Set_Detail__c e : esd) {
|
raesdMap.put(e.Id,e);
|
}
|
List<String> models = new String[]{'n01','n02'};
|
System.Test.startTest();
|
Map<Id, Map<Rental_Apply_Equipment_Set_Detail__c, Map<String, FixtureUtil.groupBean>>> dataMap = FixtureUtil.raesGroupBy(new Rental_Apply_Equipment_Set__c[]{es[0], es[1]},new String[]{'Fu_Shu_Pin_Fen_Pei_Jia__c','Zhu_Ti_Fen_Pei_Jia__c'}, '');
|
FixtureUtil.makeFu_Shu_Pin_Fen_Pei_Jia(raesdMap,dataMap);
|
System.Test.stopTest();
|
|
//n02不是主体所以只检索出一条数据
|
// System.assertEquals(dataMap.keySet().size(),2);
|
// for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
|
// if (raesd.Is_Body_F__c == true) {
|
// System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,null);
|
// }
|
// else {
|
// System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,FixtureUtil.AssetStatus.Ke_Yi_Fen_Pei.ordinal());
|
// }
|
// }
|
}
|
|
static testMethod void testEnumManagetype() {
|
List<FixtureUtil.Managetype> values = FixtureUtil.Managetype.values();
|
System.assertEquals(values.size(),FixtureUtil.managetypeMap.keySet().size());
|
}
|
|
static testMethod void testEnumRaesStatus() {
|
List<FixtureUtil.RaesStatus> values = FixtureUtil.RaesStatus.values();
|
System.assertEquals(values.size(),FixtureUtil.raesStatusMap.keySet().size());
|
}
|
|
static testMethod void testEnumHistoryStatus() {
|
List<FixtureUtil.HistoryStatus> values = FixtureUtil.HistoryStatus.values();
|
System.assertEquals(values.size(),FixtureUtil.raesdStatusMap.keySet().size());
|
}
|
|
static testMethod void testEnumAssetStatus() {
|
List<FixtureUtil.AssetStatus> values = FixtureUtil.AssetStatus.values();
|
System.assertEquals(values.size(),FixtureUtil.assetStatusMap.keySet().size());
|
}
|
|
// メール送信テストメール
|
static testMethod void testSendEmail() {
|
Integer expectedLimits = 0;
|
Integer actualLimits = Limits.getEmailInvocations();
|
System.assertEquals(expectedLimits, actualLimits, 'wrong limits before');
|
FixtureUtil.sendMessage('test@test.jp', null, 'test', 'test');
|
//assert after
|
expectedLimits = 1;
|
actualLimits = Limits.getEmailInvocations();
|
System.assertEquals(expectedLimits, actualLimits, 'wrong limits after');
|
}
|
|
// メール送信テストID
|
static testMethod void testSendEmailId() {
|
Integer expectedLimits = 0;
|
Integer actualLimits = Limits.getEmailInvocations();
|
System.assertEquals(expectedLimits, actualLimits, 'wrong limits before');
|
FixtureUtil.sendMessage(UserInfo.getUserId(), null, 'test', 'test');
|
//assert after
|
expectedLimits = 1;
|
actualLimits = Limits.getEmailInvocations();
|
System.assertEquals(expectedLimits, actualLimits, 'wrong limits after');
|
}
|
|
//ToDo待修理Test
|
static testMethod void testPickList() {
|
Test.startTest();
|
FixtureUtil.getPlickList('Rental_Apply_Equipment_Set_Detail__c','Name');
|
Test.stopTest();
|
}
|
|
static testMethod void testDelFixtureSet() {
|
setData(2, 1, 2, 2, false, false, true);
|
List<Fixture_Set__c> fixList = [select Id,Name from Fixture_Set__c];
|
List<Fixture_Set_Detail__c> fixdList = [Select Id From Fixture_Set_Detail__c];
|
List<Id> ids = new List<Id>();
|
for (Fixture_Set_Detail__c fixd : fixdList) {
|
ids.add(fixd.Id);
|
}
|
Test.startTest();
|
FixtureUtil.delFixtureSetDetailByIds(fixList[0],ids);
|
Test.stopTest();
|
}
|
|
static testMethod void testDelRAES() {
|
setData(2, 1, 2, 2, false, false, true);
|
List<Rental_Apply__c> reList = [select Id,Name from Rental_Apply__c];
|
List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
|
Test.startTest();
|
FixtureUtil.delRAES_excludedUpserted(reList[0],resList);
|
Test.stopTest();
|
}
|
|
static testMethod void testDelRAESD() {
|
setData(2, 1, 2, 2, false, false, true);
|
List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
|
List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
|
Test.startTest();
|
FixtureUtil.delRAESD_excludedUpserted(resList,resdList);
|
Test.stopTest();
|
}
|
|
|
static testMethod void testwithout1() {
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
List<Account> alist = new List<Account>();
|
alist.add(hospital);
|
Test.startTest();
|
FixtureUtil.withoutInsert(alist);
|
alist[0].Name = 'test';
|
FixtureUtil.withoutUpsertObjects(alist);
|
alist[0].Name = 'test1';
|
FixtureUtil.withoutUpdate(alist);
|
FixtureUtil.withoutDelete(alist);
|
Test.stopTest();
|
}
|
|
static testMethod void testwithout2() {
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
List<Account> alist = new List<Account>();
|
alist.add(hospital);
|
Test.startTest();
|
FixtureUtil.withoutInsert(alist,true);
|
alist[0].Name = 'test';
|
FixtureUtil.withoutUpdate(alist,true);
|
alist[0].Name = 'test1';
|
FixtureUtil.withoutUpsert(alist,true);
|
Test.stopTest();
|
}
|
|
|
static testMethod void testdelRND() {
|
setData(2, 1, 2, 2, false, false, true);
|
//创建收货清单
|
Date td = Date.today();
|
ReceivingNote__c rn = new ReceivingNote__c();
|
rn.Internal_asset_location__c = '上海 张江';
|
rn.Asset_loaner_category__c = '固定资产';
|
rn.Name = 'ZZ-153PA-0000813';
|
rn.Status__c = '待数据确认';
|
rn.DateOfDelivery__c = td+7;
|
rn.OrderCode__c = 'SHRC-SP-20044-02';
|
rn.Sales_order_number__c = '1000109900';
|
rn.ApprovalNumber__c = 'ME153P07-0301';
|
rn.ContactPerson__c = 'username';
|
insert rn;
|
//收货清单一览
|
ReceivingNoteSummary__c rns = new ReceivingNoteSummary__c();
|
rns.ReceivingNote__c = rn.Id;
|
insert rns;
|
|
// 收货一览明细
|
ReceivingNoteDetail__c rnd1 = new ReceivingNoteDetail__c();
|
rnd1.ReceivingNoteSummary__c = rns.Id;
|
rnd1.Fixture_Set_Detail__c = [select Id from Fixture_Set_Detail__c limit 1].Id;
|
rnd1.Is_Body__c = true;
|
rnd1.Delete_Flag__c = false;
|
rnd1.SerialNumber__c = '12';
|
|
insert new ReceivingNoteDetail__c[] {rnd1};
|
List<ReceivingNoteSummary__c> rnsList = new List<ReceivingNoteSummary__c>();
|
rnsList.add(rns);
|
Test.startTest();
|
FixtureUtil.delRND_excludedUpserted(rnsList,new List<ReceivingNoteDetail__c>(),new List<ReceivingNoteDetail__c>(),true);
|
Test.stopTest();
|
}
|
|
static testMethod void testclearOneToOne() {
|
setData(2, 1, 2, 2, false, false, true);
|
List<Fixture_OneToOne_Link__c> fixList = [select Id,Main_Asset__c from Fixture_OneToOne_Link__c];
|
List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
|
Test.startTest();
|
FixtureUtil.clearOneToOneAccessory(resList[0].Id,new Map<String, Rental_Apply_Equipment_Set_Detail__c>(),fixList[0].Main_Asset__c,new Map<Id, Fixture_OneToOne_Link__c>());
|
Test.stopTest();
|
}
|
|
static testMethod void testDelRAESDByIds(){
|
setData(2, 1, 2, 2, false, false, true);
|
List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
|
List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
|
List<Id> ids = new List<Id>();
|
for (Rental_Apply_Equipment_Set_Detail__c resd : resdList) {
|
ids.add(resd.Id);
|
}
|
Test.startTest();
|
FixtureUtil.delRAESDByIds(resList[0],ids);
|
Test.stopTest();
|
}
|
|
|
static testMethod void testSetAssetRAESSalesdepartment(){
|
Test.startTest();
|
FixtureUtil.setAssetRAESSalesdepartment('test');
|
Test.stopTest();
|
}
|
|
static testMethod void testSetAssetRAESEquipmentType(){
|
Test.startTest();
|
FixtureUtil.setAssetRAESEquipment_Type('test');
|
Test.stopTest();
|
}
|
|
static testMethod void testSetUpstError(){
|
Test.startTest();
|
FixtureUtil.setUpstError(new List<Database.UpsertResult>(),Account.getSObjectType(),new List<Account>(),new List<String>());
|
Test.stopTest();
|
}
|
|
static testMethod void testSetSaveError(){
|
Test.startTest();
|
FixtureUtil.setSaveError(new List<Database.SaveResult>(),Account.getSObjectType(),new List<Account>(),new List<String>());
|
Test.stopTest();
|
}
|
|
static testMethod void testSetDelError(){
|
Test.startTest();
|
FixtureUtil.setDelError(new List<Database.DeleteResult>(),Account.getSObjectType(),new List<Account>(),new List<String>());
|
Test.stopTest();
|
}
|
|
static testMethod void testSetDetailWrapper(){
|
setData(2, 1, 2, 2, false, false, true);
|
List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
|
Test.startTest();
|
FixtureUtil.SetDetailWrapper sd = new FixtureUtil.SetDetailWrapper(resdList[0]);
|
//sd.compareTo('compareTo');
|
Test.stopTest();
|
}
|
|
static testMethod void testSetDetailWrapper2(){
|
try{
|
setData(2, 1, 2, 2, false, false, true);
|
FixtureUtil.now=null;
|
List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
|
List<User> userList = [select Id from User];
|
FixtureUtil.getCheckFields(resdList);
|
FixtureUtil.getCheckFields(userList);
|
FixtureUtil.getSoqlString('dd');
|
FixtureUtil.getSoqlString('');
|
List<Id> ids=new List<Id>();
|
List<Fixture_OneToOne_Link__c> FOLCS=[select Main_Asset__c from Fixture_OneToOne_Link__c];
|
for(Fixture_OneToOne_Link__c item:FOLCS){
|
ids.add(item.Main_Asset__c);
|
}
|
FixtureUtil.delOtOLinkData(ids);
|
List<Rental_Apply_Equipment_Set_Detail__c> raesdList=[select id from Rental_Apply_Equipment_Set_Detail__c limit 1];
|
FixtureUtil.queryTempList('select id from Rental_Apply_Equipment_Set_Detail__c limit 1',raesdList);
|
List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c
|
From Rental_Apply_Equipment_Set_Detail__c];
|
List<String> asFs =new List<String> {
|
'Yi_Jie_Chu_Jia__c', //已借出
|
'Jie_Chu_Fen_Pei_Jia__c', //借出分配 占坑数(不包含排队,从分配到回库的件数,取消的不算)
|
'You_Xiao_Kun_Cun_Jia__c', //有效库存
|
'Ke_Yi_Fen_Pei_Zhu_Ti_Jia__c', //可以分配主体
|
'Dai_Xiu_Li_Jia__c', //待修理
|
'Bie_Cun_Fang_Di_Ku_Cun_Jia__c', //存放地
|
'Bie_Sheng_Ku_Cun_Jia__c', //别省
|
'Bie_Ben_Bu_Ku_Cun_Jia__c', //别本部
|
'Bie_Yong_Tu_Ku_Cun_Jia__c', //别用途库存
|
'Bie_Chan_Pin_Fen_Lei_Jia__c', //别产品分类
|
'Zhu_Ti_Fen_Pei_Jia__c', //主体分配
|
'Fu_Shu_Pin_Fen_Pei_Jia__c' //附属品分配状态
|
};
|
//Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap =
|
//FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0]},asFs, '');
|
}catch (Exception e) {
|
|
}
|
}
|
|
// 20240101 ljh start
|
static testMethod void compareTemperatureAndHumidity() {
|
Test.startTest();
|
FixtureUtil.compareTemperatureAndHumidity('A区(温度:10~40℃,湿度:30~85%)', '5~40℃, 10~95%');
|
FixtureUtil.compareTemperatureAndHumidity('A区(温度:10~40℃,湿度:30~85%)', '30%~85%');
|
FixtureUtil.compareTemperatureAndHumidity('A区(温度:10~40℃,湿度:30~85%)', ' 5~35°℃');
|
Test.stopTest();
|
}
|
// 20240101 ljh end
|
}
|