@isTest
|
public with sharing class NFM209RestTest {
|
static testMethod void testMethod1() {
|
// テストデータ
|
List<BatchIF_Transfer__c> transfers = new List<BatchIF_Transfer__c>();
|
BatchIF_Transfer__c transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'TradeComplianceStatus__c';
|
transfer.External_Value__c = 'W';
|
transfer.Internal_Value__c = '白名单';
|
transfers.add(transfer);
|
transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'TradeComplianceStatus__c';
|
transfer.External_Value__c = 'B';
|
transfer.Internal_Value__c = '黑名单';
|
transfers.add(transfer);
|
insert transfers;
|
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
company.Name = 'NFM209TestCompany';
|
upsert company;
|
Account section = new Account();
|
section.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_GI').getRecordTypeId();
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
upsert section;
|
|
StaticParameter.EscapeSyncProduct2Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
Account depart = new Account();
|
depart.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId();
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM209TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
upsert depart;
|
|
company = [select Id, Name,Management_Code_Auto__c from Account
|
where Id = :company.Id];
|
NFM209Rest.GeDatas GeDatas = new NFM209Rest.GeDatas();
|
NFM209Rest.GeData GeData = new NFM209Rest.GeData();
|
GeDatas.GeData = new NFM209Rest.GeData[]{GeData};
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
|
|
|
GeData.custCode = company.Management_Code_Auto__c;
|
GeData.complStatus = 'B';
|
GeData.orgSysId='123';
|
GeData.glbBusiNo='123';
|
GeData.custTp='123';
|
GeData.entityTp='123';
|
GeData.custName='123';
|
//System.Test.startTest();
|
NFMUtil.Monitoring Monitoring = GeDatas.Monitoring;
|
BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'NFM209', GeDatas.GeData);
|
NFM209Rest.executefuture(rowData.Id);
|
|
rowData = NFMUtil.saveRowData(Monitoring, 'NFM209', GeDatas.GeData);
|
NFM209Rest.executefuture(rowData.Id);
|
}
|
static testMethod void testMethod2() {
|
//Test.startTest();
|
|
RestRequest req = new RestRequest();
|
RestResponse res = new RestResponse();
|
|
String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"201812201320","Text":"","Tag":"MSGH","Sender":"SAP","Receiver":"SFDC","NumberOfRecord":"1","MessageType":"NFM117","MessageGroupNumber":"20210000005088"},"GeData":[{"custCode":"8098008","complStatus":"黑名单","orgSysId":"00987","glbBusiNo":"001","custTp":"Person","entityTp":"经销商","custName":"大连东控睿康医疗管理有限公司"}]}';
|
req.requestURI = 'services/apexrest/NFM209/execute';
|
req.httpMethod = 'POST';
|
req.requestBody = Blob.valueof(JsonMsg);
|
RestContext.request = req;
|
RestContext.response= res;
|
|
NFM209Rest.execute();
|
|
//Test.stopTest();
|
}
|
}
|