@isTest
|
private class Add_ReportTest {
|
private static String loginId {get; set;}
|
private static User u1 {get; set;}
|
private static User u2 {get; set;}
|
private static User u3 {get; set;}
|
private static Account accHP {get; set;}
|
private static Account accDepClass {get; set;}
|
private static Account accDep {get; set;}
|
private static Contact con1 {get; set;}
|
private static Contact con2 {get; set;}
|
private static Contact con3 {get; set;}
|
private static Contact con4 {get; set;}
|
private static Contact con5 {get; set;}
|
private static Opportunity opp1 {get; set;}
|
private static Opportunity opp2 {get; set;}
|
private static Opportunity opp3 {get; set;}
|
private static Opportunity opp4 {get; set;}
|
private static Opportunity opp5 {get; set;}
|
private static Maintenance_Contract__c mc1 {get; set;}
|
private static Maintenance_Contract__c mc2 {get; set;}
|
private static String accDepId {get; set;}
|
private static String accDepName {get; set;}
|
|
|
/**
|
* 初期処理.
|
*/
|
@TestSetup
|
private static void init() {
|
NFM001Controller.isRunning = true;
|
loginId = UserInfo.getUserId();
|
id pid = UserInfo.getProfileId();
|
// id pid = System.Label.ProfileId_2S1;
|
//Profile p = [select id from Profile where id = :System.Label.ProfileId_SystemAdmin];
|
u3 = new User(Test_staff__c = true);
|
u3.LastName = '_サンブリッジ';
|
u3.Batch_User__c = true;
|
u3.FirstName = 'う';
|
u3.Alias = 'う';
|
u3.Email = 'olympusTest03@sunbridge.com';
|
u3.Username = 'olympusTest03@sunbridge.com';
|
u3.CommunityNickname = 'う';
|
u3.IsActive = true;
|
u3.EmailEncodingKey = 'ISO-2022-JP';
|
u3.TimeZoneSidKey = 'Asia/Tokyo';
|
u3.LocaleSidKey = 'ja_JP';
|
u3.LanguageLocaleKey = 'ja';
|
u3.ProfileId = pid;
|
u3.Job_Category__c = '支援';
|
u3.Province__c = '東京';
|
|
|
u1 = new User(Test_staff__c = true);
|
u1.LastName = '_サンブリッジ';
|
u1.FirstName = 'あ';
|
u1.Batch_User__c = true;
|
u1.Alias = 'あ';
|
u1.Email = 'olympusTest01@sunbridge.com';
|
u1.Username = 'olympusTest10@sunbridge.com';
|
u1.CommunityNickname = 'あ1';
|
u1.IsActive = true;
|
u1.EmailEncodingKey = 'ISO-2022-JP';
|
u1.TimeZoneSidKey = 'Asia/Tokyo';
|
u1.LocaleSidKey = 'ja_JP';
|
u1.LanguageLocaleKey = 'ja';
|
u1.ProfileId = pid;
|
u1.Job_Category__c = '销售服务';
|
u1.Province__c = '東京';
|
u1.ManagerId = u3.id;
|
|
|
u2 = new User(Test_staff__c = true);
|
u2.LastName = '_サンブリッジ';
|
u2.FirstName = 'い';
|
u2.Batch_User__c = true;
|
u2.Alias = 'い';
|
u2.Email = 'olympusTest02@sunbridge.com';
|
u2.Username = 'olympusTest02@sunbridge.com';
|
u2.CommunityNickname = 'い';
|
u2.IsActive = true;
|
u2.EmailEncodingKey = 'ISO-2022-JP';
|
u2.TimeZoneSidKey = 'Asia/Tokyo';
|
u2.LocaleSidKey = 'ja_JP';
|
u2.LanguageLocaleKey = 'ja';
|
u2.ProfileId = pid;
|
u2.Job_Category__c = '销售推广';
|
u2.Province__c = '東京';
|
insert New List<user>{u1,u2,u3};
|
|
|
//RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT']; // 耳鼻喉科
|
|
//Address_Level__c al = [select id from Address_Level__c where Level1_Code__c =:'CN-01'];
|
//Address_Level2__c al2 = [select id from Address_Level2__c where Name =:'延庆县'];
|
system.runAs(u1) {
|
List<String> strList = new List<String>();
|
strList.add('Contact');
|
strList.add('Agency_Contact__c');
|
TestDataUtility.CreatePIPolicyConfigurations(strList);
|
Address_Level__c al = new Address_Level__c();
|
al.Name = '東京';
|
al.Level1_Code__c = 'CN-99';
|
al.Level1_Sys_No__c = '999999';
|
insert al;
|
|
Address_Level2__c al2 = new Address_Level2__c();
|
al2.Level1_Code__c = 'CN-99';
|
al2.Level1_Sys_No__c = '999999';
|
al2.Level1_Name__c = '東京';
|
al2.Name = '渋谷区';
|
al2.Level2_Code__c = 'CN-9999';
|
al2.Level2_Sys_No__c = '9999999';
|
al2.Address_Level__c = al.id;
|
insert al2;
|
|
accHP = new Account();
|
accHP.Name = '病院1';
|
accHP.Grade__c = '一般';
|
accHP.OCM_Category__c = '一般';
|
accHP.Attribute_Type__c = '保険省';
|
accHP.Speciality_Type__c = '総合病院';
|
accHP.Is_Active__c = '有効';
|
accHP.State_Master__c = al.id;
|
accHP.City_Master__c = al2.id;
|
accHP.RecordTypeId = '01210000000QemG';
|
accHP.Valid_To__c = Date.today() + 2;
|
accHP.FSE_GI_Main_Leader__c = UserInfo.getUserId();
|
accHP.FSE_SP_Main_Leader__c = UserInfo.getUserId();
|
insert accHP;
|
/*
|
accDepClass = new Account();
|
accDepClass.Name = '戦略科室分類1';
|
accDepClass.Department_Class_Label__c = '耳鼻喉科';
|
accDepClass.Hospital_Department_Class__c = accHP.id;
|
accDepClass.ParentId = accHP.id;
|
accDepClass.RecordTypeId = rtDepClass.id;
|
insert accDepClass;
|
*/
|
accDepClass = [select Id from Account where ParentId = :accHP.Id and Department_Class_Label__c = '耳鼻喉科'];
|
|
accDep = new Account();
|
accDep.Name = '診療科1';
|
accDep.Department_Class_Label__c = '診療科1';
|
accDep.Hospital__c = accHP.id;
|
accDep.ParentId = accDepClass.id;
|
accDep.Department_Class__c = accDepClass.id;
|
accDep.Department_Name__c = '診療科1';
|
accDep.CurrencyIsoCode = 'CNY';
|
accDep.RecordTypeId = '01210000000Qfm2';
|
accDep.FSE_GI_Main_Leader__c = UserInfo.getUserId();
|
accDep.FSE_SP_Main_Leader__c = UserInfo.getUserId();
|
|
insert accDep;
|
accDepId = accDep.Id;
|
accDep = [select Name from Account where Id = :accDep.Id];
|
accDepName = accDep.Name;
|
// 取引先責任者の住所を数式項目に変更の為、当該項目を削除
|
// 省の参照先は病院の住所になったため、カバレッジテストを行うには
|
// 所属する病院の賞を変更して実施してください。by 宗像(真)
|
List<Contact> conList = new List<Contact>();
|
con1 = new Contact();
|
con1.Firstname = 'ZZ1';
|
con1.LastName = '取引先責任者1';
|
con1.RecordTypeId = '01210000000QfWd';
|
con1.AccountId = accDep.Id;
|
// con1.State__c = '北京市';
|
con2 = new Contact();
|
con2.Firstname = 'ZZ2';
|
con2.LastName = '取引先責任者2';
|
con2.RecordTypeId = '01210000000QfWd';
|
con2.AccountId = accDep.Id;
|
// con2.State__c = '北京市';
|
con3 = new Contact();
|
con3.Firstname = 'ZZ3';
|
con3.LastName = '取引先責任者3';
|
con3.RecordTypeId = '01210000000QfWd';
|
con3.AccountId = accDep.Id;
|
// con3.State__c = '北京市';
|
con4 = new Contact();
|
con4.Firstname = 'ZZ4';
|
con4.LastName = '取引先責任者4';
|
con4.RecordTypeId = '01210000000QfWd';
|
con4.AccountId = accDep.Id;
|
// con4.State__c = '北京市';
|
con5 = new Contact();
|
con5.Firstname = 'ZZ5';
|
con5.LastName = '取引先責任者5';
|
con5.RecordTypeId = '01210000000QfWd';
|
con5.AccountId = accDep.Id;
|
// con5.State__c = '北京市';
|
conList.add(con1);
|
conList.add(con2);
|
conList.add(con3);
|
conList.add(con4);
|
conList.add(con5);
|
insert conList;
|
List<Opportunity> oppList = new List<Opportunity>();
|
opp1 = new Opportunity();
|
opp1.Name = '引合1';
|
opp1.AccountId = accDep.Id;
|
opp1.Opportunity_Category__c = 'ENT';
|
opp1.Trade__c = '外貿';
|
opp1.StageName = '引合';
|
opp1.CurrencyIsoCode = 'CNY';
|
opp1.Close_Forecasted_Date__c = date.today().addMonths(1);
|
opp1.CloseDate = date.today().addMonths(1);
|
opp1.Opportunity_stage__c = '确定了对手参数';
|
opp1.Competitor__c = 'E';
|
opp1.Sales_Root__c = 'OCM直接販売';
|
opp1.Hospital__c = accHP.id;
|
opp1.Department_Class__c = accDepClass.id;
|
opp1.StageName = '引合';
|
opp2 = new Opportunity();
|
opp2.Name = '引合2';
|
opp2.AccountId = accDep.Id;
|
opp2.Opportunity_Category__c = 'ENT';
|
opp2.Trade__c = '外貿';
|
opp2.StageName = '引合';
|
opp2.Opportunity_stage__c = '确定了对手参数';
|
opp2.CurrencyIsoCode = 'CNY';
|
opp2.Close_Forecasted_Date__c = date.today().addMonths(1);
|
opp2.CloseDate = date.today().addMonths(1);
|
opp2.Competitor__c = 'E';
|
opp2.Sales_Root__c = 'OCM直接販売';
|
opp2.Hospital__c = accHP.id;
|
opp2.Department_Class__c = accDepClass.id;
|
opp2.StageName = '引合';
|
opp3 = new Opportunity();
|
opp3.Name = '引合3';
|
opp3.AccountId = accDep.Id;
|
opp3.Opportunity_Category__c = 'ENT';
|
opp3.Trade__c = '外貿';
|
opp3.StageName = '引合';
|
opp3.Opportunity_stage__c = '确定了对手参数';
|
opp3.CurrencyIsoCode = 'CNY';
|
opp3.Close_Forecasted_Date__c = date.today().addMonths(1);
|
opp3.CloseDate = date.today().addMonths(1);
|
opp3.Competitor__c = 'E';
|
opp3.Sales_Root__c = 'OCM直接販売';
|
opp3.Hospital__c = accHP.id;
|
opp3.Department_Class__c = accDepClass.id;
|
opp3.StageName = '引合';
|
opp4 = new Opportunity();
|
opp4.Name = '引合4';
|
opp4.AccountId = accDep.Id;
|
opp4.Opportunity_Category__c = 'ENT';
|
opp4.Trade__c = '外貿';
|
opp4.StageName = '引合';
|
opp4.CurrencyIsoCode = 'CNY';
|
opp4.Opportunity_stage__c = '确定了对手参数';
|
opp4.Close_Forecasted_Date__c = date.today().addMonths(1);
|
opp4.CloseDate = date.today().addMonths(1);
|
opp4.Competitor__c = 'E';
|
opp4.Sales_Root__c = 'OCM直接販売';
|
opp4.Hospital__c = accHP.id;
|
opp4.Department_Class__c = accDepClass.id;
|
opp4.StageName = '引合';
|
opp5 = new Opportunity();
|
opp5.Name = '引合5';
|
opp5.AccountId = accDep.Id;
|
opp5.Opportunity_Category__c = 'ENT';
|
opp5.Trade__c = '外貿';
|
opp5.StageName = '引合';
|
opp5.CurrencyIsoCode = 'CNY';
|
opp5.Close_Forecasted_Date__c = date.today().addMonths(1);
|
opp5.CloseDate = date.today().addMonths(1);
|
opp5.Competitor__c = 'E';
|
opp5.Sales_Root__c = 'OCM直接販売';
|
opp5.Opportunity_stage__c = '确定了对手参数';
|
opp5.Hospital__c = accHP.id;
|
opp5.Department_Class__c = accDepClass.id;
|
opp5.StageName = '引合';
|
oppList.add(opp1);
|
oppList.add(opp2);
|
oppList.add(opp3);
|
oppList.add(opp4);
|
oppList.add(opp5);
|
insert oppList;
|
System.debug('opp1.Name:' + opp1.Name);
|
|
accompanying_report__c ar = new accompanying_report__c();
|
ar.Name = '管理者';
|
ar.Profile_ID_1__c = pid;
|
//Database.insert(ar, false);
|
insert ar;
|
|
report_report__c rr = new report_report__c();
|
rr.Name = '管理者';
|
rr.Profile_ID_1__c = pid;
|
//Database.insert(rr, false);
|
insert rr;
|
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.today();
|
dr.Reporter__c = u1.id;
|
dr.OwnerId = u1.Id;
|
insert dr;
|
Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today());
|
insert ec;
|
List<Maintenance_Contract__c> mcList = new List<Maintenance_Contract__c>();
|
mc1 = new Maintenance_Contract__c();
|
mc1.Name = 'サービス契約1';
|
mc1.Status__c = '引合中';
|
mc1.Hospital__c = accHP.id;
|
mc1.Department_Class__c = accDepClass.id;
|
mc1.Department__c = accDep.Id;
|
mc1.CurrencyIsoCode = 'CNY';
|
insert mc1;
|
mc2 = new Maintenance_Contract__c();
|
mc2.Name = 'サービス契約2';
|
mc2.Status__c = '引合中';
|
mc2.Hospital__c = accHP.id;
|
mc2.Department_Class__c = accDepClass.id;
|
mc2.Department__c = accDep.Id;
|
mc2.CurrencyIsoCode = 'CNY';
|
insert mc2;
|
}
|
}
|
@isTest
|
static void test01_08_01() {
|
User user = [select Id from User where Username = 'olympusTest10@sunbridge.com'];
|
System.runAs(user) {
|
Add_ReportTest.settTestData();
|
XinDailyReportController t = new XinDailyReportController();
|
t.init();
|
|
t.report_search.Reported_Date__c = date.today();
|
PageReference ref = t.getDailyReport();
|
Test.setCurrentPage(ref);
|
Test.startTest();
|
t = new XinDailyReportController();
|
|
t.init();
|
// t.getEvent();
|
// t.report.Reporter__c = u1.id;
|
|
// t.report.Reported_Date__c = date.today();
|
// t.repoStartHourText = '9';
|
// t.repoStartMinuteText = '00';
|
// t.repoEndHourText = '18';
|
// t.repoEndMinuteText = '00';
|
// t.report.Status__c = null;
|
// t.activities.get(0).actStartHourText = '9';
|
// t.activities.get(0).actStartMinuteText = '00';
|
// t.activities.get(0).actEndHourText = '18';
|
// t.activities.get(0).actEndMinuteText = '00';
|
// t.activities.get(0).act.nextPlanDate__c = date.today();
|
// t.activities.get(0).act.Activity_Type2__c = '病院';
|
// t.activities.get(0).act.Location__c = '戦略科室分類1 診療科1test';
|
// t.activities.get(0).act.Purpose__c = '目的(計画)';
|
// t.activities.get(0).act.Description__c = '結果';
|
// t.activities.get(0).act.Purpose_Type__c = '礼节性拜访';
|
// t.activities.get(0).act.Visitor1__c = '取引先責任者1';
|
// t.activities.get(0).act.Visitor1_ID__c = null;
|
// t.activities.get(0).act.Visitor2__c = '取引先責任者2';
|
// t.activities.get(0).act.Visitor2_ID__c = null;
|
// t.activities.get(0).act.Visitor3__c = '取引先責任者3';
|
// t.activities.get(0).act.Visitor3_ID__c = null;
|
// t.activities.get(0).act.Visitor4__c = '取引先責任者4';
|
// t.activities.get(0).act.Visitor4_ID__c = null;
|
// t.activities.get(0).act.Visitor5__c = '取引先責任者5';
|
// t.activities.get(0).act.Visitor5_ID__c = null;
|
// t.activities.get(0).act.Related_Opportunity1__c = opp1.Name + 'test';
|
// t.activities.get(0).act.Related_Opportunity2__c = opp2.Name + 'test';
|
// t.activities.get(0).act.Related_Opportunity3__c = opp3.Name + 'test';
|
// t.activities.get(0).act.Related_Opportunity4__c = opp4.Name + 'test';
|
// t.activities.get(0).act.Related_Opportunity5__c = opp5.Name + 'test';
|
// t.activities.get(0).act.Related_Service1__c = mc1.Name + 'test';
|
// t.activities.get(0).act.Related_Service2__c = mc2.Name + 'test';
|
// t.activities.get(0).planStartHourText = '9';
|
// t.activities.get(0).planStartMinuteText = '00';
|
// t.activities.get(0).planEndHourText = '18';
|
// t.activities.get(0).planEndMinuteText = '00';
|
// t.activities.get(0).planPurposeText = '次の活動予定目的(計画)';
|
|
// t.save();
|
|
t.activities.get(0).act.Location__c = accDepName;
|
t.activities.get(0).act.whatid__c = accDep.Id;
|
t.activities.get(0).act.Visitor1__c = '取引先責任者1';
|
t.activities.get(0).act.Visitor1_ID__c = con1.id;
|
t.activities.get(0).act.Visitor2__c = '取引先責任者2';
|
t.activities.get(0).act.Visitor2_ID__c = con2.id;
|
t.activities.get(0).act.Visitor3__c = '取引先責任者3';
|
t.activities.get(0).act.Visitor3_ID__c = con3.id;
|
t.activities.get(0).act.Visitor4__c = '取引先責任者4';
|
t.activities.get(0).act.Visitor4_ID__c = con4.id;
|
t.activities.get(0).act.Visitor5__c = '取引先責任者5';
|
t.activities.get(0).act.Visitor5_ID__c = con5.id;
|
t.activities.get(0).act.Related_Opportunity1__c = '::引合1';
|
t.activities.get(0).act.Related_Opportunity2__c = '::引合2';
|
t.activities.get(0).act.Related_Opportunity3__c = '::引合3';
|
t.activities.get(0).act.Related_Opportunity4__c = '::引合4';
|
t.activities.get(0).act.Related_Opportunity5__c = '::引合5';
|
t.activities.get(0).act.Related_Opportunity1_ID__c = opp1.Id;
|
t.activities.get(0).act.Related_Opportunity2_ID__c = opp2.Id;
|
t.activities.get(0).act.Related_Opportunity3_ID__c = opp3.Id;
|
t.activities.get(0).act.Related_Opportunity4_ID__c = opp4.Id;
|
t.activities.get(0).act.Related_Opportunity5_ID__c = opp5.Id;
|
t.activities.get(0).act.Related_Service1__c = mc1.Name;
|
t.activities.get(0).act.Related_Service2__c = mc2.Name;
|
t.activities.get(0).act.Related_Service1_ID__c = mc1.Id;
|
t.activities.get(0).act.Related_Service2_ID__c = mc2.Id;
|
t.upsertActIndex = '0';
|
t.save();
|
|
Date d = date.today();
|
String strDate = d.year() + '/' + d.month() + '/' + d.day();
|
|
Datetime dt = datetime.now();
|
String strDatetime = '2000/01/01 10:10:00';
|
System.debug('strDatetime' + strDatetime);
|
Event__c ec = [select Id from Event__c limit 1];
|
System.debug('t.activities.get(0).act.id:::::' + t.activities.get(0).act.id);
|
String opId = Add_Report.addReportOP(u1.id, t.report.id, t.report.id, t.activities.get(0).act.id, 'OPD', '戦略科室分類1 診療科1test', con1.id, con2.id, con3.id, con4.id, con5.id, opp1.Id, opp2.Id, opp3.Id, opp4.Id, opp5.Id, strDate);
|
Add_Report.addReportPr(u1.id, t.report.id, t.report.id, ec.id, 'OPD', '戦略科室分類1 診療科1test', con1.id, con2.id, con3.id, con4.id, con5.id,'', strDate);
|
Add_Report.addReportNT(u1.id, t.report.id, t.report.id, ec.id, 'OPD', '戦略科室分類1 診療科1test', con1.id, con2.id, con3.id, con4.id, con5.id,'','', strDate);
|
Add_Report.addReportOn(u1.id, t.report.id, t.report.id, ec.id, 'On_Call', '戦略科室分類1 診療科1test', strDate,'','1','1','2','1','');
|
Add_Report.addReportAc(u1.id, t.report.id, t.report.id, ec.id, 'Visit_Report__c', '戦略科室分類1 診療科1test', strDate,'');
|
|
Report__c re = [select Id from Report__c limit 1];
|
re.Manual_Name__c = '123';
|
update re;
|
Add_Report.addClaim(u1.id,re.id, t.report.id,ec.id, 'QIS_Report__c', '戦略科室分類1 診療科1test', strDate,'');
|
Daily_Report__c dr = [select Id from Daily_Report__c limit 1];
|
Add_Report.addReportEx(u1.id, '', re.id, ec.id, 'OPD', '戦略科室分類1 診療科1test', con1.id, strDate,'');
|
Add_Report.addReportIm(u1.id, '', dr.id, ec.id, 'OPD', '戦略科室分類1 診療科1test', strDate,'');
|
Add_Report.addReportEx(u1.id, re.id, re.id, ec.id, 'OPD', '戦略科室分類1 診療科1test', con1.id, strDate,'');
|
Add_Report.addReportIm(u1.id, re.id, dr.id, ec.id, 'OPD', '戦略科室分類1 診療科1test', strDate,'');
|
Add_Report.addRA(u1.id, re.id, dr.id, ec.id, 'Rental_Apply', '戦略科室分類1 診療科1test', strDate,'','');
|
// Add_Report.getProduct2(dr.Id);
|
// Add_Report.getProduct2US(dr.Id);
|
// Add_Report.getReportId(dr.Id,'2023-07-01');
|
// Add_Report.checkAccountMatch('123',dr.Id);
|
// Add_Report.getAccountForJs(dr.Id);
|
if (opId != 'false') t.activities.get(0).act.OPD_ID__c = opId;
|
t.save();
|
Test.stopTest();
|
}
|
}
|
|
public static void settTestData(){
|
Account account = [select Id,Name from Account where Department_Name__c = '診療科1'];
|
List<Contact> conList = [select Id from Contact];
|
List<Opportunity> opplist = [select Id,Name from Opportunity];
|
List<Maintenance_Contract__c> mcList = [select Id,Name from Maintenance_Contract__c];
|
Daily_Report__c report = [select Id from Daily_Report__c limit 1];
|
User user = [select Id from User where Username = 'olympusTest10@sunbridge.com'];
|
accDep = account;
|
accDepId = account.Id;
|
accDepName = account.Name;
|
con1 = conList[0];
|
con2 = conList[1];
|
con3 = conList[2];
|
con4 = conList[3];
|
con5 = conList[4];
|
opp1 = oppList[0];
|
opp2 = oppList[1];
|
opp3 = oppList[2];
|
opp4 = oppList[3];
|
opp5 = oppList[4];
|
mc1 = mcList[0];
|
mc2 = mcList[1];
|
u1 = user;
|
|
}
|
|
}
|