@isTest
|
private class UpdateTenderInformationBatch2Test {
|
static testMethod void testMethod1() {
|
StaticParameter.EscapeOpportunityBefUpdTrigger = true;
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test1';
|
insert acc1;
|
|
Account acc2 = new Account();
|
acc2.RecordTypeId = rectCo.Id;
|
acc2.Name = 'HP test2';
|
insert acc2;
|
|
|
List<Account> dept = [select Id, Name from Account where ParentId = :acc1.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[0].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = 'Gastoro Intestin Test';
|
depart1.ParentId = dept[0].Id;
|
depart1.Department_Class__c = dept[0].Id;
|
depart1.Hospital__c = acc1.Id;
|
|
List<Account> dept2 = [select Id, Name from Account where ParentId = :acc2.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart3 = new Account();
|
depart3.RecordTypeId = rectDpt[0].Id;
|
depart3.Name = '*';
|
depart3.Department_Name__c = 'Gastoro Intestin Test';
|
depart3.ParentId = dept2[0].Id;
|
depart3.Department_Class__c = dept2[0].Id;
|
depart3.Hospital__c = acc2.Id;
|
insert depart3;
|
|
|
RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
|
|
System.Test.StartTest();
|
//招标项目
|
Tender_information__c te1 = new Tender_information__c();
|
te1.Name = 'TestZhaoBiao1';
|
te1.IsReactionOpp__c = true;
|
insert te1;
|
|
Tender_information__c te2 = new Tender_information__c();
|
te2.Name = 'TestZhaoBiao2';
|
te2.IsReactionOpp__c = true;
|
insert te2;
|
|
Tender_information__c te3 = new Tender_information__c();
|
te3.Name = 'TestZhaoBiao3';
|
te3.IsReactionOpp__c = true;
|
insert te3;
|
|
StaticParameter.EscapeOppandStaTrigger = true;
|
|
Opportunity opp1 = new Opportunity(
|
Name = 'test opp1',
|
StageName = '引合',
|
CurrencyIsoCode = 'USD',
|
CloseDate = Date.today(),
|
AccountId = depart1.Id,
|
RecordTypeId = oppVND.Id,
|
Closing_Bid_Date__c = Date.today().addDays(-5),
|
Hospital__c = acc1.Id,
|
Competitor__c = 'A',
|
Bidding_Project_Name_Bid__c = te1.Id
|
);
|
Opportunity opp2 = new Opportunity(
|
Name = 'test opp2',
|
StageName = '引合',
|
CurrencyIsoCode = 'USD',
|
CloseDate = Date.today(),
|
AccountId = depart3.Id,
|
RecordTypeId = oppVND.Id,
|
Closing_Bid_Date__c = Date.today().addDays(-5),
|
Hospital__c = acc2.Id,
|
Competitor__c = 'B',
|
Bidding_Project_Name_Bid__c = te1.Id
|
);
|
insert new Opportunity[] {opp1, opp2};
|
|
Tender_Opportunity_Link__c tolc1 = new Tender_Opportunity_Link__c();
|
tolc1.Tender_information__c=te1.Id;
|
tolc1.Opportunity__c=opp1.Id;
|
tolc1.IsRelated__c=false;
|
insert tolc1;
|
Tender_Opportunity_Link__c tolc2 = new Tender_Opportunity_Link__c();
|
tolc2.Tender_information__c=te2.Id;
|
tolc2.Opportunity__c=opp1.Id;
|
tolc2.IsRelated__c=false;
|
insert tolc2;
|
Tender_Opportunity_Link__c tolc3 = new Tender_Opportunity_Link__c();
|
tolc3.Tender_information__c=te3.Id;
|
tolc3.Opportunity__c=opp1.Id;
|
tolc3.IsRelated__c=false;
|
insert tolc3;
|
Tender_Opportunity_Link__c tolc4 = new Tender_Opportunity_Link__c();
|
tolc4.Tender_information__c=te1.Id;
|
tolc4.Opportunity__c=opp2.Id;
|
tolc4.IsRelated__c=false;
|
insert tolc4;
|
|
Id execBTId = Database.executeBatch(new UpdateTenderInformationBatch2());
|
System.Test.StopTest();
|
|
}
|
}
|