@isTest
|
private class NotetoPdfHandlerTest {
|
private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
|
static testMethod void NotetoPdf() {
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
|
dep.Name = 'test dep';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
// 製品を作る
|
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 = dep.Id;
|
asset.Department_Class__c = strategicDep[0].Id;
|
asset.Hospital__c = hospital.Id;
|
asset.SerialNumber = 'testserial';
|
insert asset;
|
|
// 维修合同を作成する
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep[0].Id;
|
contract.Department__c = dep.Id;
|
insert contract;
|
|
// 修理を作成する
|
Repair__c repair = new Repair__c();
|
repair.Account__c = dep.Id;
|
repair.Department_Class__c = strategicDep[0].Id;
|
repair.Hospital__c = hospital.Id;
|
repair.Delivered_Product__c = asset.Id;
|
repair.AWS_Data_Id__c = 'AWS_Data_Id__c';
|
insert repair;
|
ContentVersion version = new ContentVersion();
|
version.Title = '123';
|
version.VersionData = EncodingUtil.base64Decode('qwe');
|
version.ContentLocation = 's';
|
version.PathOnClient = '123.txt';
|
insert version;
|
version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
|
ContentDocumentLink link = new ContentDocumentLink();
|
link.ContentDocumentId = version.ContentDocumentId;
|
link.LinkedEntityId = repair.Id;
|
link.ShareType = 'V';
|
link.Visibility = 'AllUsers';
|
insert link;
|
// Note n = new Note();
|
// n.ParentId = repair.Id;
|
// n.Title = 'testnote';
|
// insert n;
|
// PageReference page = new PageReference('/apex/ReAndQISNotePDF?id='+n.id);
|
// System.Test.setCurrentPage(page);
|
// ReAndQISNotePDFController conTest = new ReAndQISNotePDFController();
|
}
|
}
|