liuyan
2022-11-24 8badb57ea2c82557850ad5b39281c3e8714eb119
force-app/main/default/classes/NFM624RestAboutTest.cls
@@ -21,9 +21,26 @@
        Account hptemp = [select Id,PlatformCode__c,AgentCode_Ext__c,Is_Active_Formula__c from Account where Id = :hp.Id];
        
        //战略科室
        Account dc = [select Id, Name,Parent_PlatformCode__c,Parent_Management_Code__c, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_BF'];
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hp.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 = hp.Id;
        insert dep;
        //联系人
        Contact contact2 = new Contact();
        contact2.AccountId = dep.Id;
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        contact2.LastName_Encrypted__c ='24616254c7c7b65d985567f475b667d7';
        insert contact2;
        NFM624Rest.GeData GeData1 = new NFM624Rest.GeData();
        NFM624Rest.GeDatas GaDatas = new  NFM624Rest.GeDatas();
@@ -99,4 +116,22 @@
            NFM624RestAbout.executefuture(rowData3.Id);
        }
    }
    static testMethod void test_method_execute(){
        Test.startTest();
        RestRequest req = new RestRequest();
        RestResponse res = new RestResponse();
        String JsonMsg = '{"Monitoring":{"Tag":"MSGH","Sender":"SPO","Receiver":"SFDC","MessageType":"NFM624About","MessageGroupNumber":"20210000004695","NumberOfRecord":"4","TransmissionDateTime":"2022-05-19","Text":""},"GeData":[{"PersonManagementCode":"thhTest","HospitalManagementCode2":"thhTest","DepartmentManagementCode2":"thhTest","NameEncrypted":"thhTest","RelatedHospital":"thhTest","DepartmentClass":"thhTest","DepartmentName":"thhTest","RelatedDepartment":"thhTest","dataId":"thh121231345","AccountName":"thhTest","MobileEncrypted":"11223344"}]}';
        req.requestURI = 'services/apexrest/NFM624RestAbout/execute';
        req.httpMethod = 'POST';
        req.requestBody = Blob.valueof(JsonMsg);
        RestContext.request = req;
        RestContext.response= res;
        NFM624RestAbout.execute();
        Test.stopTest();
    }
}