@isTest
|
private class LexInquiryControllerTest {
|
@isTest
|
static void testmethod1(){
|
id rectCo =
|
Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
|
if (rectCo == null) {
|
return;
|
}
|
id rectSct =
|
Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_BF').getRecordTypeId();
|
if (rectSct == null) {
|
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;
|
}
|
id rectAs =
|
Schema.SObjectType.Asset.getRecordTypeInfosByDeveloperName().get('Shipment').getRecordTypeId();
|
if (rectAs == null) {
|
return;
|
}
|
|
Account company1 = new Account();
|
company1.RecordTypeId = rectCo ;
|
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 ;
|
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.Order_No__c = '12345';
|
ast.Manage_type__c = '个体管理';
|
ast.Asset_Owner__c ='病院資産';
|
|
ast.FirstApproveDate_old__c = Date.today().addDays(-30);
|
insert ast;
|
Product2 pro5 = new Product2(Name = 'name05', IsActive = true, Family = 'SP',
|
Fixture_Model_No__c = 'n05', Serial_Lot_No__c = 'S/N tracing',
|
Fixture_Model_No_T__c = 'n05',
|
ProductCode_Ext__c = 'pc05', Manual_Entry__c = false);
|
insert pro5;
|
|
QIS_Report__c qis1 = new QIS_Report__c();
|
qis1.nonyushohin__c = ast.Id;
|
//qis1.consumable__c = pro5.Id;
|
qis1.Hospital__c = company1.Id;
|
qis1.RC__c = UserInfo.getUserId();
|
qis1.Department_Class__c = dc1s[0].Id;
|
qis1.Hospital_Department__c = depart1.Id;
|
qis1.Damage_For_Doc_Or_Pat__c = '有';
|
qis1.Relation_With_The_Problem__c = '有可能';
|
qis1.Report_For_Goz__c = '不知道';
|
qis1.IsSendQIS__c = false;
|
qis1.Generation_Source__c = '保有设备';
|
qis1.consumable__c = pro5.Id;
|
qis1.Lots_No__c = 'LOT123';
|
qis1.sell__c = '购买';
|
qis1.Instration_date_consumable__c = Date.today();
|
qis1.contract_number_ET__c = '123';
|
|
insert qis1;
|
|
Task t1 = new Task(
|
Subject = 'test_task',
|
Status = '未着手',
|
Priority = '中',
|
whatid = qis1.id
|
);
|
insert new Task[] {t1};
|
LexInquiryController.init('123');
|
LexInquiryController.init(t1.Id);
|
LexInquiryController.makeAndUpdateTask('123','123');
|
LexInquiryController.makeAndUpdateTask('未着手',t1.Id);
|
|
QuoteIrai__c irai = new QuoteIrai__c();
|
irai.IraiSubject__c = '委托01';
|
irai.IraiUser__c = null;
|
irai.CurrencyIsoCode = 'USD';
|
insert irai;
|
LexInquiryController.getQuoteIrai(irai.Id);
|
LexInquiryController.getQuoteIrai('123');
|
LexInquiryController.makeAndUpdateQuoteIrai('更新完毕',irai.Id);
|
LexInquiryController.makeAndUpdateQuoteIrai('更新完毕','123');
|
|
Lead ret = new Lead();
|
ret.LastName = 'leadName';
|
ret.Email = 'test@test.com.leadtest';
|
ret.company = 'tesetCompany';
|
insert ret;
|
LexInquiryController.makeAndUpdateLead('0061000000OS7F5AAL',ret.Id,irai.Id);
|
LexInquiryController.makeAndUpdateLead('123',ret.Id,irai.Id);
|
|
}
|
@IsTest
|
static void testMethod2(){
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.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;
|
}
|
|
|
// insert hospital
|
Account company1 = new Account();
|
company1.RecordTypeId = rectCo[0].Id;
|
company1.Name = '病院テスト1';
|
company1.OCM_man_province_txt__c = '江西';
|
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;
|
depart1.OCM_man_province_txt__c = '江西';
|
|
insert new Account[] {depart1};
|
|
List<Product2> prdList = new List<Product2>();
|
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);
|
prdList.add(prd1);
|
insert prdList;
|
|
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);
|
|
Oly_TriggerHandler.bypass('AssetHandler');
|
|
insert ast;
|
|
Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
|
|
String RecordTypeID = ast1.RecordTypeID__c;
|
|
System.assertEquals(RecordTypeID , ast.RecordTypeId);
|
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
Opportunity opp = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=depart1.Id,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
insert opp;
|
LexInquiryController.getOpportunityIds(opp.Id);
|
|
}
|
}
|