From 64b3629116e6f3f5eb3debf9b451d100f4010fa5 Mon Sep 17 00:00:00 2001 From: 游畅 <youchang@prec-tech.com> Date: 星期五, 22 四月 2022 13:50:56 +0800 Subject: [PATCH] 询问单相关修改 --- force-app/main/default/classes/InquiryFormHandlerTest.cls | 76 +++++++++++++++++++++++++++++++++++-- 1 files changed, 71 insertions(+), 5 deletions(-) diff --git a/force-app/main/default/classes/InquiryFormHandlerTest.cls b/force-app/main/default/classes/InquiryFormHandlerTest.cls index 9f50f52..7863d8d 100644 --- a/force-app/main/default/classes/InquiryFormHandlerTest.cls +++ b/force-app/main/default/classes/InquiryFormHandlerTest.cls @@ -1,12 +1,68 @@ @isTest private class InquiryFormHandlerTest { + @TestSetup + static void setup(){ + TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); + } + + @isTest + static void Test1(){ + Test.setMock(HttpCalloutMock.class, new HttpMock()); + + List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + lra.add(new Agency_Contact__c( + Id = 'a2R1m0000007BPD' + )); + Test.startTest(); + //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl); + AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); + AWSServiceTool2.EncryptPushFuture(null,null); + Test.stopTest(); + } + + class HttpMock implements HttpCalloutMock{ + + public HTTPResponse respond(HTTPRequest request) { + // 鍒涘缓涓�涓亣鐨勫洖搴� + System.debug('------------------------------------------------------'); + HttpResponse response = new HttpResponse(); + string body = ''; + system.debug(request.getEndpoint()); + if(request.getEndpoint().contains('token')){ + system.debug('url=token'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else if(request.getEndpoint().contains('insert')){ + system.debug('url=Insert'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else if(request.getEndpoint().contains('update')){ + system.debug('url=update'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else{ + + } + + response.setBody(body); + response.setStatus('OK'); + response.setStatusCode(200); + return response; + // } + } + } @isTest static void test_method_one() { + Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; + + User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); + insert hpOwner; Inquiry_form__c inquiryform = new Inquiry_form__c(); inquiryform.Name = '2019102101'; inquiryform.Request1__c = '闇�瑕佹姤浠�'; inquiryform.Product1__c = '瓒呭0'; + inquiryform.FSE_Owner__c = hpOwner.id; insert inquiryform; } @@ -126,11 +182,11 @@ dpt1.Hospital__c = hp.Id; insert dpt1; - Contact contact2 = new Contact(); - contact2.AccountId = dpt1.Id; - contact2.FirstName = '璨换鑰�'; - contact2.LastName = 'test1缁忛攢鍟�'; - insert contact2; + //Contact contact2 = new Contact(); + //contact2.AccountId = dpt1.Id; + //contact2.FirstName = '璨换鑰�'; + //contact2.LastName = 'test1缁忛攢鍟�'; + //insert contact2; Inquiry_form__c inquiryform = new Inquiry_form__c(); inquiryform.Name = '2019102101'; @@ -143,8 +199,18 @@ inquiryform.Phone__c = '13844756322'; inquiryform.Product1__c = '瓒呭0'; inquiryform.Request1__c = '闇�瑕佹姤浠�'; + inquiryform.FSE_Owner__c = hpOwner.id; insert inquiryform; + Test.setMock(HttpCalloutMock.class, new HttpMock()); + + List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + lra.add(new Agency_Contact__c( + Id = 'a2R1m0000007BPD', + Aws_Data_Id__c = '123456' + )); + AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); + Inquiry_form__c inquiryform0 = new Inquiry_form__c(Id = inquiryform.id); inquiryform0.Hospital_Name__c = null; //System.runAs (inquiryform){ -- Gitblit v1.9.1