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 |   94 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 70 insertions(+), 24 deletions(-)

diff --git a/force-app/main/default/classes/InquiryFormHandlerTest.cls b/force-app/main/default/classes/InquiryFormHandlerTest.cls
index 7863d8d..934397f 100644
--- a/force-app/main/default/classes/InquiryFormHandlerTest.cls
+++ b/force-app/main/default/classes/InquiryFormHandlerTest.cls
@@ -1,8 +1,12 @@
 @isTest
 private class InquiryFormHandlerTest {
-   @TestSetup
+
+   static testMethod void updaue() {
+        InquiryFormHandler.test();//鍏堣皟鐢ㄨ繖涓紝鐒跺悗缁х画琛ュ厖娴嬭瘯绫�
+   }
+  @TestSetup
     static void setup(){
-        TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
+        TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Agency_Contact__c','Contact'});
     } 
     
   @isTest
@@ -11,14 +15,55 @@
 
         List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
         lra.add(new Agency_Contact__c(
-            Id = 'a2R1m0000007BPD'
         ));
+        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{
         
@@ -51,19 +96,20 @@
         // }
     }
     }
-
     @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;
+        //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() {
@@ -151,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;
 
         //鎴樼暐绉戝
@@ -199,7 +245,7 @@
         inquiryform.Phone__c = '13844756322';
         inquiryform.Product1__c = '瓒呭0';
         inquiryform.Request1__c = '闇�瑕佹姤浠�';
-        inquiryform.FSE_Owner__c  = hpOwner.id;
+        inquiryform.FSE_Owner__c  = thisUser.id;
         insert inquiryform;
 
          Test.setMock(HttpCalloutMock.class, new HttpMock());
@@ -216,7 +262,7 @@
         //System.runAs (inquiryform){
             update inquiryform0;
         //}
-
+        }
     }
   //    static testMethod void testBeforeUpdate() {
   //      //鍖婚櫌

--
Gitblit v1.9.1