@isTest
|
private class OFSInsReportLayoutForVmControllerTest {
|
@TestSetup
|
static void makeData(){
|
TestDataUtility.CreatePIPolicyConfigurations(new String[]{'Contact','Agency_Contact__c','contactV2'});
|
}
|
static Asset createAsset(String input, String accountid, String dcId, String hpId, String serialNo, String prId) {
|
Asset asset = new Asset();
|
asset.Name = input;
|
asset.AccountId = accountid;
|
asset.Department_Class__c = dcId;
|
asset.Hospital__c = hpId;
|
asset.SerialNumber = serialNo;
|
asset.Product2Id = prId;
|
asset.Status= '使用中';
|
insert asset;
|
return asset;
|
}
|
static testMethod void testMethod0() {
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
OFSInsReportLayout__c layout =new OFSInsReportLayout__c();
|
layout.Name = 'test';
|
layout.recordType_devName__c = 'EndoscopeSystem';
|
layout.section1__c = '{"id":"001","title":"基本信息","column":"2","showHeader":"true"}';
|
layout.field1__c = '{"sectionId":"001", "api":{"columns":["Name","Hospital__c", "Department__c"], "lables":["点检检测单号", "医院", "科室"]}, "lable":""}';
|
|
layout.section2__c = '{"id":"002","title":"信息","column":"2","showHeader":"false"}';
|
layout.field2__c = '{"sectionId":"002","api":"Hospital__c"}';
|
layout.field3__c = '{"sectionId":"002","api":"Manual_Department__c","isInput":"true"}';
|
layout.field4__c = '{"sectionId":"002","api":"Status__c","right":"true","isInput":"true"}';
|
layout.field5__c = '{"sectionId":"002","api":"NextInspection_Day__c"}';
|
layout.field6__c = '{"sectionId":"002","api":"Inspection_Date__c"}';
|
|
insert layout;
|
|
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();
|
StaticParameter.EscapeAccountTrigger = true;
|
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='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
|
insert productA;
|
|
|
// 納入機器を作成する
|
Asset asset01 = createAsset('asset:01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id);
|
Asset asset02 = createAsset('asset:21', dep.Id, strategicDep[0].Id, hospital.Id, '21343', productA.Id);
|
|
// 维修合同を作成する
|
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;
|
contract.Contract_End_Date__c = Date.today();
|
contract.Status__c= '契約';
|
contract.Not_Upper_limit_reason__c = 'test';
|
contract.Maintenance_Contract_No__c = 'contact1';
|
contract.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
|
insert contract;
|
|
// 维修合同保有设备
|
Maintenance_Contract_Asset__c mca = new Maintenance_Contract_Asset__c();
|
mca.Asset__c = asset01.Id;
|
mca.Maintenance_Contract__c = contract.Id;
|
mca.Check_object__c = true;
|
insert mca;
|
|
Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
|
mca1.Asset__c = asset02.Id;
|
mca1.Maintenance_Contract__c = contract.Id;
|
mca1.Check_object__c = true;
|
insert mca1;
|
|
//点检计划
|
Inspectup_Plan__c inplan = new Inspectup_Plan__c();
|
inplan.Planned_Start_Date__c = Date.today().addMonths(-1).addDays(1);
|
inplan.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan.InspctupDate__c = Date.today().addDays(1);
|
inplan.Actual_Execution_Quantity__c = 0;
|
inplan.Maintenance_Contract__c = contract.Id;
|
inplan.Task_sending_time__c = Date.today();
|
inplan.Planned_check_equipment_Num__c = 20;
|
// inplan.Check_Object_Quantity__c=10;
|
inplan.Actual_Execution_Quantity__c=11;
|
insert inplan;
|
|
|
Test.startTest();
|
PageReference peg = new PageReference('/apex/OFSInsReportLayoutForVm?vmId='+contract.Id+'&rt=EndoscopeSystem&djId='+inplan.Id+'&hpid='+hospital.id);
|
System.Test.setCurrentPage(peg);
|
OFSInsReportLayoutForVmController controller = new OFSInsReportLayoutForVmController();
|
controller.init();
|
controller.text1 = 'S:SerialNumber';
|
controller.cond1 = 'contains';
|
controller.val1 ='2 1';
|
controller.searchBtn();
|
controller.checkedInfoList[0].ah.ItemStatus__c = 'NG';
|
controller.save();
|
|
controller.checkedInfoList[0].ah.ItemStatus__c = '医院放弃';
|
controller.save();
|
|
controller.checkedInfoList[0].ah.ItemStatus__c = '医院放弃';
|
controller.checkedInfoList[0].ah.Abandonment_Reasons__c = '121212';
|
controller.save();
|
controller.submit();
|
controller.makeIrNo();
|
controller.exchangeAsset();
|
controller.showPDF();
|
Test.stopTest();
|
|
}
|
static testMethod void testMethod1() {
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
OFSInsReportLayout__c layout =new OFSInsReportLayout__c();
|
layout.Name = 'test';
|
layout.recordType_devName__c = 'EndoscopeSystem';
|
layout.section1__c = '{"id":"001","title":"基本信息","column":"2","showHeader":"true"}';
|
layout.field1__c = '{"sectionId":"001", "api":{"columns":["Name","Hospital__c", "Department__c"], "lables":["点检检测单号", "医院", "科室"]}, "lable":""}';
|
|
layout.section2__c = '{"id":"002","title":"信息","column":"2","showHeader":"false"}';
|
layout.field2__c = '{"sectionId":"002","api":"Hospital__c"}';
|
layout.field3__c = '{"sectionId":"002","api":"Manual_Department__c","isInput":"true"}';
|
layout.field4__c = '{"sectionId":"002","api":"Status__c","right":"true","isInput":"true"}';
|
layout.field5__c = '{"sectionId":"002","api":"NextInspection_Day__c"}';
|
layout.field6__c = '{"sectionId":"002","api":"Inspection_Date__c"}';
|
|
insert layout;
|
|
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();
|
StaticParameter.EscapeAccountTrigger = true;
|
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='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
|
insert productA;
|
|
|
// 納入機器を作成する
|
Asset asset01 = createAsset('asset:01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id);
|
Asset asset02 = createAsset('asset:21', dep.Id, strategicDep[0].Id, hospital.Id, '21343', productA.Id);
|
|
// 维修合同を作成する
|
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;
|
contract.Contract_End_Date__c = Date.today();
|
contract.Status__c= '契約';
|
contract.Not_Upper_limit_reason__c = 'test';
|
contract.Maintenance_Contract_No__c = 'contact1';
|
contract.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
|
insert contract;
|
|
// 维修合同保有设备
|
Maintenance_Contract_Asset__c mca = new Maintenance_Contract_Asset__c();
|
mca.Asset__c = asset01.Id;
|
mca.Maintenance_Contract__c = contract.Id;
|
mca.Check_object__c = true;
|
insert mca;
|
|
Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
|
mca1.Asset__c = asset02.Id;
|
mca1.Maintenance_Contract__c = contract.Id;
|
mca1.Check_object__c = true;
|
insert mca1;
|
|
//点检计划
|
Inspectup_Plan__c inplan = new Inspectup_Plan__c();
|
inplan.Planned_Start_Date__c = Date.today().addMonths(-1).addDays(1);
|
inplan.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan.InspctupDate__c = Date.today().addDays(1);
|
inplan.Actual_Execution_Quantity__c = 0;
|
inplan.Maintenance_Contract__c = contract.Id;
|
inplan.Task_sending_time__c = Date.today();
|
inplan.Planned_check_equipment_Num__c = 20;
|
// inplan.Check_Object_Quantity__c=10;
|
inplan.Actual_Execution_Quantity__c=11;
|
insert inplan;
|
|
|
Test.startTest();
|
PageReference peg = new PageReference('/apex/OFSInsReportLayoutForVm?vmId='+contract.Id+'&rt=EndoscopeSystem&djId='+inplan.Id);
|
System.Test.setCurrentPage(peg);
|
OFSInsReportLayoutForVmController controller = new OFSInsReportLayoutForVmController();
|
controller.init();
|
controller.text1 = 'S:SerialNumber';
|
controller.cond1 = 'contains';
|
controller.val1 ='2 1';
|
controller.searchBtn();
|
controller.checkedInfoList[0].ah.ItemStatus__c = 'NG';
|
controller.save();
|
|
controller.checkedInfoList[0].ah.ItemStatus__c = '医院放弃';
|
controller.save();
|
|
controller.checkedInfoList[0].ah.ItemStatus__c = '医院放弃';
|
controller.checkedInfoList[0].ah.Abandonment_Reasons__c = '121212';
|
controller.save();
|
controller.submit();
|
controller.makeIrNo();
|
controller.exchangeAsset();
|
controller.showPDF();
|
Test.stopTest();
|
|
}
|
static testMethod void testMethod2(){
|
//1.新建维修合同
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
OFSInsReportLayout__c layout =new OFSInsReportLayout__c();
|
layout.Name = 'test';
|
layout.recordType_devName__c = 'EndoscopeSystem';
|
layout.section1__c = '{"id":"001","title":"基本信息","column":"2","showHeader":"true"}';
|
layout.field1__c = '{"sectionId":"001", "api":{"columns":["Name","Hospital__c", "Department__c"], "lables":["点检检测单号", "医院", "科室"]}, "lable":""}';
|
|
layout.section2__c = '{"id":"002","title":"信息","column":"2","showHeader":"false"}';
|
layout.field2__c = '{"sectionId":"002","api":"Hospital__c"}';
|
layout.field3__c = '{"sectionId":"002","api":"Manual_Department__c","isInput":"true"}';
|
layout.field4__c = '{"sectionId":"002","api":"Status__c","right":"true","isInput":"true"}';
|
layout.field5__c = '{"sectionId":"002","api":"NextInspection_Day__c"}';
|
layout.field6__c = '{"sectionId":"002","api":"Inspection_Date__c"}';
|
|
insert layout;
|
|
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();
|
StaticParameter.EscapeAccountTrigger = true;
|
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='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
|
insert productA;
|
|
|
// 納入機器を作成する
|
Asset asset01 = createAsset('asset:01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id);
|
Asset asset02 = createAsset('asset:21', dep.Id, strategicDep[0].Id, hospital.Id, '21343', productA.Id);
|
|
// 维修合同を作成する
|
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;
|
contract.Contract_End_Date__c = Date.today();
|
contract.Status__c= '契約';
|
contract.Not_Upper_limit_reason__c = 'test';
|
contract.Maintenance_Contract_No__c = 'contact1';
|
contract.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
|
insert contract;
|
// 维修合同保有设备
|
Maintenance_Contract_Asset__c mca = new Maintenance_Contract_Asset__c();
|
mca.Asset__c = asset01.Id;
|
mca.Maintenance_Contract__c = contract.Id;
|
mca.Check_object__c = true;
|
insert mca;
|
|
Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
|
mca1.Asset__c = asset02.Id;
|
mca1.Maintenance_Contract__c = contract.Id;
|
mca1.Check_object__c = true;
|
insert mca1;
|
|
//点检计划
|
Inspectup_Plan__c inplan = new Inspectup_Plan__c();
|
inplan.Planned_Start_Date__c = Date.today().addMonths(-1).addDays(1);
|
inplan.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan.InspctupDate__c = Date.today().addDays(1);
|
inplan.Actual_Execution_Quantity__c = 0;
|
inplan.Maintenance_Contract__c = contract.Id;
|
inplan.Task_sending_time__c = Date.today();
|
insert inplan;
|
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Test_staff__c = true, Job_Category__c='销售服务' ,LastName = 'hp', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert hpOwner;
|
|
Inspection_Report__c ir = new Inspection_Report__c(Name = '*',
|
Hospital__c = hospital.Id,
|
Reporter__c = hpOwner.id,
|
Contract__c = contract.Id,
|
Inspectup_Plan__c = inplan.id,
|
Status__c = '草案中'
|
);
|
insert ir;
|
|
//3.新建点检明细
|
Inspection_Item__c item = new Inspection_Item__c ();
|
item.AssetId__c = asset01.Id;
|
item.Inspection_ReportId__c = ir.Id;
|
insert item;
|
|
Test.startTest();
|
//4.调用
|
PageReference peg = new PageReference('/apex/OFSInsReportLayoutForVm?vmId='+contract.Id+'&rt=EndoscopeSystem&djId='+inplan.Id+'&id='+ir.Id);
|
System.Test.setCurrentPage(peg);
|
OFSInsReportLayoutForVmController controller = new OFSInsReportLayoutForVmController();
|
controller.init();
|
|
controller.text1 = 'S:SerialNumber';
|
controller.cond1 = 'notequals';
|
controller.val1 ='niash,12343ss';
|
controller.searchBtn();
|
PageReference peg1 = new PageReference('/apex/OFSInsReportLayoutForVm?id=12121');
|
System.Test.setCurrentPage(peg1);
|
controller.init();
|
Test.stopTest();
|
|
}
|
|
|
|
|
//編集テスト
|
//编辑测试
|
@isTest
|
static void EditUnitTest() {
|
System.runAs(new User(Id = UserInfo.getUserId())){
|
Test.startTest();
|
TestRepo repo = new TestRepo();
|
repo.createInspectionReport(Date.today());
|
repo.initAssets();
|
repo.sqlIr();
|
Apexpages.currentPage().getParameters().put('id', repo.ir.Id);
|
Apexpages.currentPage().getParameters().put('name', repo.ir.name);
|
Apexpages.currentPage().getParameters().put('asset_ids', repo.getAssetIds(5));
|
OFSInsReportLayoutForVmController controller = new OFSInsReportLayoutForVmController();
|
|
//init
|
controller.init();
|
|
//Assetをチェックして、明細を作る
|
//检查Asset,制作明细
|
//controller.unCheckedInfoList[0].rec_checkBox_c = true;
|
controller.exchangeAsset();
|
|
controller.saveBtn();
|
|
list<Inspection_Report__c> irs = [select id, Name from Inspection_Report__c where Name =:controller.ir.Name];
|
|
List<Inspection_Item__c> ahList = [Select Id, Name, AssetId__c, Inspection_ReportId__c from Inspection_Item__c Where Inspection_ReportId__c = :controller.ir.Id order by Name];
|
|
Integer cnt1 = controller.productCount;
|
Integer cnt2 = controller.productCount2;
|
|
//init
|
controller.text1 = 'S:SerialNumber';
|
controller.cond1 = 'notequals';
|
controller.val1 = '00000';
|
controller.searchBtn();
|
|
controller.text1 = 'S:SerialNumber';
|
controller.cond1 = 'contains';
|
controller.val1 = '00000';
|
controller.searchBtn();
|
|
controller.text1 = 'S:SerialNumber';
|
controller.cond1 = 'equals';
|
controller.val1 = '00000';
|
controller.searchBtn();
|
controller.sortKey = '1';
|
controller.sortTable();
|
controller.showPDF();
|
controller.submit();
|
|
controller.DownPage();
|
controller.UpPage();
|
PageReference peg1 = new PageReference('/apex/OFSInsReportLayoutForVm?rt=EndoscopeSystem&hpId='+repo.hp.Id + '&id=121');
|
System.Test.setCurrentPage(peg1);
|
OFSInsReportLayoutForVmController controller1 = new OFSInsReportLayoutForVmController();
|
controller1.init();
|
|
Test.stopTest();
|
}
|
}
|
|
public class TestRepo {
|
public final Integer ASSETMAX = 8;
|
public OFSInsReportLayout__c layout { get; private set; }
|
public Account hp { get; private set; }
|
public Account depart { get; private set; }
|
public Inspection_Report__c ir { get; private set; }
|
public List<Asset> assets { get; private set; }
|
public Event evnt { get; private set; }
|
//public List<list<AssetInfo>> ResultOfRefresh{get;set;}
|
TestRepo() {
|
assets = new List<Asset>();
|
createLayout();
|
createHospital();
|
createEvent();
|
}
|
public void createEvent() {
|
evnt = new Event();
|
evnt.StartDateTime = Datetime.now().addDays(1);
|
evnt.EndDateTime = Datetime.now().addDays(1).addHours(1);
|
insert evnt;
|
}
|
public void createHospital() {
|
hp = new Account();
|
hp.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hp.Name = 'test hospital';
|
insert hp;
|
Account section = [Select Id from Account where RecordType.DeveloperName = 'Department_Class_GI' and ParentId =: hp.Id];
|
depart = new Account();
|
|
StaticParameter.EscapeAccountTrigger = true;
|
depart.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'OFSInsReportLayoutForVmControllerTestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = hp.Id;
|
insert depart;
|
}
|
public void createInspectionReport(Date inspectionDate) {
|
|
Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
User u1 = new User();
|
u1.LastName = '_サンブリッジ';
|
u1.Alias = 'あ2';
|
u1.Email = 'olympusTest02@sunbridge.com';
|
u1.Username = 'olympusTest02@sunbridge.com';
|
u1.CommunityNickname = 'あ2';
|
u1.IsActive = true;
|
u1.EmailEncodingKey = 'ISO-2022-JP';
|
u1.TimeZoneSidKey = 'Asia/Tokyo';
|
u1.LocaleSidKey = 'ja_JP';
|
u1.LanguageLocaleKey = 'ja';
|
u1.ProfileId = p.id;
|
u1.Job_Category__c = '销售服务';
|
|
insert u1;
|
|
ir = new Inspection_Report__c(Name = '*', Inspection_Date__c = inspectionDate, Hospital__c = hp.Id);
|
ir.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Inspection_Report__c' and DeveloperName = 'EndoscopeSystem'].id;
|
ir.Hospital__c = hp.Id;
|
|
ir.Reporter__c = u1.Id;
|
|
ir.Manual_Department__c = 'test';
|
ir.Inspection_StartTime__c = Datetime.now();
|
ir.Inspection_EndTime__c = Datetime.now().addHours(1);
|
ir.Phone__c = '11112222';
|
ir.Responsible_Person__c = 'test';
|
ir.Next_StartTime__c = Datetime.now().addDays(1);
|
ir.Next_EndTime__c = Datetime.now().addDays(1).addHours(1);
|
ir.NextInspection_Day__c = Date.today().addDays(1);
|
ir.Next_StartHour_Page__c = '09';
|
ir.Next_StartMinute_Page__c = '00';
|
ir.Next_EndHour_Page__c = '10';
|
ir.Next_EndMinute_Page__c = '00';
|
ir.Event_ID__c = evnt.Id;
|
ir.Status__c= '草案中';
|
insert ir;
|
}
|
|
private void createLayout() {
|
layout = new OFSInsReportLayout__c();
|
layout.Name = 'test';
|
layout.recordType_devName__c = 'EndoscopeSystem';
|
layout.section1__c = '{"id":"001","title":"基本信息","column":"2","showHeader":"true"}';
|
layout.field1__c = '{"sectionId":"001", "api":{"columns":["Name","Hospital__c", "Department__c"], "lables":["点检检测单号", "医院", "科室"]}, "lable":""}';
|
|
layout.section2__c = '{"id":"002","title":"信息","column":"2","showHeader":"false"}';
|
layout.field2__c = '{"sectionId":"002","api":"Hospital__c"}';
|
layout.field3__c = '{"sectionId":"002","api":"Manual_Department__c","isInput":"true"}';
|
layout.field4__c = '{"sectionId":"002","api":"Status__c","right":"true","isInput":"true"}';
|
layout.field5__c = '{"sectionId":"002","api":"NextInspection_Day__c"}';
|
layout.field6__c = '{"sectionId":"002","api":"Inspection_Date__c"}';
|
|
insert layout;
|
}
|
private Asset createAsset(String name, String serialNo) {
|
Asset asset = new Asset();
|
asset.Name = name;
|
asset.AccountId = depart.Id;
|
asset.Hospital__c = hp.Id;
|
asset.SerialNumber = serialNo;
|
asset.InstallDate = Date.today();
|
return asset;
|
}
|
public void initAssets() {
|
for (Integer i= 0; i < ASSETMAX; i++) {
|
assets.add(createAsset('testAsset'+i, '0000'+i));
|
}
|
insert assets;
|
}
|
public String getAssetIds(Integer num) {
|
String irStr = '';
|
for (Integer i = 0; i < num; i++) {
|
irStr += assets[i].Id + '_';
|
}
|
irStr = irStr.removeEnd('_');
|
return irStr;
|
}
|
|
public void sqlIr() {
|
this.ir = [select Id, Name, Status__c, Inspection_Date__c, Reporter__c from Inspection_Report__c where Id =: ir.Id];
|
}
|
}
|
|
@isTest
|
static void VMTest(){
|
ControllerUtil.EscapeNFM001Trigger = true;
|
ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
|
StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
|
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
User MacOwner = new User(Test_staff__c = true, LastName = 'hp1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com',Job_Category__c = '销售服务', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert MacOwner;
|
Account hospital = new Account();
|
hospital.recordtypeId =
|
Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
|
hospital.Name = 'test hospita/l';
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
|
// 診療科を作る
|
Account dep = new Account();
|
StaticParameter.EscapeAccountTrigger = true;
|
dep.recordtypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId();
|
dep.Name = 'test de/p';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
// 製品を作る
|
Product2 productA = new Product2( Name='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false,IsActive=true,Family='GI',
|
Fixture_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',
|
Fixture_Model_No_T__c = 'n01',
|
ProductCode_Ext__c='pc01');
|
insert productA;
|
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;
|
contract.Service_Contract_Staff__c = MacOwner.Id;
|
contract.Payment_Plan_Sum_First__c = 1;
|
contract.Status__c= '引合中';
|
contract.Maintenance_Contract_No__c = '11123';
|
contract.recordtypeId =
|
Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId();
|
contract.Not_Upper_limit_reason__c = ' 1';
|
contract.Contract_Start_Date__c = Date.today().addDays( -10);
|
contract.Contract_End_Date__c = Date.today().addDays( 5);
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
insert new list<Maintenance_Contract__c> {contract};
|
|
Test.startTest();
|
// repo.ir.Contract__c = contract.Id;
|
// update repo.ir;
|
PageReference peg = new PageReference('/apex/OFSInsReportLayoutForVm?vmId=121&rt=EndoscopeSystem');
|
System.Test.setCurrentPage(peg);
|
OFSInsReportLayoutForVmController controller = new OFSInsReportLayoutForVmController();
|
controller.init();
|
PageReference peg1 = new PageReference('/apex/OFSInsReportLayoutForVm?vmId='+contract.Id+'&rt=EndoscopeSystem&hpId='+hospital.Id);
|
System.Test.setCurrentPage(peg1);
|
OFSInsReportLayoutForVmController controller1 = new OFSInsReportLayoutForVmController();
|
controller1.init();
|
PageReference peg2 = new PageReference('/apex/OFSInsReportLayoutForVm?rt=EndoscopeSystem&hpId='+hospital.Id);
|
System.Test.setCurrentPage(peg2);
|
OFSInsReportLayoutForVmController controller2 = new OFSInsReportLayoutForVmController();
|
controller2.init();
|
Test.stopTest();
|
}
|
}
|