From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新
---
force-app/main/default/classes/InquiryFormHandlerTest.cls | 154 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 133 insertions(+), 21 deletions(-)
diff --git a/force-app/main/default/classes/InquiryFormHandlerTest.cls b/force-app/main/default/classes/InquiryFormHandlerTest.cls
index 9f50f52..934397f 100644
--- a/force-app/main/default/classes/InquiryFormHandlerTest.cls
+++ b/force-app/main/default/classes/InquiryFormHandlerTest.cls
@@ -1,13 +1,115 @@
@isTest
private class InquiryFormHandlerTest {
- @isTest static void test_method_one() {
+ static testMethod void updaue() {
+ InquiryFormHandler.test();//鍏堣皟鐢ㄨ繖涓紝鐒跺悗缁х画琛ュ厖娴嬭瘯绫�
+ }
+ @TestSetup
+ static void setup(){
+ TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Agency_Contact__c','Contact'});
+ }
+
+ @isTest
+ static void Test1(){
+ Test.setMock(HttpCalloutMock.class, new HttpMock());
- Inquiry_form__c inquiryform = new Inquiry_form__c();
- inquiryform.Name = '2019102101';
- inquiryform.Request1__c = '闇�瑕佹姤浠�';
- inquiryform.Product1__c = '瓒呭0';
- insert inquiryform;
+ List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
+ lra.add(new Agency_Contact__c(
+ ));
+ insert lra;
+ Test.startTest();
+ //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
+ AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
+ AWSServiceTool2.EncryptPushFuture(null,null);
+ Test.stopTest();
+ }
+
+ @isTest
+ static void Test2(){
+ Test.setMock(HttpCalloutMock.class, new HttpMock());
+
+ List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
+ lra.add(new Agency_Contact__c(
+ Aws_Data_Id__c = '123456'
+ ));
+ insert lra;
+ Test.startTest();
+ //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
+ AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
+ Test.stopTest();
+ }
+
+ @isTest
+ static void Test3(){
+ Test.setMock(HttpCalloutMock.class, new HttpMock());
+
+
+ Test.startTest();
+ AWSServiceTool2.EncryptPushData(new string[]{'0031000000O4Cff'});
+
+ Test.stopTest();
+ }
+
+ //@isTest
+ // static void Test2(){
+ // 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'
+ // ));
+ // Test.startTest();
+ // //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
+ // AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
+ // 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;
+ User thisUser = [select Id from User where Id = :UserInfo.getUserId() ];
+ System.runAs ( thisUser ){
+ Inquiry_form__c inquiryform = new Inquiry_form__c();
+ inquiryform.Name = '2019102101';
+ inquiryform.Request1__c = '闇�瑕佹姤浠�';
+ inquiryform.Product1__c = '瓒呭0';
+ inquiryform.FSE_Owner__c = thisUser.id;
+ insert inquiryform;
+ }
}
// @isTest static void test_method_two() {
@@ -95,16 +197,16 @@
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;
- User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- insert hpOwner2;
+ //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;
+ //User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ //insert hpOwner2;
-
-
- Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
- hp.FSE_GI_Main_Leader__c = hpOwner.Id;
- hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
+ User thisUser = [select Id from User where Id = :UserInfo.getUserId() ];
+ System.runAs ( thisUser ){
+ Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = thisUser.Id);
+ hp.FSE_GI_Main_Leader__c = thisUser.Id;
+ hp.FSE_SP_Main_Leader__c = thisUser.Id;
insert hp;
//鎴樼暐绉戝
@@ -126,11 +228,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,14 +245,24 @@
inquiryform.Phone__c = '13844756322';
inquiryform.Product1__c = '瓒呭0';
inquiryform.Request1__c = '闇�瑕佹姤浠�';
+ inquiryform.FSE_Owner__c = thisUser.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){
update inquiryform0;
//}
-
+ }
}
// static testMethod void testBeforeUpdate() {
// //鍖婚櫌
--
Gitblit v1.9.1