@isTest
|
private class PAEDecisionRecordControllerTest {
|
static testMethod void myUnitTest() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
PAE_DecisionRecord__c record = new PAE_DecisionRecord__c(PAE_DetermineResults__c = 'nonPAE', // PAE判定结果
|
PAE_ConfirmationDate__c = Date.valueOf('2020-05-06'), // OCSM QARA确认日
|
PAE_Authenticator__c = '00510000005sEEM', // OCSM QARA确认者
|
PAE_reappear_confirm__c = '未确认' // 再现结果确认
|
);
|
record.PAE_Repair__c = repair1.Id;
|
record.RecordTypeId = '01210000000gUIJ';
|
insert record;
|
PAE_DecisionRecordDetail__c detail1 = new PAE_DecisionRecordDetail__c(
|
PAED_RCAC__c = 'Intake', // Intake/Final
|
PAED_ManagementCode__c = 'test001', // Code
|
PAED_Status__c = '有效', // 状态
|
PAED_ConfirmationDate__c = Date.valueOf('2020-05-06'), // 确认日
|
PAED_Affirmant__c = '00510000005sEEM', // 确认者
|
isInterfaceCreate__c = false, // 是否通过接口新建
|
PAE_Judge__c = 'nonPAE', // PAE判定
|
PAED_Reappear_Result__c = '不再現', // 再现結果
|
InspectionCategory109__c = '0'
|
);
|
detail1.PAE_DecisionRecordD__c = record.Id;
|
detail1.PAED_Repair__c = repair1.Id;
|
insert detail1;
|
|
// System.Test.startTest();
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 2;
|
// 初始化测试
|
Test.startTest();
|
controller.init();
|
controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
controller.InsertMoreRows();
|
controller.SaveAndClose();
|
Test.stopTest();
|
|
|
|
//-------------------
|
PAE_DecisionRecord__c newRCPAED_IdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Repair__c = :repair1.id And RecordType.DeveloperName = 'ASRCDecision' Order by LastModifiedDate desc limit 1];
|
|
PageReference page2 = new PageReference('PAEDecisionRecord?RecordTypeIds=ASRCDecision&Id='+newRCPAED_IdList.id+'&RepairId='+repair1.id);
|
System.Test.setCurrentPage(page2);
|
PAEDecisionRecordController controller2 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller2.Id = newRCPAED_IdList.Id;
|
controller2.init();
|
|
controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T002';
|
controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
|
controller2.InsertRow();
|
controller2.paedRecordDetailView[1].paedrdd.PAED_ManagementCode__c = 'T003,T004';
|
controller2.paedRecordDetailView[1].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Reappear_Result__c = '不再現';
|
controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
|
PageReference page3 = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASACDecision');
|
System.Test.setCurrentPage(page3);
|
PAEDecisionRecordController controller3 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller3.init();
|
controller3.toIntake();
|
controller3.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'F001';
|
controller3.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller3.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller3.InsertMoreRows();
|
controller3.SaveAndClose();
|
// System.Test.stopTest();
|
}
|
static testMethod void myUnitTest2() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
|
if (rectAs.size() == 0) {
|
return;
|
}
|
|
Account company1 = new Account();
|
company1.RecordTypeId = rectCo[0].Id;
|
company1.Name = '病院テスト1';
|
List<Account> hps = new Account[]{company1};
|
insert hps;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[0].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = company1.Id;
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'HistoryPrd1';
|
prd1.ProductCode = 'HistoryPrd1';
|
prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
|
prd1.Name = 'HistoryPrd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Extend_new_product_gurantee__c = true;
|
prd1.Extend_Gurantee_Start__c = Date.today().addDays(-60);
|
prd1.Extend_Gurantee_End__c = Date.today().addDays(60);
|
insert prd1;
|
|
Oly_TriggerHandler.bypass('AssetHandler');
|
|
Asset ast = new Asset();
|
ast.RecordTypeId = rectAs[0].Id;
|
ast.SerialNumber = 'abcdefg';
|
ast.Name = '测试资产1';
|
ast.AccountId = depart1.Id;
|
ast.Department_Class__c = dc1s[0].Id;
|
ast.Hospital__c = company1.Id;
|
ast.Product2Id = prd1.Id;
|
ast.Guarantee_period_for_products__c = Date.today();
|
ast.InstallDate = Date.today();
|
ast.Manage_type__c = '个体管理';
|
ast.FirstApproveDate_old__c = Date.today().addDays(-30);
|
insert ast;
|
|
QIS_Report__c qis = new QIS_Report__c();
|
qis.nonyushohin__c = ast.Id;
|
qis.Name = 'test-1111111111';
|
//qis.consumable__c = pro5.Id;
|
qis.Hospital__c = company1.Id;
|
qis.RC__c = UserInfo.getUserId();
|
qis.Department_Class__c = dc1s[0].Id;
|
qis.Hospital_Department__c = depart1.Id;
|
qis.Damage_For_Doc_Or_Pat__c = '有';
|
qis.Relation_With_The_Problem__c = '有可能';
|
qis.Report_For_Goz__c = '不知道';
|
//qis.IsSendQIS__c = true;
|
insert qis;
|
// System.Test.startTest();
|
PageReference page4 = new PageReference('/apex/PAEDecisionRecord?QISReportId='+qis.id+'&RecordTypeIds=ASACDecision');
|
System.Test.setCurrentPage(page4);
|
PAEDecisionRecordController controller4 = new PAEDecisionRecordController(new ApexPages.StandardController(qis));
|
controller4.CancelineFlag = 2;
|
// 初始化测试
|
controller4.init();
|
controller4.toIntake();
|
controller4.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'Q001';
|
controller4.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller4.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller4.SaveAndClose();
|
}
|
|
|
|
static testMethod void myUnitTest3() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
|
// System.Test.startTest();
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 3;
|
// 初始化测试
|
controller.init();
|
controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
controller.InsertMoreRows();
|
controller.SaveAndClose();
|
// System.Test.stopTest();
|
}
|
|
|
static testMethod void myUnitTest4() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
|
// System.Test.startTest();
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 3;
|
// 初始化测试
|
controller.init();
|
controller.paedRecordDetailView = null;
|
// controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
// controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'nonPAE';
|
// controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
// controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
// controller.InsertMoreRows();
|
// controller.SaveAndClose();
|
// System.Test.stopTest();
|
}
|
|
static testMethod void myUnitTest5() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
repair1.if_Repair_Allowed__c = '可修理(不需要回收)';
|
|
insert new Repair__c[] {repair1};
|
|
// System.Test.startTest();
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 2;
|
controller.intakePAEReappearConfirm = 'nonull';
|
controller.editFlag = false;
|
controller.RecordTypeName='';
|
controller.isOSH = true;
|
// 初始化测试
|
System.Test.startTest();
|
controller.init();
|
controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
controller.InsertMoreRows();
|
controller.SaveAndClose();
|
|
//-------------------
|
|
PAEDecisionRecordController controller2 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller2.init();
|
|
controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T002';
|
controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
|
controller2.InsertRow();
|
controller2.paedRecordDetailView[1].paedrdd.PAED_ManagementCode__c = 'T003';
|
controller2.paedRecordDetailView[1].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Reappear_Result__c = '不再現';
|
controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
controller2.sendToSAP();
|
|
PageReference page3 = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASACDecision');
|
System.Test.setCurrentPage(page3);
|
PAEDecisionRecordController controller3 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller3.RecordTypeName = '';
|
controller3.init();
|
controller3.toIntake();
|
controller3.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'F001';
|
controller3.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller3.paedRecordDetailView[0].paedrdd.PAED_Status__c = '取消';
|
controller3.paedRecordDetailView[0].check = true;
|
controller3.CancelineFlag = 3;
|
controller3.InsertMoreRows();
|
controller3.SaveAndClose();
|
System.Test.stopTest();
|
}
|
static testMethod void test001() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
PAE_DecisionRecord__c record = new PAE_DecisionRecord__c(PAE_DetermineResults__c = 'nonPAE', // PAE判定结果
|
PAE_ConfirmationDate__c = Date.valueOf('2020-05-06'), // OCSM QARA确认日
|
PAE_Authenticator__c = '00510000005sEEM', // OCSM QARA确认者
|
PAE_reappear_confirm__c = '未确认' // 再现结果确认
|
);
|
record.PAE_Repair__c = repair1.Id;
|
record.RecordTypeId = '01210000000gUIJ';
|
// insert record;
|
insert new PAE_DecisionRecord__c[] {record};
|
PAE_DecisionRecordDetail__c detail1 = new PAE_DecisionRecordDetail__c(
|
PAED_RCAC__c = 'Intake', // Intake/Final
|
PAED_Status__c = '有效', // 状态
|
PAED_ConfirmationDate__c = Date.valueOf('2020-05-06'), // 确认日
|
PAED_Affirmant__c = '00510000005sEEM', // 确认者
|
isInterfaceCreate__c = false, // 是否通过接口新建
|
PAED_Reappear_Result__c = '不再現', // 再现結果
|
InspectionCategory109__c = '0'
|
);
|
detail1.PAE_DecisionRecordD__c = record.Id;
|
detail1.PAED_Repair__c = repair1.Id;
|
insert detail1;
|
RSA_master_data__c psa = new RSA_master_data__c(RSS_CODE__C = 'Q001', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa;
|
RSA_master_data__c psa2 = new RSA_master_data__c(RSS_CODE__C = 'T002', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa2;
|
RSA_master_data__c psa3 = new RSA_master_data__c(RSS_CODE__C = 'T003', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa3;
|
RSA_master_data__c psa4 = new RSA_master_data__c(RSS_CODE__C = 'T004', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa4;
|
RSA_master_data__c psa5 = new RSA_master_data__c(RSS_CODE__C = 'T005', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa5;
|
RSA_master_data__c psa6 = new RSA_master_data__c(RSS_CODE__C = 'T006', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa6;
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 3;
|
// 初始化测试
|
controller.init();
|
controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T002';
|
controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = '';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
controller.InsertMoreRows();
|
controller.SaveAndClose();
|
PAE_DecisionRecord__c newRCPAED_IdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Repair__c = :repair1.id And RecordType.DeveloperName = 'ASRCDecision' Order by LastModifiedDate desc limit 1];
|
PageReference page2 = new PageReference('PAEDecisionRecord?RecordTypeIds=ASRCDecision&Id='+newRCPAED_IdList.id+'&RepairId='+repair1.id);
|
System.Test.setCurrentPage(page2);
|
PAEDecisionRecordController controller2 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller.CancelineFlag = 2;
|
controller2.init();
|
|
controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T005';
|
controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = '';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
|
controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T003,T004';
|
controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = '';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
controller2.sendToSAP();
|
|
PageReference page3 = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASACDecision');
|
System.Test.setCurrentPage(page3);
|
PAEDecisionRecordController controller3 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller.CancelineFlag = 3;
|
controller3.init();
|
controller3.toIntake();
|
controller3.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T006';
|
controller3.paedRecordDetailView[0].paedrdd.PAE_Judge__c = '';
|
controller3.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller3.InsertMoreRows();
|
controller3.SaveAndClose();
|
}
|
static testMethod void test002() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
PAE_DecisionRecord__c record = new PAE_DecisionRecord__c(PAE_DetermineResults__c = 'nonPAE', // PAE判定结果
|
PAE_ConfirmationDate__c = Date.valueOf('2020-05-06'), // OCSM QARA确认日
|
PAE_Authenticator__c = '00510000005sEEM', // OCSM QARA确认者
|
PAE_reappear_confirm__c = '未确认' // 再现结果确认
|
);
|
record.PAE_Repair__c = repair1.Id;
|
record.RecordTypeId = '01210000000gUIJ';
|
// insert record;
|
insert new PAE_DecisionRecord__c[] {record};
|
PAE_DecisionRecordDetail__c detail1 = new PAE_DecisionRecordDetail__c(
|
PAED_RCAC__c = 'Intake', // Intake/Final
|
PAED_Status__c = '有效', // 状态
|
PAED_ConfirmationDate__c = Date.valueOf('2020-05-06'), // 确认日
|
PAED_Affirmant__c = '00510000005sEEM', // 确认者
|
isInterfaceCreate__c = false, // 是否通过接口新建
|
PAED_Reappear_Result__c = '不再現', // 再现結果
|
InspectionCategory109__c = '0'
|
);
|
detail1.PAE_DecisionRecordD__c = record.Id;
|
detail1.PAED_Repair__c = repair1.Id;
|
insert detail1;
|
RSA_master_data__c psa = new RSA_master_data__c(RSS_CODE__C = 'Q001', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa;
|
RSA_master_data__c psa2 = new RSA_master_data__c(RSS_CODE__C = 'T002', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa2;
|
RSA_master_data__c psa3 = new RSA_master_data__c(RSS_CODE__C = 'T003', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa3;
|
RSA_master_data__c psa4 = new RSA_master_data__c(RSS_CODE__C = 'T004', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa4;
|
RSA_master_data__c psa5 = new RSA_master_data__c(RSS_CODE__C = 'T005', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa5;
|
RSA_master_data__c psa6 = new RSA_master_data__c(RSS_CODE__C = 'T006', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa6;
|
|
// System.Test.startTest();
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 2;
|
// 初始化测试
|
Test.startTest();
|
controller.init();
|
controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
controller.InsertMoreRows();
|
controller.SaveAndClose();
|
test.stopTest();
|
|
|
|
//-------------------
|
PAE_DecisionRecord__c newRCPAED_IdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Repair__c = :repair1.id And RecordType.DeveloperName = 'ASRCDecision' Order by LastModifiedDate desc limit 1];
|
|
PageReference page2 = new PageReference('PAEDecisionRecord?RecordTypeIds=ASRCDecision&Id='+newRCPAED_IdList.id+'&RepairId='+repair1.id);
|
System.Test.setCurrentPage(page2);
|
PAEDecisionRecordController controller2 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller2.Id = newRCPAED_IdList.Id;
|
controller2.init();
|
|
controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T002';
|
controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
|
controller2.InsertRow();
|
controller2.paedRecordDetailView[1].paedrdd.PAED_ManagementCode__c = 'T003,T004';
|
controller2.paedRecordDetailView[1].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Reappear_Result__c = '不再現';
|
controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
|
PageReference page3 = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASACDecision');
|
System.Test.setCurrentPage(page3);
|
PAEDecisionRecordController controller3 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller3.init();
|
controller3.toIntake();
|
controller3.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'F001';
|
controller3.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller3.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller3.InsertMoreRows();
|
controller3.sendToSAP();
|
// System.Test.stopTest();
|
}
|
|
static testMethod void test003() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
PAE_DecisionRecord__c record = new PAE_DecisionRecord__c(PAE_DetermineResults__c = 'nonPAE', // PAE判定结果
|
PAE_ConfirmationDate__c = Date.valueOf('2020-05-06'), // OCSM QARA确认日
|
PAE_Authenticator__c = '00510000005sEEM', // OCSM QARA确认者
|
PAE_reappear_confirm__c = '未确认', // 再现结果确认
|
PAE_DetermineResults_Text__c = 'PAE'
|
);
|
record.PAE_Repair__c = repair1.Id;
|
record.RecordTypeId = '01210000000gUIJ';
|
// insert record;
|
insert new PAE_DecisionRecord__c[] {record};
|
PAE_DecisionRecordDetail__c detail1 = new PAE_DecisionRecordDetail__c(
|
PAED_RCAC__c = 'Intake', // Intake/Final
|
PAED_Status__c = '有效', // 状态
|
PAED_ConfirmationDate__c = Date.valueOf('2020-05-06'), // 确认日
|
PAED_Affirmant__c = '00510000005sEEM', // 确认者
|
isInterfaceCreate__c = false, // 是否通过接口新建
|
PAED_Reappear_Result__c = '不再現', // 再现結果
|
InspectionCategory109__c = '0',
|
PAED_ManagementCode__c = 'Q006',
|
PAE_Judge__c = 'PAE'
|
// PAE_DetermineResults_Text__c = 'PAE'
|
);
|
detail1.PAE_DecisionRecordD__c = record.Id;
|
detail1.PAED_Repair__c = repair1.Id;
|
insert detail1;
|
RSA_master_data__c psa = new RSA_master_data__c(RSS_CODE__C = 'Q001', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa;
|
RSA_master_data__c psa2 = new RSA_master_data__c(RSS_CODE__C = 'T002', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa2;
|
RSA_master_data__c psa3 = new RSA_master_data__c(RSS_CODE__C = 'T003', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa3;
|
RSA_master_data__c psa4 = new RSA_master_data__c(RSS_CODE__C = 'T004', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa4;
|
RSA_master_data__c psa5 = new RSA_master_data__c(RSS_CODE__C = 'T005', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa5;
|
RSA_master_data__c psa6 = new RSA_master_data__c(RSS_CODE__C = 'T006', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa6;
|
|
// // System.Test.startTest();
|
// PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
// System.Test.setCurrentPage(page);
|
// PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// controller.CancelineFlag = 2;
|
// // 初始化测试
|
// controller.init();
|
// // controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
// // controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
// // controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
// // controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
// controller.InsertRow();
|
// controller.paedRecordDetailView[1].paedrdd.PAED_ManagementCode__c = 'T001';
|
// controller.paedRecordDetailView[1].paedrdd.PAE_Judge__c = 'Unknown';
|
// controller.paedRecordDetailView[1].paedrdd.PAED_Status__c = '有效';
|
// controller.paedRecordDetailView[1].paedrdd.PAED_Reappear_Result__c = '再現';
|
// controller.SaveAndClose();
|
|
|
|
//-------------------
|
PAE_DecisionRecord__c newRCPAED_IdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Repair__c = :repair1.id And RecordType.DeveloperName = 'ASRCDecision' Order by LastModifiedDate desc limit 1];
|
|
PageReference page2 = new PageReference('PAEDecisionRecord?RecordTypeIds=ASRCDecision&Id='+newRCPAED_IdList.id+'&RepairId='+repair1.id);
|
System.Test.setCurrentPage(page2);
|
PAEDecisionRecordController controller2 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
// controller2.Id = newRCPAED_IdList.Id;
|
controller2.init();
|
|
// controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T002';
|
// controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
// controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
// controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
|
controller2.InsertRow();
|
controller2.paedRecordDetailView[1].paedrdd.PAED_ManagementCode__c = 'T003,T004';
|
controller2.paedRecordDetailView[1].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Reappear_Result__c = '不再現';
|
// controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
|
// PageReference page3 = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASACDecision');
|
// System.Test.setCurrentPage(page3);
|
// PAEDecisionRecordController controller3 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// // 初始化测试
|
// controller3.init();
|
// controller3.toIntake();
|
// controller3.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'F001';
|
// controller3.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
// controller3.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
// controller3.InsertMoreRows();
|
// controller3.sendToSAP();
|
// System.Test.stopTest();
|
}
|
static testMethod void test004() {
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
// ユーザー作成
|
User hpOwner = new User(Job_Category__c = '销售服务', Test_staff__c = true, LastName = 'hp', FirstName = 'owner', 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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科','診療科 普外科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'testHp1', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[1].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
|
insert depart1;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
prd1.Category3__c = '';
|
prd1.Category4__c = 'CV';
|
|
insert prd1;
|
|
Asset ast1 = new Asset();
|
ast1.Name = '保有設備1';
|
ast1.Hospital__c = hp1.Id;
|
ast1.Department_Class__c = dc1s[0].Id;
|
ast1.AccountId = depart1.Id;
|
ast1.Product2Id = prd1.Id;
|
ast1.SerialNumber = 'SerialNumber1';
|
ast1.Guarantee_period_for_products__c = Date.today();
|
ast1.InstallDate = Date.today();
|
|
insert ast1;
|
|
Repair__c repair1 = new Repair__c();
|
repair1.Service_Repair_No__c = 'repair1';
|
repair1.Hospital__c = hp1.Id;
|
repair1.Department_Class__c = dc1s[0].Id;
|
repair1.Account__c = depart1.Id;
|
repair1.Delivered_Product__c = ast1.Id;
|
repair1.Repair_List_Price__c = 100;
|
repair1.Billing_Amount__c = 10;
|
repair1.Paid_Amount__c = 1;
|
repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
|
repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
|
repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
|
repair1.Incharge_Staff__c = hpOwner.Id;
|
|
insert new Repair__c[] {repair1};
|
PAE_DecisionRecord__c record = new PAE_DecisionRecord__c(
|
PAE_DetermineResults__c = 'nonPAE', // PAE判定结果
|
PAE_ConfirmationDate__c = Date.valueOf('2020-05-06'), // OCSM QARA确认日
|
PAE_Authenticator__c = '00510000005sEEM', // OCSM QARA确认者
|
PAE_reappear_confirm__c = '未确认',// 再现结果确认
|
PAE_DetermineResults_Text__c = 'nonPAE'
|
);
|
record.PAE_Repair__c = repair1.Id;
|
record.RecordTypeId = '01210000000gUIJ';
|
// insert record;
|
insert new PAE_DecisionRecord__c[] {record};
|
PAE_DecisionRecordDetail__c detail1 = new PAE_DecisionRecordDetail__c(
|
PAED_RCAC__c = 'Intake', // Intake/Final
|
PAED_Status__c = '有效', // 状态
|
PAED_ConfirmationDate__c = Date.valueOf('2020-05-06'), // 确认日
|
PAED_Affirmant__c = '00510000005sEEM', // 确认者
|
isInterfaceCreate__c = false, // 是否通过接口新建
|
PAED_Reappear_Result__c = '不再現', // 再现結果
|
InspectionCategory109__c = '0'
|
);
|
detail1.PAE_DecisionRecordD__c = record.Id;
|
detail1.PAED_Repair__c = repair1.Id;
|
insert detail1;
|
RSA_master_data__c psa = new RSA_master_data__c(RSS_CODE__C = 'Q001', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa;
|
RSA_master_data__c psa2 = new RSA_master_data__c(RSS_CODE__C = 'T002', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa2;
|
RSA_master_data__c psa3 = new RSA_master_data__c(RSS_CODE__C = 'T003', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa3;
|
RSA_master_data__c psa4 = new RSA_master_data__c(RSS_CODE__C = 'T004', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa4;
|
RSA_master_data__c psa5 = new RSA_master_data__c(RSS_CODE__C = 'T005', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa5;
|
RSA_master_data__c psa6 = new RSA_master_data__c(RSS_CODE__C = 'T006', IS_INTAKE_ESTIMATION__C = 'Intake,Estimation', IS_PAE__c = 'Unknown', IS_INACTIVE__C = 'No');
|
insert psa6;
|
|
// System.Test.startTest();
|
PageReference page = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASRCDecision');
|
System.Test.setCurrentPage(page);
|
PAEDecisionRecordController controller = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
controller.CancelineFlag = 2;
|
// 初始化测试
|
Test.startTest();
|
controller.init();
|
controller.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T001';
|
controller.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '再現';
|
controller.InsertMoreRows();
|
controller.SaveAndClose();
|
test.stopTest();
|
|
|
|
//-------------------
|
PAE_DecisionRecord__c newRCPAED_IdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_Repair__c = :repair1.id And RecordType.DeveloperName = 'ASRCDecision' Order by LastModifiedDate desc limit 1];
|
|
PageReference page2 = new PageReference('PAEDecisionRecord?RecordTypeIds=ASRCDecision&Id='+newRCPAED_IdList.id+'&RepairId='+repair1.id);
|
System.Test.setCurrentPage(page2);
|
PAEDecisionRecordController controller2 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller2.Id = newRCPAED_IdList.Id;
|
controller2.init();
|
|
controller2.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'T002';
|
controller2.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[0].paedrdd.PAED_Reappear_Result__c = '不再現';
|
|
controller2.InsertRow();
|
controller2.paedRecordDetailView[1].paedrdd.PAED_ManagementCode__c = 'T003,T004';
|
controller2.paedRecordDetailView[1].paedrdd.PAE_Judge__c = 'Unknown';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Status__c = '有效';
|
controller2.paedRecordDetailView[1].paedrdd.PAED_Reappear_Result__c = '不再現';
|
controller2.InsertMoreRows();
|
controller2.SaveAndClose();
|
|
PageReference page3 = new PageReference('/apex/PAEDecisionRecord?RepairId='+repair1.id+'&RecordTypeIds=ASACDecision');
|
System.Test.setCurrentPage(page3);
|
PAEDecisionRecordController controller3 = new PAEDecisionRecordController(new ApexPages.StandardController(repair1));
|
// 初始化测试
|
controller3.init();
|
controller3.toIntake();
|
controller3.paedRecordDetailView[0].paedrdd.PAED_ManagementCode__c = 'F001';
|
controller3.paedRecordDetailView[0].paedrdd.PAE_Judge__c = 'Unknown';
|
controller3.paedRecordDetailView[0].paedrdd.PAED_Status__c = '有效';
|
controller3.InsertMoreRows();
|
controller3.sendToSAP();
|
// System.Test.stopTest();
|
}
|
|
|
|
}
|