| | |
| | | @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>(); |
| | |
| | | PIHelper.getPIIntegrationInfo('Document'); |
| | | |
| | | Test.startTest(); |
| | | // AWSServiceTool.getAWSToken(); |
| | | AWSServiceTool.getAWSServiceStatus(); |
| | | AWSServiceTool.getAWSToken(); |
| | | |
| | | Set<String> dataids = new Set<String>(); |
| | | String data = '12345678'; |
| | |
| | | |
| | | 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>(); |
| | |
| | | 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; |
| | | // } |
| | | } |
| | | } |
| | | } |