@isTest
private class RepairAgainAnHandlerTest {
@isTest static void testmethod_1(){
RepairAgainAn__c ra = new RepairAgainAn__c();
ra.Name = 'TestRa';
ra.Dectect_Picture1__c = '
';
ra.Dectect_Picture2__c = '
';
ra.OSH_Dectect_Picture1__c = '
';
ra.OSH_Dectect_Picture2__c = '
';
ra.OSH_Dectect_Picture3__c = '
';
ra.OSH_Dectect_Picture4__c = '
';
ra.OSH_Dectect_Picture5__c = '
';
ra.OSH_Dectect_Picture6__c = '
';
ra.OSH_Dectect_Picture7__c = '
';
ra.OSH_Dectect_Picture8__c = '
';
insert ra;
ra.Dectect_Picture1__c = '
';
update ra;
ra = [select Dectect_Picture1_URL__c, Dectect_Picture2_URL__c, OSH_Dectect_Picture1_URL__c, OSH_Dectect_Picture2_URL__c,
OSH_Dectect_Picture3_URL__c, OSH_Dectect_Picture4_URL__c from RepairAgainAn__c where Id = :ra.Id];
}
@isTest static void testmethod_2(){
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
User hpOwner = new User(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;
User testOwner = new User(Test_staff__c = true, LastName = 'test', FirstName = 'owner', Alias = 'test', CommunityNickname = 'testOwner', Email = 'olympus_test@sunbridge.com', Username = 'olympus_test@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
insert testOwner;
List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
if (rectDpt.size() == 0) {
return;
}
Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'SoakupTestHp', OwnerId = hpOwner.Id);
insert hp;
Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
dpt.Name = '*';
dpt.Department_Name__c = 'TestDepart';
dpt.ParentId = dc.Id;
dpt.Department_Class__c = dc.Id;
dpt.Hospital__c = hp.Id;
insert dpt;
Asset asset = new Asset();
asset.Name = 'テスト機器';
asset.AccountId = dpt.Id;
asset.Department_Class__c = dc.Id;
asset.Hospital__c = hp.Id;
asset.SerialNumber = 'testserial';
insert asset;
Repair__c repair01 = new Repair__c();
repair01.Account__c = dpt.Id;
repair01.Department_Class__c = dc.Id;
repair01.Hospital__c = hp.Id;
repair01.Delivered_Product__c = asset.Id;
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0);
repair01.FSE_Work_Location__c = '上海';
repair01.Service_Repair_No__c = 'SAP0001';
repair01.Incharge_Staff__c = hpOwner.Id;
repair01.On_site_repair__c = 'RC修理';
repair01.work_location_select__c = '北京办事处';
repair01.SAPRepairNo__c = 'RepairAgain';
insert repair01;
Repair__c repair02 = new Repair__c();
repair02.Account__c = dpt.Id;
repair02.Department_Class__c = dc.Id;
repair02.Hospital__c = hp.Id;
repair02.Delivered_Product__c = asset.Id;
repair02.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0);
repair02.FSE_Work_Location__c = '上海';
repair02.Service_Repair_No__c = 'SAP0002';
repair02.Incharge_Staff__c = hpOwner.Id;
repair02.On_site_repair__c = 'RC修理';
repair02.work_location_select__c = '北京办事处';
repair02.SAPRepairNo__c = 'RepairAgain1';
insert repair02;
RepairAgainAn__c ra = new RepairAgainAn__c();
ra.Name = 'TestRa2';
ra.Repair__c = repair01.Id;
insert ra;
ra.RepairAgain_Status__c='草案中';
update ra;
ra.RepairLast__c = repair02.Id;
ra.RC_Confirmer__c = testOwner.Id;
update ra;
ra.RepairAgain_Status__c='RC填写完毕';
update ra;
// ra.RepairAgain_Status__c='OSH受理';
// update ra;
// ra.RepairAgain_Status__c='OSH填写完毕';
// update ra;
// ra.JudgementOSH__c='质量原因';
// ra.AnalysisOSH__c='f';
// ra.AnalysisReasonOSH__c='f';
// ra.ActionOSH__c='无偿维修';
// update ra;
// ra.AnalysisOCM__c='f';
// ra.ActionOCM__c='无偿维修';
// ra.Technical_Responsibility__c='00510000006klDyAAI';
// ra.OCM_Confirmer__c='00510000006klDyAAI';
// update ra;
// ra.RepairAgain_Status__c='完毕';
// update ra;
}
}