@isTest
|
private class NFM620RestTest {
|
|
@isTest static void test_method_one() {
|
|
// 省
|
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;
|
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
hospital.Is_Active__c = '有効';
|
hospital.Attribute_Type__c = '卫生部';
|
hospital.Speciality_Type__c = '综合医院';
|
hospital.Grade__c = '一级';
|
hospital.OCM_Category__c = 'SLTV';
|
hospital.Is_Medical__c = '医疗机构';
|
hospital.State_Master__c = al.id;
|
hospital.City_Master__c = al2.id;
|
hospital.Town__c = '东京';
|
insert hospital;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
//useを得る
|
Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
User 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 = p.id;
|
u1.Job_Category__c = '销售服务';
|
u1.Province__c = '北京';
|
insert u1;
|
|
Contact contact2 = new Contact();
|
contact2.UnifiedI_Contact_ID__c = 'test001';
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '张';
|
contact2.LastName = '小花';
|
insert contact2;
|
|
List<Id> recordTypeIds = new List<Id>();
|
recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId()); //学会/会议
|
|
Campaign campaign01 = new Campaign();
|
campaign01.RecordTypeId = recordTypeIds.get(0);
|
// campaign01.StartDate = Date.newInstance(2020,10,29);
|
campaign01.StartDate = Date.today();
|
campaign01.Name = 'mzyTest01';
|
campaign01.EndDate = Date.today().addDays(1);
|
campaign01.Status = '公开中';
|
campaign01.Is_LendProduct__c = '是';
|
campaign01.Internal_in_charge_province__c = al.id; //备品出借省
|
campaign01.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期
|
campaign01.LoadNum__c = '3D主机*2; BF-290镜子*4; CV-170*1; CV-190*6;'; //计划出借备品信息
|
campaign01.HostName__c = '主办方';
|
campaign01.cooperatorCompany__c = '1';
|
insert campaign01;
|
Campaign c =[select Id, Num__c, Name2__c from Campaign limit 1];
|
|
NFM620Rest.GeDatas GeDatas = new NFM620Rest.GeDatas();
|
NFM620Rest.GeData GeData = new NFM620Rest.GeData();
|
GeDatas.GeData = new NFM620Rest.GeData[]{GeData};
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
|
|
GeData.InquiryNo = 'SH-SP-JS0679111';
|
GeData.Name = '商品询问单000';
|
GeData.ContactId = contact2.UnifiedI_Contact_ID__c;
|
GeData.ContactWay = 'SFDC_Wangqingli@olympus.com.cn';
|
GeData.Campaign = c.Num__c;
|
GeData.Product = '内窥镜;超声;治疗附件';
|
GeData.Request = '产品试用';
|
GeData.RequestDetail = '委托事项详情AAAAAAAAAAAAAA';
|
// GeData.ApproverID = u1.Employee_No__c;
|
|
|
//System.Test.startTest();
|
NFMUtil.Monitoring Monitoring = GeDatas.Monitoring;
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'NFM620', GeDatas.GeData);
|
NFM620Rest.executefuture(rowData.Id);
|
|
rowData = NFMUtil.saveRowData(Monitoring, 'NFM620', GeDatas.GeData);
|
NFM620Rest.executefuture(rowData.Id);
|
|
//System.Test.stopTest();
|
|
}
|
@isTest static void test_method_two() {
|
//Test.startTest();
|
|
RestRequest req = new RestRequest();
|
RestResponse res = new RestResponse();
|
|
String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"201812201320","Text":"","Tag":"MSGH","Sender":"共通平台","Receiver":"SFDC","NumberOfRecord":"1","MessageType":"NFM620","MessageGroupNumber":"20210000005088"},"GeData":[{"RequestDetail":"委托事项详情","Request":"产品试用;产品说明","Product":"超声;内镜系统;胃镜;十二指肠镜","Name":"商品询问单l八","InquiryNo":"ONLINE008","ContactWay":"17638160959","ContactId":"test0055","Campaign":"MT-GI-201811-1758"}]}';
|
req.requestURI = 'services/apexrest/NFM620/execute';
|
req.httpMethod = 'POST';
|
req.requestBody = Blob.valueof(JsonMsg);
|
RestContext.request = req;
|
RestContext.response= res;
|
|
NFM620Rest.execute();
|
|
//Test.stopTest();
|
}
|
@isTest static void test_method_three() {
|
|
// 省
|
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;
|
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
hospital.Is_Active__c = '有効';
|
hospital.Attribute_Type__c = '卫生部';
|
hospital.Speciality_Type__c = '综合医院';
|
hospital.Grade__c = '一级';
|
hospital.OCM_Category__c = 'SLTV';
|
hospital.Is_Medical__c = '医疗机构';
|
hospital.State_Master__c = al.id;
|
hospital.City_Master__c = al2.id;
|
hospital.Town__c = '东京';
|
insert hospital;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
//useを得る
|
Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
User 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 = p.id;
|
u1.Job_Category__c = '销售服务';
|
u1.Province__c = '北京';
|
insert u1;
|
//OCSM管理省を得る
|
OCM_Management_Province__c mp1 = new OCM_Management_Province__c();
|
mp1.Name = '北京';
|
mp1.Province__c = '北京市';
|
mp1.Window1__c = u1.Id;
|
insert mp1;
|
|
Contact contact2 = new Contact();
|
contact2.UnifiedI_Contact_ID__c = 'test001';
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
|
List<BatchIF_Transfer__c> transfers = new List<BatchIF_Transfer__c>();
|
BatchIF_Transfer__c transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Inquiry_form__c';
|
transfer.Column__c = 'Request1__c';
|
transfer.External_Value__c = '产品试用';
|
transfer.Internal_Value__c = 'OPD';
|
transfers.add(transfer);
|
insert transfers;
|
|
List<Id> recordTypeIds = new List<Id>();
|
recordTypeIds.add(Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId()); //学会/会议
|
|
Campaign campaign01 = new Campaign();
|
campaign01.RecordTypeId = recordTypeIds.get(0);
|
// campaign01.StartDate = Date.newInstance(2020,10,29);
|
campaign01.StartDate = Date.today();
|
campaign01.Name = 'mzyTest02';
|
campaign01.EndDate = Date.today().addDays(1);
|
campaign01.Status = '公开中';
|
campaign01.Is_LendProduct__c = '是';
|
campaign01.Internal_in_charge_province__c = al.id; //备品出借省
|
campaign01.PlanBackData__c = Date.newInstance(2020,11,30); //计划撤展日期
|
campaign01.LoadNum__c = '3D主机*2; BF-290镜子*4; CV-170*1; CV-190*6;'; //计划出借备品信息
|
campaign01.HostName__c = '主办方';
|
campaign01.cooperatorCompany__c = '1';
|
insert campaign01;
|
|
NFM620Rest.GeDatas GeDatas = new NFM620Rest.GeDatas();
|
NFM620Rest.GeData GeData = new NFM620Rest.GeData();
|
GeDatas.GeData = new NFM620Rest.GeData[]{GeData};
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
|
|
GeData.InquiryNo = 'SH-SP-JS0679111';
|
GeData.Name = '商品询问单000';
|
GeData.ContactId = contact2.UnifiedI_Contact_ID__c;
|
GeData.ContactWay = 'SFDC_Wangqingli@olympus.com.cn';
|
GeData.Campaign = campaign01.Num__c;
|
GeData.Product = '内窥镜;超声;治疗附件';
|
GeData.Request = '产品试用';
|
GeData.RequestDetail = '委托事项详情AAAAAAAAAAAAAA';
|
|
|
//System.Test.startTest();
|
NFMUtil.Monitoring Monitoring = GeDatas.Monitoring;
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'NFM620', GeDatas.GeData);
|
NFM620Rest.executefuture(rowData.Id);
|
|
rowData = NFMUtil.saveRowData(Monitoring, 'NFM620', GeDatas.GeData);
|
NFM620Rest.executefuture(rowData.Id);
|
|
//System.Test.stopTest();
|
|
}
|
}
|