@isTest
|
private class NFM704RestTest {
|
@testSetup
|
static void test_method_one(){
|
|
List < RecordType > rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account'
|
and Name = '病院'
|
];
|
if (rectCo.size() == 0) {
|
throw new ControllerUtil.myException('not found 病院 recodetype');
|
}
|
List < RecordType > rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account'
|
and Name = '戦略科室分類 消化科'
|
];
|
if (rectSct.size() == 0) {
|
throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype');
|
}
|
List < RecordType > rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account'
|
and Name = '診療科 消化科'
|
];
|
if (rectDpt.size() == 0) {
|
throw new ControllerUtil.myException('not found 診療科 消化科 recodetype');
|
}
|
// テストデータ
|
Account company = new Account();
|
company.RecordTypeId = rectCo[0].Id;
|
company.Is_Active__c = '有効';
|
company.Name = 'NFM105TestCompany';
|
company.AwaitToSendAWS__c = true;
|
upsert company;
|
|
Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId =: company.Id and RecordTypeId =: rectSct[0].Id];
|
|
Account depart = new Account();
|
depart.RecordTypeId = rectDpt[0].Id;
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM105TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
depart.AgentCode_Ext__c = 'Test202201';
|
upsert depart;
|
|
}
|
|
@isTest static void test_method_two(){
|
|
RestRequest req = new RestRequest();
|
RestResponse res = new RestResponse();
|
|
String JsonMsg = '{"Monitoring":{"TransmissionDateTime":"202112311320","Text":"","Tag":"","Sender":"OBPM","Receiver":"SFDC","NumberOfRecord":"1","MessageType":"NFM704","MessageGroupNumber":""},"GeData":[{"StaffMCode": "C000019313","HospitalMCode": "010","OfficeMCode": "Test202201", "HcpNo": "111", "HCPLevel": "2", "Name": "刘刚", "Mobile": "13809233181"}]}';
|
req.requestURI = 'services/apexrest/NFM704/execute';
|
req.httpMethod = 'POST';
|
req.requestBody = Blob.valueOf(JsonMsg);
|
|
RestContext.request = req;
|
RestContext.response = res;
|
|
NFM704Rest.doPost();
|
}
|
}
|