@isTest
|
private class RepairTriggerTester {
|
private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
|
//创建医院
|
static Account createHospital( String hospitalName) {
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE DeveloperName = 'HP'].id;
|
hospital.Name = hospitalName;
|
insert hospital;
|
StaticParameter.EscapeAccountTrigger = true;
|
return hospital;
|
}
|
|
static List<Account> selectStrategicDep( Account hospital) {
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
return strategicDep;
|
}
|
|
static Account createDep( Account hospital, Account strategicDep) {
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE DeveloperName = 'Department_GI'].id;
|
dep.Name = 'test dep';
|
dep.ParentId = strategicDep.Id;
|
dep.Department_Class__c = strategicDep.Id;
|
dep.Hospital__c = hospital.Id;
|
// dep.State_Text__c = '上海市';
|
insert dep;
|
return dep;
|
}
|
|
static Asset createAsset( Account hospital, Account strategicDep, Account 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.CurrencyIsoCode= 'CNY';
|
asset.Reson_Can_not_Warranty__c='点检';
|
asset.AccountId = dep.Id;
|
asset.Department_Class__c = strategicDep.Id;
|
asset.Hospital__c = hospital.Id;
|
asset.SerialNumber = 'testserial';
|
asset.Quantity = 3;
|
// asset.Extend_Gurantee_DateTo_Text__c =Date.today().addDays(30);
|
// asset.IS_Extend_Gurantee_Txt__c =true;
|
// asset.Order_No__c = 'BJ_2020';
|
|
insert asset;
|
return asset;
|
}
|
|
static Maintenance_Contract__c createMaintenanceContract( Account hospital, Account strategicDep, Account dep) {
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep.Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
|
insert contract;
|
return contract;
|
}
|
|
static Maintenance_Contract__c createMaintenanceContract1( Account hospital, Account strategicDep, Account dep) {
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep.Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '上海RC';
|
|
insert contract;
|
return contract;
|
}
|
|
static Maintenance_Contract__c createMaintenanceContract2( Account hospital, Account strategicDep, Account dep) {
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep.Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
contract.RecordTypeId='01210000000gTYv';
|
|
insert contract;
|
return contract;
|
}
|
static Maintenance_Contract__c createMaintenanceContract3( Account hospital, Account strategicDep, Account dep) {
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep.Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '沈阳RC';
|
|
insert contract;
|
return contract;
|
}
|
//维修合同/保有设备
|
static Maintenance_Contract_Asset__c createMiddleTable( Asset asset, Maintenance_Contract__c contract) {
|
// 中間テーブルを設ける
|
Maintenance_Contract_Asset__c middleTable = new Maintenance_Contract_Asset__c();
|
middleTable.Asset__c = asset.Id;
|
middleTable.Maintenance_Contract__c = contract.id;
|
middleTable.CurrencyIsoCode= 'CNY';
|
middleTable.startDateGurantee_Text__c =Date.today().addDays( 5);
|
middleTable.endDateGurantee_Text__c =Date.today().addDays( 30);
|
insert middleTable;
|
return middleTable;
|
}
|
//限次合同产品信息维护相关测试 FXK 2021/3/8 Start
|
static testMethod void test03(){
|
//客户
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
// 保有设备
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// 创建维修合同
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.URF_Contract__c=true;
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep[0].Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
contract.RecordTypeId='01210000000gTYq';
|
contract.URF_Contract__c = true;
|
contract.agree_Upper_limit__c = true;
|
insert contract;
|
//创建维修合同报价
|
Maintenance_Contract_Estimate__c Estimate = new Maintenance_Contract_Estimate__c();
|
Estimate.Maintenance_Contract__c = contract.Id;
|
Estimate.recordtypeId = '01210000000gTZA';
|
Estimate.Name = '报价1';
|
insert Estimate;
|
//创建维修合同报价/保有设备
|
Maintenance_Contract_Asset_Estimate__c Asset_Estimate = new Maintenance_Contract_Asset_Estimate__c();
|
Asset_Estimate.Maintenance_Contract_Estimate__c = Estimate.Id;
|
Asset_Estimate.CurrencyIsoCode = 'CNY';
|
Asset_Estimate.Series_MaxRepairCount__c = 10;
|
Asset_Estimate.Series_RepairCount__c = 5;
|
insert Asset_Estimate;
|
//创建维修合同/保有设备
|
Maintenance_Contract_Asset__c middleTable = new Maintenance_Contract_Asset__c();
|
middleTable.Asset__c = asset.Id;
|
middleTable.Maintenance_Contract__c = contract.Id;
|
middleTable.CurrencyIsoCode= 'CNY';
|
middleTable.startDateGurantee_Text__c =Date.today().addDays( 5);
|
middleTable.endDateGurantee_Text__c =Date.today().addDays( 30);
|
middleTable.Maintenance_Contract_Asset_Estimate__c = Asset_Estimate.Id;
|
insert middleTable;
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today(); // 维修合同判断日在合同开始日与合同结束日之间
|
repair01.Failure_Occurrence_Date__c =Date.today();
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.Status__c = '草案中';
|
repair01.SalesOfficeCode_selection__c = '西安RC';
|
insert repair01;
|
|
Repair__c checkRepair = null;
|
checkRepair = [SELECT Id, Name , Maintenance_Contract__c,MaintenanceContractType__c FROM Repair__c WHERE ID = :repair01.id];
|
System.assertEquals( contract.Id, checkRepair.Maintenance_Contract__c);
|
|
// 修理を作成する01
|
Repair__c repair02 = new Repair__c();
|
repair02.Account__c = dep.Id;
|
repair02.Department_Class__c = strategicDep[0].Id;
|
repair02.Hospital__c = hospital.Id;
|
repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today(); // 维修合同判断日在合同开始日与合同结束日之间
|
repair02.Failure_Occurrence_Date__c =Date.today();
|
repair02.Delivered_Product__c = asset.Id;
|
insert repair02;
|
delete repair02;
|
|
checkRepair.NewProductGuarante_Txt__c = '2: 服务多年保修';
|
update checkRepair;
|
|
checkRepair.NewProductGuarante_Txt__c = '8: 市场多年保修';
|
checkRepair.On_site_repair__c = 'RC修理';
|
checkRepair.Maintenance_Contract__c = contract.Id;
|
checkRepair.SalesOfficeCode_selection__c = '杭州RC';
|
update checkRepair;
|
|
contract.SalesOfficeCode_selection__c = '上海RC';
|
update contract;
|
checkRepair.SalesOfficeCode_selection__c = '杭州RC';
|
update checkRepair;
|
|
checkRepair.SalesOfficeCode_selection__c = '杭州RC';
|
checkRepair.NewProductGuarante_Txt__c = '2: 服务多年保修';
|
update checkRepair;
|
|
asset.Order_No__c = '上海分公司';
|
update asset;
|
checkRepair.SalesOfficeCode_selection__c = '杭州';
|
update checkRepair;
|
|
asset.Order_No__c = '广州分公司';
|
update asset;
|
checkRepair.On_site_repair__c = '办事处修理';
|
checkRepair.SalesOfficeCode_selection__c = '杭州';
|
checkRepair.NewProductGuarante_Txt__c = '8: 市场多年保修';
|
update checkRepair;
|
|
contract.SalesOfficeCode_selection__c = '广州RC';
|
update contract;
|
}
|
//限次合同产品信息维护相关测试 FXK 2021/3/8 End
|
|
/**
|
* 有効なサービス契約がある場合をテストします。
|
* (修理の故障日が、サービス契約の契約開始日 〜 契約終了日に含まれるパターン)
|
* 中間テーブルを削除するパターンもテストします。
|
*/
|
// static testMethod void test01() {
|
|
// 病院、戦略科室、診療科の情報を作成します
|
// 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract2( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約開始日の前日
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name,Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// System.assertEquals( contract.Id, checkRepair.Maintenance_Contract__c, '01.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '01.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '01.003');
|
|
// // 中間テーブルを削除します
|
// delete middleTable;
|
// // 結果発表
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '01.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '01.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '01.003');
|
// }
|
|
/**
|
* 有効なサービス契約がない場合をテストします。
|
* (修理の故障日が、サービス契約の契約開始日 〜 契約終了日に含まれないパターン)
|
*/
|
static testMethod void test02() {
|
|
// 病院、戦略科室、診療科の情報を作成します
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
|
// 納入機器を作る
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// 维修合同を作成する
|
Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// 中間テーブルを設ける
|
Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -1000); // 维修合同判断日がサービス契約のだいぶ前
|
repair01.Failure_Occurrence_Date__c =Date.today();
|
insert repair01;
|
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(4); // 维修合同判断日がサービス契約開始日の前日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(6); // 维修合同判断日がサービス契約終了日の翌日
|
// insert repair03;
|
|
// 結果発表
|
Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '02.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '02.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
//FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '02.003');
|
}
|
|
/**
|
* 有効なサービス契約と無効な契約が混在する場合をテストします。
|
* あとから修理の维修合同判断日を変更して、サービスと関連付け直すパターンもテストします。
|
*/
|
// static testMethod void test03() {
|
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -1000); // 维修合同判断日がサービス契約のだいぶ前
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(6); // 维修合同判断日がサービス契約終了日の翌日
|
// insert repair03;
|
|
// // 結果発表
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME
|
// System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '03.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME
|
// System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '03.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME
|
// System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '03.003');
|
|
// }
|
|
|
// static testMethod void test03_01() {
|
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -1000); // 维修合同判断日がサービス契約のだいぶ前
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(6); // 维修合同判断日がサービス契約終了日の翌日
|
// insert repair03;
|
|
// // 修理の维修合同判断日を買えてみます。
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-11); // 维修合同判断日がサービス契約開始日前日
|
// update repair02;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// update repair03;
|
|
|
// // 結果発表
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME
|
// System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '03.011');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME
|
// System.assertEquals( null, checkRepair.Maintenance_Contract__c, '03.012');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME
|
// System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '03.013');
|
|
// }
|
|
|
/**
|
* 先に修理を作り、あとから中間テーブルをつくって、修理とサービスを関連付けるパターンをテストします。
|
*/
|
// static testMethod void test04() {
|
|
// Account hospital = createHospital( 'test hospital');
|
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
|
// // 結果発表
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '04.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '04.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '04.003');
|
|
// // あとから中間テーブルを作って、サービスと修理を関連付ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 結果発表
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '04.011');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '04.012');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '04.013');
|
|
// // 修理を更新してみる
|
// update repair03;
|
|
// // 結果発表
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '04.021');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '04.022');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '04.023');
|
// }
|
|
/**
|
* 有効なサービス契約と無効な契約が混在する場合をテストします。
|
* あとから契約の契約期間を変更す場合もテストします。
|
*/
|
// static testMethod void test05() {
|
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract3( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日の翌日
|
// insert repair03;
|
|
// // 結果発表
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '05.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.003');
|
|
// // 契約の契約開始日を変えてみる
|
// contract.Contract_Start_Date__c = Date.today().addDays( -11); // 11日前にしてみる
|
// update contract;
|
|
// // 結果発表
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.011');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.012');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.013');
|
|
|
|
// }
|
// static testMethod void test05_01() {
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract2( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日の翌日
|
// insert repair03;
|
|
// // 契約の契約開始日を変えてみる
|
// contract.Contract_End_Date__c = Date.today().addDays( 4); // 4日後にしてみる
|
// update contract;
|
|
|
// Repair__c checkRepair = null;
|
// // 結果発表
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.021');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.022');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '05.023');
|
|
|
// }
|
|
// static testMethod void test05_02() {
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日の翌日
|
// repair03.SalesOfficeCode_selection__c ='北京';
|
// insert repair03;
|
|
|
// // 契約の契約開始日を変えてみる
|
// contract.Contract_Start_Date__c = Date.today().addDays( -20); // 20日前にしてみる
|
// contract.Contract_End_Date__c = Date.today().addDays( 41); // 41日後にしてみる
|
// update contract;
|
|
// // 結果発表
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.031');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.032');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '05.033');
|
|
// }
|
|
// /**
|
// * 異常系のテストをします。
|
// * 维修合同判断日がない修理を作ってみたり、契約開始日を nullにしてみたりします。
|
// */
|
// static testMethod void test06() {
|
// System.debug( '-----: test06 start');
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract1( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// // repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// // 维修合同判断日は、初期値が today()なので、修理 insert時に维修合同判断日を nullにしておいても、サービスと関連づく
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.003');
|
|
// // 维修合同判断日を nullにしてみる
|
// repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = null;
|
// update repair03;
|
// // 結果発表
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.011');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.012');
|
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.013');
|
|
|
// System.debug( '-----: test06 end');
|
// }
|
|
/**
|
* 異常系のテストをします。
|
* 维修合同判断日がない修理を作ってみたり、契約開始日を nullにしてみたりします。
|
*/
|
// static testMethod void test06_01() {
|
// System.debug( '-----: test06 start');
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// // repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// repair02.SalesOfficeCode_selection__c ='杭州';
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.SalesOfficeCode_selection__c ='杭州';
|
// // repair03.Contract_Principal_Office__c = contract.SalesOfficeCode_selection__c;
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// // 维修合同判断日は、初期値が today()なので、修理 insert時に维修合同判断日を nullにしておいても、サービスと関連づく
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.001');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.002');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.003');
|
|
// // 契約の日付を nullにしてみる
|
// contract.Contract_Start_Date__c = null;
|
// update contract;
|
|
// // 結果発表
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.021');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.022');
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.023');
|
|
// System.debug( '-----: test06 end');
|
// }
|
// static testMethod void test06_02() {
|
// System.debug( '-----: test06_02 start');
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// // repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.Maintenance_Contract__c = contract.Id;
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// // 维修合同判断日は、初期値が today()なので、修理 insert時に维修合同判断日を nullにしておいても、サービスと関連づく
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.001');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.002');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.003');
|
|
// // // 维修合同判断日を nullにしてみる
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = null;
|
// // update repair03;
|
// // 結果発表
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.011');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.012');
|
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.013');
|
|
|
// System.debug( '-----: test06 end');
|
// }
|
// static testMethod void test06_03() {
|
// System.debug( '-----: test06_03 start');
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract1( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// // repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.Maintenance_Contract__c = contract.Id;
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// // 维修合同判断日は、初期値が today()なので、修理 insert時に维修合同判断日を nullにしておいても、サービスと関連づく
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.001');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.002');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.003');
|
|
// // // 维修合同判断日を nullにしてみる
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = null;
|
// // update repair03;
|
// // 結果発表
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.011');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.012');
|
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.013');
|
|
|
// System.debug( '-----: test06 end');
|
// }
|
// static testMethod void test06_04() {
|
// System.debug( '-----: test06_04 start');
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract2( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// // repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.Maintenance_Contract__c = contract.Id;
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// // 维修合同判断日は、初期値が today()なので、修理 insert時に维修合同判断日を nullにしておいても、サービスと関連づく
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.001');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.002');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.003');
|
|
// // // 维修合同判断日を nullにしてみる
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = null;
|
// // update repair03;
|
// // 結果発表
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.011');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.012');
|
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.013');
|
|
|
// System.debug( '-----: test06 end');
|
// }
|
// static testMethod void test06_05() {
|
// System.debug( '-----: test06_05 start');
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// // 维修合同を作成する
|
// Maintenance_Contract__c contract = createMaintenanceContract3( hospital, strategicDep[0], dep);
|
// // 中間テーブルを設ける
|
// Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// // repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0); // 维修合同判断日がサービス契約の中間辺りの日付
|
// insert repair01;
|
// // 修理を作成する02
|
// Repair__c repair02 = new Repair__c();
|
// repair02.Account__c = dep.Id;
|
// repair02.Department_Class__c = strategicDep[0].Id;
|
// repair02.Hospital__c = hospital.Id;
|
// repair02.Delivered_Product__c = asset.Id;
|
// repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(-10); // 维修合同判断日がサービス契約開始日
|
// insert repair02;
|
// // 修理を作成する03
|
// Repair__c repair03 = new Repair__c();
|
// repair03.Account__c = dep.Id;
|
// repair03.Department_Class__c = strategicDep[0].Id;
|
// repair03.Hospital__c = hospital.Id;
|
// repair03.Delivered_Product__c = asset.Id;
|
// repair03.Maintenance_Contract__c = contract.Id;
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(5); // 维修合同判断日がサービス契約終了日
|
// insert repair03;
|
|
// // 結果発表
|
// // 维修合同判断日は、初期値が today()なので、修理 insert時に维修合同判断日を nullにしておいても、サービスと関連づく
|
// Repair__c checkRepair = null;
|
// checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.001');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.002');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.003');
|
|
// // // 维修合同判断日を nullにしてみる
|
// // repair03.SERVICE_CONTRACT_JUDEGE_DAY__C = null;
|
// // update repair03;
|
// // 結果発表
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair01.id];
|
// //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.011');
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair02.id];
|
// // //FIXME System.assertEquals( contract.id, checkRepair.Maintenance_Contract__c, '06.012');
|
|
// // checkRepair = [SELECT Id, Name, Hospital__c, Delivered_Product__c, SERVICE_CONTRACT_JUDEGE_DAY__C, Maintenance_Contract__c FROM Repair__c WHERE ID = :repair03.id];
|
// //FIXME System.assertEquals( null, checkRepair.Maintenance_Contract__c, '06.013');
|
|
|
// System.debug( '-----: test06 end');
|
// }
|
|
/**
|
* 备品借出申请の「修理最终检测日」を更新するロジック
|
*/
|
//static testMethod void test07() {
|
|
// // 病院、戦略科室、診療科の情報を作成します
|
// Account hospital = createHospital( 'test hospital');
|
// Account[] strategicDep = selectStrategicDep( hospital);
|
// Account dep = createDep( hospital, strategicDep[0]);
|
|
// // 納入機器を作る
|
// Asset asset = createAsset( hospital, strategicDep[0], dep);
|
|
// // 修理を作成する01
|
// Repair__c repair01 = new Repair__c();
|
// repair01.Account__c = dep.Id;
|
// repair01.Department_Class__c = strategicDep[0].Id;
|
// repair01.Hospital__c = hospital.Id;
|
// repair01.Delivered_Product__c = asset.Id;
|
// repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
// insert repair01;
|
// System.Test.startTest();
|
// Rental_Apply__c rentalApply = new Rental_Apply__c();
|
// rentalApply.Status__c = '引当完了';
|
// //rentalApply.Rental_End_Date__c = Date.today() + 30;
|
// rentalApply.Request_return_day__c = Date.today() + 30;
|
// rentalApply.applyUser__c = UserInfo.getUserId();
|
// rentalApply.demo_purpose2__c = '一般用户';
|
// rentalApply.Repair__c = repair01.Id;
|
// insert rentalApply;
|
|
// repair01.Repair_Final_Inspection_Date__c = Date.today();
|
// update repair01;
|
|
// // 結果発表
|
// List<Rental_Apply__c> raList = [SELECT Id, Repair_Final_Inspection_Date__c FROM Rental_Apply__c WHERE ID = :rentalApply.id];
|
// System.assertEquals(Date.today(), raList[0].Repair_Final_Inspection_Date__c);
|
// System.Test.stopTest();
|
//}
|
|
/**
|
* TAT:修理时长(工作日)设定测试
|
*/
|
static testMethod void testSetRepairWorkday() {
|
// 测试需要,插入固定日历时间,强制设定工作日和假日
|
OlympusCalendar__c oc1 = new OlympusCalendar__c(Date__c = Date.today().addDays(1), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc2 = new OlympusCalendar__c(Date__c = Date.today().addDays(2), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc3 = new OlympusCalendar__c(Date__c = Date.today().addDays(3), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc4 = new OlympusCalendar__c(Date__c = Date.today().addDays(4), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc5 = new OlympusCalendar__c(Date__c = Date.today().addDays(5), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc6 = new OlympusCalendar__c(Date__c = Date.today().addDays(6), ChangeToHoliday__c = true, ChangeToWorkday__c = false);
|
OlympusCalendar__c oc7 = new OlympusCalendar__c(Date__c = Date.today().addDays(7), ChangeToHoliday__c = true, ChangeToWorkday__c = false);
|
OlympusCalendar__c oc8 = new OlympusCalendar__c(Date__c = Date.today().addDays(8), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc9 = new OlympusCalendar__c(Date__c = Date.today().addDays(9), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc10 = new OlympusCalendar__c(Date__c = Date.today().addDays(10), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc11 = new OlympusCalendar__c(Date__c = Date.today().addDays(11), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc12 = new OlympusCalendar__c(Date__c = Date.today().addDays(12), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
|
insert new OlympusCalendar__c[] {oc1, oc2, oc3, oc4, oc5, oc6, oc7, oc8, oc9, oc10, oc11, oc12};
|
|
// 病院、戦略科室、診療科の情報を作成します
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
|
// 納入機器を作る
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair01.Repair_Start_Date__c = Date.today().addDays(3);
|
repair01.Repair_Final_Inspection_Date__c = Date.today().addDays(10);
|
insert repair01;
|
|
// 修理を作成する01
|
Repair__c repair02 = new Repair__c();
|
repair02.Account__c = dep.Id;
|
repair02.Department_Class__c = strategicDep[0].Id;
|
repair02.Hospital__c = hospital.Id;
|
repair02.Delivered_Product__c = asset.Id;
|
repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair02.Repair_Start_Date__c = Date.today().addDays(3);
|
repair02.Repair_Final_Inspection_Date__c = Date.today().addDays(10);
|
repair02.RepairOrderStatusCode__c ='A95';
|
repair02.Return_Without_Repair_IF__c =true;
|
insert repair02;
|
System.Test.startTest();
|
List<Repair__c> rpList = [select id, TAT_elapsed_workday__c from Repair__c where id = :repair01.Id];
|
System.assertEquals(6, rpList[0].TAT_elapsed_workday__c);
|
|
repair01.Repair_Start_Date__c = Date.today().addDays(2);
|
update repair01;
|
repair02.Repair_Start_Date__c = Date.today().addDays(2);
|
update repair02;
|
|
List<Repair__c> rpList2 = [select id, TAT_elapsed_workday__c from Repair__c where id = :repair01.Id];
|
System.assertEquals(7, rpList2[0].TAT_elapsed_workday__c);
|
|
repair01.Facility_Return_Receipt_Collection_Date__c = Date.today().addDays(11);
|
update repair01;
|
repair02.Facility_Return_Receipt_Collection_Date__c = Date.today().addDays(11);
|
update repair02;
|
|
List<Repair__c> rpList3 = [select id, TAT_elapsed_workday__c from Repair__c where id = :repair01.Id];
|
System.assertEquals(7, rpList3[0].TAT_elapsed_workday__c);
|
|
repair01.Repair_Final_Inspection_Date__c = null;
|
update repair01;
|
repair02.Repair_Final_Inspection_Date__c = null;
|
update repair02;
|
System.Test.stopTest();
|
List<Repair__c> rpList4 = [select id, TAT_elapsed_workday__c from Repair__c where id = :repair01.Id];
|
System.assertEquals(null, rpList4[0].TAT_elapsed_workday__c);
|
}
|
|
static testMethod void testCheckUpdate() {
|
// 病院、戦略科室、診療科の情報を作成します
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
|
// 納入機器を作る
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Dealer__c = dep.Id;
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair01.repair_cancel_date__c = Date.today();
|
insert repair01;
|
List<Repair__c> oldList = new List<Repair__c> ();
|
oldList.add(repair01);
|
Repair__c repair02 = new Repair__c();
|
|
Map<Id, Repair__c> newMap = new Map<Id, Repair__c>();
|
newMap.put(repair01.id, repair02);
|
RepairTrigger.CheckUpdate(oldList,newMap);
|
}
|
|
//限次合同产品信息维护相关测试 FXK 2021/3/8 Start
|
static testMethod void test04(){
|
// 病院、戦略科室、診療科の情報を作成します
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
|
// 納入機器を作る
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// 维修合同を作成する
|
Maintenance_Contract__c contract = createMaintenanceContract( hospital, strategicDep[0], dep);
|
// 中間テーブルを設ける
|
Maintenance_Contract_Asset__c middleTable = createMiddleTable( asset, contract);
|
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -1000); // 维修合同判断日がサービス契約のだいぶ前
|
repair01.Failure_Occurrence_Date__c =Date.today();
|
repair01.SalesOfficeCode_selection__c = '杭州';
|
repair01.On_site_repair__c = 'RC修理';
|
insert repair01;
|
|
repair01.SalesOfficeCode_selection__c = '北京';
|
update repair01;
|
repair01.SalesOfficeCode_selection__c = '哈尔滨';
|
update repair01;
|
repair01.SalesOfficeCode_selection__c = '上海';
|
update repair01;
|
repair01.SalesOfficeCode_selection__c = '广州';
|
update repair01;
|
repair01.SalesOfficeCode_selection__c = '太原';
|
update repair01;
|
repair01.SalesOfficeCode_selection__c = '成都';
|
update repair01;
|
repair01.SalesOfficeCode_selection__c = '杭州';
|
update repair01;
|
|
repair01.On_site_repair__c = '服务方式';
|
update repair01;
|
}
|
|
static testMethod void test05(){
|
//客户
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
// 保有设备
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
// 创建维修合同
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.URF_Contract__c=true;
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep[0].Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
contract.RecordTypeId='01210000000gTYq';
|
contract.URF_Contract__c = true;
|
contract.agree_Upper_limit__c = true;
|
insert contract;
|
//创建维修合同报价
|
Maintenance_Contract_Estimate__c Estimate = new Maintenance_Contract_Estimate__c();
|
Estimate.Maintenance_Contract__c = contract.Id;
|
Estimate.recordtypeId = '01210000000gTZA';
|
Estimate.Name = '报价1';
|
insert Estimate;
|
//创建维修合同报价/保有设备
|
Maintenance_Contract_Asset_Estimate__c Asset_Estimate = new Maintenance_Contract_Asset_Estimate__c();
|
Asset_Estimate.Maintenance_Contract_Estimate__c = Estimate.Id;
|
Asset_Estimate.CurrencyIsoCode = 'CNY';
|
Asset_Estimate.Series_MaxRepairCount__c = 10;
|
Asset_Estimate.Series_RepairCount__c = 5;
|
insert Asset_Estimate;
|
//创建维修合同/保有设备
|
Maintenance_Contract_Asset__c middleTable = new Maintenance_Contract_Asset__c();
|
middleTable.Asset__c = asset.Id;
|
middleTable.Maintenance_Contract__c = contract.Id;
|
middleTable.CurrencyIsoCode= 'CNY';
|
middleTable.startDateGurantee_Text__c =Date.today().addDays( 5);
|
middleTable.endDateGurantee_Text__c =Date.today().addDays( 30);
|
middleTable.Maintenance_Contract_Asset_Estimate__c = Asset_Estimate.Id;
|
insert middleTable;
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today(); // 维修合同判断日在合同开始日与合同结束日之间
|
repair01.Failure_Occurrence_Date__c =Date.today();
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.Status__c = '草案中';
|
repair01.SalesOfficeCode_selection__c = '西安RC';
|
insert repair01;
|
|
Repair__c checkRepair = null;
|
checkRepair = [SELECT Id, Name , Maintenance_Contract__c,MaintenanceContractType__c FROM Repair__c WHERE ID = :repair01.id];
|
System.assertEquals( contract.Id, checkRepair.Maintenance_Contract__c);
|
|
// 修理を作成する01
|
Repair__c repair02 = new Repair__c();
|
repair02.Account__c = dep.Id;
|
repair02.Department_Class__c = strategicDep[0].Id;
|
repair02.Hospital__c = hospital.Id;
|
repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today(); // 维修合同判断日在合同开始日与合同结束日之间
|
repair02.Failure_Occurrence_Date__c =Date.today();
|
repair02.Delivered_Product__c = asset.Id;
|
insert repair02;
|
delete repair02;
|
|
checkRepair.On_site_repair__c = '办事处修理';
|
contract.SalesOfficeCode_selection__c = '广州RC';
|
update contract;
|
checkRepair.SalesOfficeCode_selection__c = '成都';
|
update checkRepair;
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
update contract;
|
checkRepair.SalesOfficeCode_selection__c = '太原';
|
update checkRepair;
|
checkRepair.SalesOfficeCode_selection__c = '杭州';
|
update checkRepair;
|
}
|
|
static testMethod void test06(){
|
// 测试需要,插入固定日历时间,强制设定工作日和假日
|
OlympusCalendar__c oc1 = new OlympusCalendar__c(Date__c = Date.today().addDays(1), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc2 = new OlympusCalendar__c(Date__c = Date.today().addDays(2), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc3 = new OlympusCalendar__c(Date__c = Date.today().addDays(3), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc4 = new OlympusCalendar__c(Date__c = Date.today().addDays(4), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc5 = new OlympusCalendar__c(Date__c = Date.today().addDays(5), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc6 = new OlympusCalendar__c(Date__c = Date.today().addDays(6), ChangeToHoliday__c = true, ChangeToWorkday__c = false);
|
OlympusCalendar__c oc7 = new OlympusCalendar__c(Date__c = Date.today().addDays(7), ChangeToHoliday__c = true, ChangeToWorkday__c = false);
|
OlympusCalendar__c oc8 = new OlympusCalendar__c(Date__c = Date.today().addDays(8), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc9 = new OlympusCalendar__c(Date__c = Date.today().addDays(9), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc10 = new OlympusCalendar__c(Date__c = Date.today().addDays(10), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc11 = new OlympusCalendar__c(Date__c = Date.today().addDays(11), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
OlympusCalendar__c oc12 = new OlympusCalendar__c(Date__c = Date.today().addDays(12), ChangeToHoliday__c = false, ChangeToWorkday__c = true);
|
|
insert new OlympusCalendar__c[] {oc1, oc2, oc3, oc4, oc5, oc6, oc7, oc8, oc9, oc10, oc11, oc12};
|
|
// 病院、戦略科室、診療科の情報を作成します
|
Account hospital = createHospital( 'test hospital');
|
Account[] strategicDep = selectStrategicDep( hospital);
|
Account dep = createDep( hospital, strategicDep[0]);
|
|
// 納入機器を作る
|
Asset asset = createAsset( hospital, strategicDep[0], dep);
|
|
// 创建维修合同
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.status__c = '契約';
|
contract.URF_Contract__c=true;
|
contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
|
contract.Contract_Conclusion_Date__c = Date.today();
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep[0].Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today().addDays( -10); // 10日前
|
contract.Contract_End_Date__c = Date.today().addDays( 5); // 5日後
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
contract.RecordTypeId='01210000000gTYq';
|
contract.URF_Contract__c = true;
|
contract.agree_Upper_limit__c = true;
|
insert contract;
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair01.Repair_Start_Date__c = Date.today().addDays(3);
|
repair01.Repair_Final_Inspection_Date__c = Date.today().addDays(10);
|
insert repair01;
|
|
// 修理を作成する01
|
Repair__c repair02 = new Repair__c();
|
repair02.Account__c = dep.Id;
|
repair02.Department_Class__c = strategicDep[0].Id;
|
repair02.Hospital__c = hospital.Id;
|
repair02.Delivered_Product__c = asset.Id;
|
repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair02.Repair_Start_Date__c = Date.today().addDays(3);
|
repair02.Repair_Final_Inspection_Date__c = Date.today().addDays(10);
|
repair02.RepairOrderStatusCode__c ='A95';
|
repair02.Return_Without_Repair_IF__c =true;
|
insert repair02;
|
|
List<Repair__c> rpList = [select id, TAT_elapsed_workday__c from Repair__c where id = :repair01.Id];
|
System.assertEquals(6, rpList[0].TAT_elapsed_workday__c);
|
|
repair01.Repair_Start_Date__c = Date.today().addDays(2);
|
update repair01;
|
repair02.Repair_Start_Date__c = Date.today().addDays(2);
|
repair02.Maintenance_Contract__c = contract.id;
|
repair02.On_site_repair__c = 'RC修理';
|
repair02.SalesOfficeCode_selection__c = '杭州';
|
update repair02;
|
|
repair02.On_site_repair__c = '办事处修理';
|
repair02.SalesOfficeCode_selection__c = '杭州';
|
update repair02;
|
|
}
|
}
|