From 2f4492ee18f90274582fcc2bb06f5e9bf64136e8 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 13 五月 2022 17:32:14 +0800
Subject: [PATCH] ProdBackup0513

---
 force-app/main/default/classes/AWSServiceToolTest.cls |   71 ++++++++++++++++++++++++++++++-----
 1 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/force-app/main/default/classes/AWSServiceToolTest.cls b/force-app/main/default/classes/AWSServiceToolTest.cls
index 8bb1fdb..10d8720 100644
--- a/force-app/main/default/classes/AWSServiceToolTest.cls
+++ b/force-app/main/default/classes/AWSServiceToolTest.cls
@@ -1,6 +1,6 @@
 @isTest
 private class AWSServiceToolTest {
-    /*static testMethod void testMethod1() {
+    static testMethod void testMethod1() {
     	TestDataUtility.CreatePIPolicyConfiguration();
     	Account acc = TestDataUtility.CreateAccounts(1)[0];
     	Map<String,Object> accMap = new Map<String,Object>();
@@ -12,7 +12,8 @@
         PIHelper.getPIIntegrationInfo('Document');
 
         Test.startTest();
-        // AWSServiceTool.getAWSToken();
+        AWSServiceTool.getAWSServiceStatus();
+        AWSServiceTool.getAWSToken();
 
         Set<String> dataids = new Set<String>();
         String data = '12345678';
@@ -21,8 +22,8 @@
 
         AWSServiceTool.deleteFileAddress(dataids);
         Test.stopTest();
-    }*/
-    static testMethod void testMethod2() {
+    }
+    /*static testMethod void testMethod2() {
         // TestDataUtility.CreatePIPolicyConfiguration();
         Account acc = TestDataUtility.CreateAccounts(1)[0];
         Map<String,Object> accMap = new Map<String,Object>();
@@ -33,11 +34,61 @@
         Test.startTest();
         AWSServiceTool.getAWSToken();
         Test.stopTest();
-    }
-    /*static testMethod void testMethod3() {
-        Test.startTest();
-        AWSServiceTool.getNoPIContact('Test','');
-        AWSServiceTool.getNoPIContact('','0010l00001PQFkhAAH');
-        Test.stopTest();
     }*/
+    static testMethod void testMethod3() {
+    	String searchContactName = 'test';
+        String accountId = '0010l00001PQFkhAAH';
+      
+        Test.startTest();
+        AWSServiceTool.getNoPIContact(searchContactName,accountId);
+        Test.stopTest();
+    }
+    @isTest
+    static void Test4(){
+        Test.setMock(HttpCalloutMock.class, new HttpMock());
+
+
+        Test.startTest();
+        AWSServiceTool.sendToPiAWS('String rowDataStr', 'String endpoint','String awsToken');
+        Test.stopTest();
+    }
+    class HttpMock implements HttpCalloutMock{
+        
+        string rid  = '';
+        public HttpMock(){
+        }
+        public HttpMock(string rid){
+            this.rid = rid;
+        }
+        public HTTPResponse respond(HTTPRequest request) {
+        // 鍒涘缓涓�涓亣鐨勫洖搴�
+        System.debug('------------------------------------------------------');
+        HttpResponse response = new HttpResponse();
+        string body = '';
+        system.debug(request.getEndpoint());
+        string url = request.getEndpoint();
+            
+        if(url.contains('token')){
+            system.debug('url=token');
+            response.setHeader('Content-Type', 'application/json');
+			body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }';        	
+        } else if(url.toLowerCase().contains('insert')){
+            system.debug('url=Insert');
+            response.setHeader('Content-Type', 'application/json');
+			body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "'+rid+'" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';        	
+        } else if(url.toLowerCase().contains('update')){
+            system.debug('url=update');
+            response.setHeader('Content-Type', 'application/json');
+			body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "'+rid+'" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';        	
+        } else{
+        	
+        }
+        
+        response.setBody(body);
+        response.setStatus('OK');
+        response.setStatusCode(200);
+        return response;
+        // }
+    }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1