@isTest
|
private class OpportunitySpecialApplyHandlerTest {
|
|
static void initHpData() {
|
|
}
|
@isTest static void test_method_one() {
|
ControllerUtil.EscapeNFM001Trigger = true;
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Agency'];
|
if (rectCo1.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSpec = [select Id from RecordType where IsActive = true and SobjectType = 'OpportunitySpecialApply__c' and Name = '注残特殊对应'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Name = 'TestCompany';
|
upsert company;
|
|
Account company1 = new Account();
|
company1.RecordTypeId = rectCo1[0].Id;
|
company1.Name = 'TestCompany1';
|
upsert company1;
|
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
|
System.Test.startTest();
|
Opportunity opp = new Opportunity();
|
opp.AccountId = depart.Id;
|
opp.Department_Class__c = section.Id;
|
opp.Hospital__c = company.Id;
|
opp.Name = 'GZ-SP-NFM007_1';
|
opp.Trade__c = '内貿';
|
opp.StageName = '引合';
|
opp.CloseDate = date.today().adddays(1);
|
opp.Agency1__c = company1.Id;
|
insert opp;
|
|
//注残
|
Statu_Achievements__c Sac2 = new Statu_Achievements__c();
|
Sac2.name = 'zhucan_two';
|
Sac2.Opportunity__c = opp.id;
|
Sac2.DeliveryDate__c = Date.today();
|
Sac2.ContractNO__c = 'ContractNO1';
|
Sac2.ContractAmount__c = 1;
|
insert Sac2;
|
|
OpportunitySpecialApply__c spec = new OpportunitySpecialApply__c();
|
spec.Status__c = '草案中';
|
spec.Apply_Content__c = '删除本月订货预测';
|
spec.Apply_Reason__c = 'NMPA影响';
|
spec.Opportunity__c = opp.Id;
|
spec.Achievements__c = Sac2.Id;
|
spec.Approval_Date__c = Date.today();
|
insert spec;
|
|
spec.Status__c = '已批准';
|
spec.Approval_Date__c = date.today();
|
update spec;
|
|
//注残
|
Statu_Achievements__c Sac = new Statu_Achievements__c();
|
Sac.name = 'zhucan_one';
|
Sac.Opportunity__c = opp.id;
|
Sac.DeliveryDate__c = Date.today();
|
Sac.ContractNO__c = 'ContractNO1';
|
Sac.ContractAmount__c = 1;
|
insert Sac;
|
|
OpportunitySpecialApply__c spec1 = new OpportunitySpecialApply__c();
|
spec1.Status__c = '草案中';
|
spec1.Apply_Content__c = '新增本月发货预测';
|
spec1.Apply_Reason__c = 'NMPA影响';
|
spec1.Opportunity__c = opp.Id;
|
spec1.Achievements__c = Sac.Id;
|
spec1.RecordTypeId = rectSpec[0].Id;
|
spec1.Approval_Date__c = Date.today();
|
insert spec1;
|
|
spec1.Status__c = '已批准';
|
spec1.Approval_Date__c = date.today();
|
update spec1;
|
|
|
OpportunitySpecialApply__c spec3 = new OpportunitySpecialApply__c();
|
spec3.Status__c = '草案中';
|
spec3.Apply_Content__c = '新增本月发货预测';
|
spec3.Apply_Reason__c = 'NMPA影响';
|
spec3.Opportunity__c = opp.Id;
|
spec3.Achievements__c = Sac.Id;
|
spec3.RecordTypeId = rectSpec[0].Id;
|
spec3.Approval_Date__c = Date.today();
|
spec3.Status__c = '已批准';
|
insert spec3;
|
|
OpportunitySpecialApply__c spec4 = new OpportunitySpecialApply__c();
|
spec4.Status__c = '草案中';
|
spec4.Apply_Content__c = '删除本月发货预测';
|
spec4.Apply_Reason__c = 'NMPA影响';
|
spec4.Opportunity__c = opp.Id;
|
spec4.Achievements__c = Sac.Id;
|
spec4.RecordTypeId = rectSpec[0].Id;
|
spec4.Approval_Date__c = Date.today();
|
spec4.Status__c = '已批准';
|
insert spec4;
|
|
System.Test.StopTest();
|
}
|
|
|
}
|