@isTest
|
private class SparePartsSequencingBatchTest {
|
|
static testMethod void testMethod1() {
|
// 产品
|
Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',
|
Fixture_Model_No__c='TD-TB400',Serial_Lot_No__c='S/N tracing',
|
Fixture_Model_No_T__c = 'TD-TB400', Asset_Model_No__c = 'Pro1',
|
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',
|
Fixture_Model_No_T__c = 'n02', Asset_Model_No__c = 'Pro2',
|
ProductCode_Ext__c='pc02',Manual_Entry__c=false);
|
insert new Product2[] {pro1, pro2};
|
|
Date approval_date = Date.newInstance(2021, 4, 6);
|
|
//备品借出申请
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name = 'testra';
|
raObj.demo_purpose2__c = '其他';
|
raObj.Status__c ='已批准';
|
raObj.Request_approval_time__c = approval_date;
|
insert raObj;
|
|
//备品借出申请
|
Rental_Apply__c raObj1 = new Rental_Apply__c();
|
raObj1.Name = 'testra1';
|
raObj1.demo_purpose2__c = '其他';
|
raObj1.Status__c ='已批准';
|
raObj1.Request_approval_time__c = approval_date.addDays(1);
|
insert raObj1;
|
|
//OPD计划
|
OPDPlan__c opd1 = new OPDPlan__c();
|
opd1.Name = 'plan1';
|
opd1.Rental_Apply2__c = raObj.Id;
|
opd1.NoOpp_Reason__c = '突发事件对应';
|
insert opd1;
|
|
//OPD计划
|
OPDPlan__c opd2 = new OPDPlan__c();
|
opd2.Name = 'plan2';
|
opd2.Rental_Apply2__c = raObj1.Id;
|
opd2.NoOpp_Reason__c = '突发事件对应';
|
insert opd2;
|
|
// 备品配套
|
Fixture_Set__c fsObjA1 = new Fixture_Set__c();
|
fsObjA1.Name = 'set1';
|
fsObjA1.Fixture_Set_Body_Model_No__c = 'modelNo1';
|
fsObjA1.Loaner_name__c = 'name1';
|
insert fsObjA1;
|
|
// 备品配套明细
|
Fixture_Set_Detail__c fsdObjA1 = new Fixture_Set_Detail__c();
|
fsdObjA1.Name = '备品配套明细名1';
|
fsdObjA1.Product2__c = pro1.Id;
|
fsdObjA1.Fixture_Set__c = fsObjA1.Id;
|
fsdObjA1.UniqueKey__c = fsObjA1.Id + ':' + pro1.Id;
|
insert fsdObjA1;
|
|
OCM_Management_Province__c omp = new OCM_Management_Province__c();
|
omp.Name = '北京';
|
insert omp;
|
|
Date startat = Date.newInstance(2021, 4, 1);
|
Date endat = Date.newInstance(2021, 4, 29);
|
Database.executeBatch(new SparePartsSequencingBatch(startat, endat));
|
Database.executeBatch(new SparePartsSequencingBatch(startat, endat, '北京'));
|
}
|
|
}
|