@isTest
|
private class Opponent_Bid_InformationHandlerTest {
|
|
@isTest static void test_method_one() {
|
// recode type を取得
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
throw new ControllerUtil.myException('not found 病院 recodetype');
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
throw new ControllerUtil.myException('not found 戦略科室分類 recodetype');
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
throw new ControllerUtil.myException('not found 診療科 recodetype');
|
}
|
List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Opponent_Bid_Information__c' and DeveloperName IN ('OpponentBidInformation') order by DeveloperName desc];
|
if (rectLost.size() == 0) {
|
throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
|
}
|
|
// insert
|
Account company1 = new Account();
|
company1.RecordTypeId = rectCo[0].Id;
|
company1.Name = '病院テスト1';
|
insert company1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[0].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = company1.Id;
|
insert depart1;
|
|
// 商談
|
Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
|
Hospital__c = company1.Id,
|
Department_Class__c = dc1s[0].Id,
|
AccountId = depart1.Id
|
);
|
insert opp1;
|
|
// 部分失单
|
Opponent_Bid_Information__c lcr1 = new Opponent_Bid_Information__c(
|
Opportunity__c = opp1.Id,
|
RecordTypeId = rectLost[0].Id
|
);
|
insert lcr1;
|
//test
|
lcr1.Report_Status__c = '批准';
|
update lcr1;
|
}
|
}
|