@isTest
|
private class SelectRepairPDFDeleteBatchTest {
|
static testMethod void testMethod1() {
|
StaticParameter.ContentDocumentLink=false;
|
StaticParameter.ContentDocumentTrigger = false;
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_Class_GI'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
|
// 病院作成
|
Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = UserInfo.getUserId());
|
hp.FSE_GI_Main_Leader__c = UserInfo.getUserId();
|
hp.FSE_SP_Main_Leader__c = UserInfo.getUserId();
|
insert hp;
|
|
Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
|
|
// 診療科を作る
|
Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
|
dpt.Name = '*';
|
dpt.Department_Name__c = 'TestDepart';
|
dpt.ParentId = dc.Id;
|
dpt.Department_Class__c = dc.Id;
|
dpt.Hospital__c = hp.Id;
|
insert dpt;
|
|
//Product2 productA = new Product2( Name='テスト商品');
|
//insert productA;
|
|
//// 価格表エントリを作成する
|
//PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
|
//entry.UnitPrice = 0;
|
//entry.IsActive = true;
|
//entry.UseStandardPrice = false;
|
//entry.CurrencyIsoCode = 'CNY';
|
//entry.Product2Id = productA.Id;
|
//insert entry;
|
|
// 納入機器を作成する
|
Asset asset = new Asset();
|
asset.Name = 'テスト機器';
|
asset.AccountId = dpt.Id;
|
asset.Department_Class__c = dc.Id;
|
asset.Hospital__c = hp.Id;
|
asset.SerialNumber = 'testserial';
|
insert asset;
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dpt.Id;
|
repair01.Department_Class__c = dc.Id;
|
repair01.Hospital__c = hp.Id;
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
repair01.FSE_Work_Location__c = '上海';
|
repair01.AWS_Data_Id__c='123';
|
insert repair01;
|
|
List<Repair__c> reList=new List<Repair__c>();
|
reList.add(repair01);
|
Database.executeBatch(new SelectRepairPDFDeleteBatch(reList),1);
|
}
|
}
|